mirror of
https://github.com/lxc/incus.git
synced 2026-02-05 09:46:19 +01:00
client: Add full variants of volume and bucket list functions
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
This commit is contained in:
@@ -118,6 +118,87 @@ func (r *ProtocolIncus) GetStoragePoolBucketsWithFilterAllProjects(poolName stri
|
||||
return buckets, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolBucketsFull returns a list of storage buckets for the provided pool (full struct).
|
||||
func (r *ProtocolIncus) GetStoragePoolBucketsFull(poolName string) ([]api.StorageBucketFull, error) {
|
||||
err := r.CheckExtension("storage_bucket_full")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buckets := []api.StorageBucketFull{}
|
||||
|
||||
// Fetch the raw value.
|
||||
u := api.NewURL().Path("storage-pools", poolName, "buckets").WithQuery("recursion", "2")
|
||||
_, err = r.queryStruct("GET", u.String(), nil, "", &buckets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buckets, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolBucketsFullWithFilter returns a filtered list of storage buckets for the provided pool (full struct).
|
||||
func (r *ProtocolIncus) GetStoragePoolBucketsFullWithFilter(poolName string, filters []string) ([]api.StorageBucketFull, error) {
|
||||
err := r.CheckExtension("storage_bucket_full")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buckets := []api.StorageBucketFull{}
|
||||
|
||||
// Fetch the raw value
|
||||
u := api.NewURL().Path("storage-pools", poolName, "buckets").
|
||||
WithQuery("recursion", "2").
|
||||
WithQuery("filter", parseFilters(filters))
|
||||
|
||||
_, err = r.queryStruct("GET", u.String(), nil, "", &buckets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buckets, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolBucketsFullAllProjects gets all storage pool buckets across all projects (full struct).
|
||||
func (r *ProtocolIncus) GetStoragePoolBucketsFullAllProjects(poolName string) ([]api.StorageBucketFull, error) {
|
||||
err := r.CheckExtension("storage_bucket_full")
|
||||
if err != nil {
|
||||
return nil, errors.New(`The server is missing the required "storage_bucket_full" API extension`)
|
||||
}
|
||||
|
||||
buckets := []api.StorageBucketFull{}
|
||||
|
||||
u := api.NewURL().Path("storage-pools", poolName, "buckets").WithQuery("recursion", "2").WithQuery("all-projects", "true")
|
||||
_, err = r.queryStruct("GET", u.String(), nil, "", &buckets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buckets, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolBucketsFullWithFilterAllProjects gets a filtered list of storage pool buckets across all projects (full struct).
|
||||
func (r *ProtocolIncus) GetStoragePoolBucketsFullWithFilterAllProjects(poolName string, filters []string) ([]api.StorageBucketFull, error) {
|
||||
err := r.CheckExtension("storage_bucket_full")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buckets := []api.StorageBucketFull{}
|
||||
|
||||
u := api.NewURL().Path("storage-pools", poolName, "buckets").
|
||||
WithQuery("recursion", "2").
|
||||
WithQuery("filter", parseFilters(filters)).
|
||||
WithQuery("all-projects", "true")
|
||||
|
||||
_, err = r.queryStruct("GET", u.String(), nil, "", &buckets)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buckets, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolBucket returns a storage bucket entry for the provided pool and bucket name.
|
||||
func (r *ProtocolIncus) GetStoragePoolBucket(poolName string, bucketName string) (*api.StorageBucket, string, error) {
|
||||
err := r.CheckExtension("storage_buckets")
|
||||
|
||||
@@ -174,6 +174,88 @@ func (r *ProtocolIncus) GetStoragePoolVolumesWithFilterAllProjects(pool string,
|
||||
return volumes, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolVolumesFull returns a list of StorageVolume entries for the provided pool (full struct).
|
||||
func (r *ProtocolIncus) GetStoragePoolVolumesFull(pool string) ([]api.StorageVolumeFull, error) {
|
||||
if !r.HasExtension("storage_volume_full") {
|
||||
return nil, errors.New("The server is missing the required \"storage_volume_full\" API extension")
|
||||
}
|
||||
|
||||
volumes := []api.StorageVolumeFull{}
|
||||
|
||||
// Fetch the raw value
|
||||
_, err := r.queryStruct("GET", fmt.Sprintf("/storage-pools/%s/volumes?recursion=2", url.PathEscape(pool)), nil, "", &volumes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return volumes, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolVolumesFullAllProjects returns a list of StorageVolume entries for the provided pool for all projects (full struct).
|
||||
func (r *ProtocolIncus) GetStoragePoolVolumesFullAllProjects(pool string) ([]api.StorageVolumeFull, error) {
|
||||
err := r.CheckExtension("storage_volume_full")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
volumes := []api.StorageVolumeFull{}
|
||||
|
||||
uri := api.NewURL().Path("storage-pools", pool, "volumes").
|
||||
WithQuery("recursion", "2").
|
||||
WithQuery("all-projects", "true")
|
||||
|
||||
// Fetch the raw value.
|
||||
_, err = r.queryStruct("GET", uri.String(), nil, "", &volumes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return volumes, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolVolumesFullWithFilter returns a filtered list of StorageVolume entries for the provided pool (full struct).
|
||||
func (r *ProtocolIncus) GetStoragePoolVolumesFullWithFilter(pool string, filters []string) ([]api.StorageVolumeFull, error) {
|
||||
if !r.HasExtension("storage_volume_full") {
|
||||
return nil, errors.New("The server is missing the required \"storage_volume_full\" API extension")
|
||||
}
|
||||
|
||||
volumes := []api.StorageVolumeFull{}
|
||||
|
||||
v := url.Values{}
|
||||
v.Set("recursion", "2")
|
||||
v.Set("filter", parseFilters(filters))
|
||||
// Fetch the raw value
|
||||
_, err := r.queryStruct("GET", fmt.Sprintf("/storage-pools/%s/volumes?%s", url.PathEscape(pool), v.Encode()), nil, "", &volumes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return volumes, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolVolumesFullWithFilterAllProjects returns a filtered list of StorageVolume entries for the provided pool for all projects (full struct).
|
||||
func (r *ProtocolIncus) GetStoragePoolVolumesFullWithFilterAllProjects(pool string, filters []string) ([]api.StorageVolumeFull, error) {
|
||||
err := r.CheckExtension("storage_volume_full")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
volumes := []api.StorageVolumeFull{}
|
||||
|
||||
uri := api.NewURL().Path("storage-pools", pool, "volumes").
|
||||
WithQuery("recursion", "2").
|
||||
WithQuery("filter", parseFilters(filters)).
|
||||
WithQuery("all-projects", "true")
|
||||
|
||||
// Fetch the raw value.
|
||||
_, err = r.queryStruct("GET", uri.String(), nil, "", &volumes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return volumes, nil
|
||||
}
|
||||
|
||||
// GetStoragePoolVolume returns a StorageVolume entry for the provided pool and volume name.
|
||||
func (r *ProtocolIncus) GetStoragePoolVolume(pool string, volType string, name string) (*api.StorageVolume, string, error) {
|
||||
if !r.HasExtension("storage") {
|
||||
|
||||
@@ -334,6 +334,10 @@ type InstanceServer interface {
|
||||
GetStoragePoolBucketsWithFilterAllProjects(poolName string, filters []string) (bucket []api.StorageBucket, err error)
|
||||
GetStoragePoolBuckets(poolName string) ([]api.StorageBucket, error)
|
||||
GetStoragePoolBucketsWithFilter(poolName string, filters []string) (bucket []api.StorageBucket, err error)
|
||||
GetStoragePoolBucketsFullAllProjects(poolName string) ([]api.StorageBucketFull, error)
|
||||
GetStoragePoolBucketsFullWithFilterAllProjects(poolName string, filters []string) (bucket []api.StorageBucketFull, err error)
|
||||
GetStoragePoolBucketsFull(poolName string) ([]api.StorageBucketFull, error)
|
||||
GetStoragePoolBucketsFullWithFilter(poolName string, filters []string) (bucket []api.StorageBucketFull, 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)
|
||||
@@ -359,6 +363,10 @@ type InstanceServer interface {
|
||||
GetStoragePoolVolumesAllProjects(pool string) (volumes []api.StorageVolume, err error)
|
||||
GetStoragePoolVolumesWithFilter(pool string, filters []string) (volumes []api.StorageVolume, err error)
|
||||
GetStoragePoolVolumesWithFilterAllProjects(pool string, filters []string) (volumes []api.StorageVolume, err error)
|
||||
GetStoragePoolVolumesFull(pool string) (volumes []api.StorageVolumeFull, err error)
|
||||
GetStoragePoolVolumesFullAllProjects(pool string) (volumes []api.StorageVolumeFull, err error)
|
||||
GetStoragePoolVolumesFullWithFilter(pool string, filters []string) (volumes []api.StorageVolumeFull, err error)
|
||||
GetStoragePoolVolumesFullWithFilterAllProjects(pool string, filters []string) (volumes []api.StorageVolumeFull, 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)
|
||||
|
||||
Reference in New Issue
Block a user