UpCloudLtd / upcloud-go-api

Go client for UpCloud's API
https://pkg.go.dev/github.com/UpCloudLtd/upcloud-go-api/v6
MIT License
42 stars 9 forks source link

List storages by type #87

Open fabioDMFerreira opened 3 years ago

fabioDMFerreira commented 3 years ago

The list storages method seems to don't filter storages by type.

GetStorages should read the storage type of the request and append the storage type to the URL used to get storages.

https://github.com/UpCloudLtd/upcloud-go-api/blob/af59376c7bf914854e0ef3b13ad4ee9435ea2919/upcloud/service/storage.go#L41

https://developers.upcloud.com/1.3/9-storages/#list-storages

I don't mind to open a PR if nobody is working on this.

peknur commented 2 years ago

Hi @fabioDMFerreira ,

You can filter storages by type using Type field in request.GetStoragesRequest . For example list only templates:

service.GetStorages(&request.GetStoragesRequest{
    Type: upcloud.StorageTypeTemplate,
})

You can use that with Access field to get your private templates:

service.GetStorages(&request.GetStoragesRequest{
    Type: upcloud.StorageTypeTemplate,
    Access: upcloud.StorageAccessPrivate,
})