1
0
mirror of https://github.com/lxc/incus.git synced 2026-02-05 09:46:19 +01:00

client: Add GetStoragePoolBucketFull and GetStoragePoolVolumeFull

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
This commit is contained in:
Stéphane Graber
2025-11-27 03:34:34 -05:00
parent 9b23183b52
commit e5bb1ec415
3 changed files with 39 additions and 0 deletions

View File

@@ -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.

View File

@@ -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") {

View File

@@ -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)