diff --git a/client/incus_storage_buckets.go b/client/incus_storage_buckets.go index e809d882d..69b4f559d 100644 --- a/client/incus_storage_buckets.go +++ b/client/incus_storage_buckets.go @@ -137,6 +137,25 @@ func (r *ProtocolIncus) GetStoragePoolBucket(poolName string, bucketName string) return &bucket, etag, nil } +// GetStoragePoolBucketFull returns a full storage bucket entry for the provided pool and bucket name. +func (r *ProtocolIncus) GetStoragePoolBucketFull(poolName string, bucketName string) (*api.StorageBucketFull, string, error) { + err := r.CheckExtension("storage_bucket_full") + if err != nil { + return nil, "", err + } + + bucket := api.StorageBucketFull{} + + // Fetch the raw value. + u := api.NewURL().Path("storage-pools", poolName, "buckets", bucketName).WithQuery("recursion", "1") + etag, err := r.queryStruct("GET", u.String(), nil, "", &bucket) + if err != nil { + return nil, "", err + } + + return &bucket, etag, nil +} + // CreateStoragePoolBucket defines a new storage bucket using the provided struct. // If the server supports storage_buckets_create_credentials API extension, then this function will return the // initial admin credentials. Otherwise it will be nil. diff --git a/client/incus_storage_volumes.go b/client/incus_storage_volumes.go index bc6bb19de..7cb8b5068 100644 --- a/client/incus_storage_volumes.go +++ b/client/incus_storage_volumes.go @@ -192,6 +192,24 @@ func (r *ProtocolIncus) GetStoragePoolVolume(pool string, volType string, name s return &volume, etag, nil } +// GetStoragePoolVolumeFull returns a StorageVolumeFull entry for the provided pool and volume name. +func (r *ProtocolIncus) GetStoragePoolVolumeFull(pool string, volType string, name string) (*api.StorageVolumeFull, string, error) { + if !r.HasExtension("storage_volume_full") { + return nil, "", errors.New("The server is missing the required \"storage_volume_full\" API extension") + } + + volume := api.StorageVolumeFull{} + + // Fetch the raw value + path := fmt.Sprintf("/storage-pools/%s/volumes/%s/%s?recursion=1", url.PathEscape(pool), url.PathEscape(volType), url.PathEscape(name)) + etag, err := r.queryStruct("GET", path, nil, "", &volume) + if err != nil { + return nil, "", err + } + + return &volume, etag, nil +} + // GetStoragePoolVolumeState returns a StorageVolumeState entry for the provided pool and volume name. func (r *ProtocolIncus) GetStoragePoolVolumeState(pool string, volType string, name string) (*api.StorageVolumeState, error) { if !r.HasExtension("storage_volume_state") { diff --git a/client/interfaces.go b/client/interfaces.go index 076d16ac1..d0ece5503 100644 --- a/client/interfaces.go +++ b/client/interfaces.go @@ -335,6 +335,7 @@ type InstanceServer interface { GetStoragePoolBuckets(poolName string) ([]api.StorageBucket, error) GetStoragePoolBucketsWithFilter(poolName string, filters []string) (bucket []api.StorageBucket, err error) GetStoragePoolBucket(poolName string, bucketName string) (bucket *api.StorageBucket, ETag string, err error) + GetStoragePoolBucketFull(poolName string, bucketName string) (bucket *api.StorageBucketFull, ETag string, err error) CreateStoragePoolBucket(poolName string, bucket api.StorageBucketsPost) (*api.StorageBucketKey, error) UpdateStoragePoolBucket(poolName string, bucketName string, bucket api.StorageBucketPut, ETag string) (err error) DeleteStoragePoolBucket(poolName string, bucketName string) (err error) @@ -359,6 +360,7 @@ type InstanceServer interface { GetStoragePoolVolumesWithFilter(pool string, filters []string) (volumes []api.StorageVolume, err error) GetStoragePoolVolumesWithFilterAllProjects(pool string, filters []string) (volumes []api.StorageVolume, err error) GetStoragePoolVolume(pool string, volType string, name string) (volume *api.StorageVolume, ETag string, err error) + GetStoragePoolVolumeFull(pool string, volType string, name string) (volume *api.StorageVolumeFull, ETag string, err error) GetStoragePoolVolumeState(pool string, volType string, name string) (state *api.StorageVolumeState, err error) CreateStoragePoolVolume(pool string, volume api.StorageVolumesPost) (err error) UpdateStoragePoolVolume(pool string, volType string, name string, volume api.StorageVolumePut, ETag string) (err error)