Skip to content

Commit 8630007

Browse files
authored
Merge pull request #1156 from stgraber/main
Fix backup struct naming and swagger metadata
2 parents b4e13c7 + 55079ab commit 8630007

File tree

8 files changed

+132
-132
lines changed

8 files changed

+132
-132
lines changed

client/incus_storage_volumes.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,8 @@ func (r *ProtocolIncus) RenameStoragePoolVolume(pool string, volType string, nam
814814
return nil
815815
}
816816

817-
// GetStoragePoolVolumeBackupNames returns a list of volume backup names.
818-
func (r *ProtocolIncus) GetStoragePoolVolumeBackupNames(pool string, volName string) ([]string, error) {
817+
// GetStorageVolumeBackupNames returns a list of volume backup names.
818+
func (r *ProtocolIncus) GetStorageVolumeBackupNames(pool string, volName string) ([]string, error) {
819819
if !r.HasExtension("custom_volume_backup") {
820820
return nil, fmt.Errorf("The server is missing the required \"custom_volume_backup\" API extension")
821821
}
@@ -832,14 +832,14 @@ func (r *ProtocolIncus) GetStoragePoolVolumeBackupNames(pool string, volName str
832832
return urlsToResourceNames(baseURL, urls...)
833833
}
834834

835-
// GetStoragePoolVolumeBackups returns a list of custom volume backups.
836-
func (r *ProtocolIncus) GetStoragePoolVolumeBackups(pool string, volName string) ([]api.StoragePoolVolumeBackup, error) {
835+
// GetStorageVolumeBackups returns a list of custom volume backups.
836+
func (r *ProtocolIncus) GetStorageVolumeBackups(pool string, volName string) ([]api.StorageVolumeBackup, error) {
837837
if !r.HasExtension("custom_volume_backup") {
838838
return nil, fmt.Errorf("The server is missing the required \"custom_volume_backup\" API extension")
839839
}
840840

841841
// Fetch the raw value
842-
backups := []api.StoragePoolVolumeBackup{}
842+
backups := []api.StorageVolumeBackup{}
843843

844844
_, err := r.queryStruct("GET", fmt.Sprintf("/storage-pools/%s/volumes/custom/%s/backups?recursion=1", url.PathEscape(pool), url.PathEscape(volName)), nil, "", &backups)
845845
if err != nil {
@@ -849,14 +849,14 @@ func (r *ProtocolIncus) GetStoragePoolVolumeBackups(pool string, volName string)
849849
return backups, nil
850850
}
851851

852-
// GetStoragePoolVolumeBackup returns a custom volume backup.
853-
func (r *ProtocolIncus) GetStoragePoolVolumeBackup(pool string, volName string, name string) (*api.StoragePoolVolumeBackup, string, error) {
852+
// GetStorageVolumeBackup returns a custom volume backup.
853+
func (r *ProtocolIncus) GetStorageVolumeBackup(pool string, volName string, name string) (*api.StorageVolumeBackup, string, error) {
854854
if !r.HasExtension("custom_volume_backup") {
855855
return nil, "", fmt.Errorf("The server is missing the required \"custom_volume_backup\" API extension")
856856
}
857857

858858
// Fetch the raw value
859-
backup := api.StoragePoolVolumeBackup{}
859+
backup := api.StorageVolumeBackup{}
860860
etag, err := r.queryStruct("GET", fmt.Sprintf("/storage-pools/%s/volumes/custom/%s/backups/%s", url.PathEscape(pool), url.PathEscape(volName), url.PathEscape(name)), nil, "", &backup)
861861
if err != nil {
862862
return nil, "", err
@@ -865,8 +865,8 @@ func (r *ProtocolIncus) GetStoragePoolVolumeBackup(pool string, volName string,
865865
return &backup, etag, nil
866866
}
867867

868-
// CreateStoragePoolVolumeBackup creates new custom volume backup.
869-
func (r *ProtocolIncus) CreateStoragePoolVolumeBackup(pool string, volName string, backup api.StoragePoolVolumeBackupsPost) (Operation, error) {
868+
// CreateStorageVolumeBackup creates new custom volume backup.
869+
func (r *ProtocolIncus) CreateStorageVolumeBackup(pool string, volName string, backup api.StorageVolumeBackupsPost) (Operation, error) {
870870
if !r.HasExtension("custom_volume_backup") {
871871
return nil, fmt.Errorf("The server is missing the required \"custom_volume_backup\" API extension")
872872
}
@@ -880,8 +880,8 @@ func (r *ProtocolIncus) CreateStoragePoolVolumeBackup(pool string, volName strin
880880
return op, nil
881881
}
882882

883-
// RenameStoragePoolVolumeBackup renames a custom volume backup.
884-
func (r *ProtocolIncus) RenameStoragePoolVolumeBackup(pool string, volName string, name string, backup api.StoragePoolVolumeBackupPost) (Operation, error) {
883+
// RenameStorageVolumeBackup renames a custom volume backup.
884+
func (r *ProtocolIncus) RenameStorageVolumeBackup(pool string, volName string, name string, backup api.StorageVolumeBackupPost) (Operation, error) {
885885
if !r.HasExtension("custom_volume_backup") {
886886
return nil, fmt.Errorf("The server is missing the required \"custom_volume_backup\" API extension")
887887
}
@@ -895,8 +895,8 @@ func (r *ProtocolIncus) RenameStoragePoolVolumeBackup(pool string, volName strin
895895
return op, nil
896896
}
897897

898-
// DeleteStoragePoolVolumeBackup deletes a custom volume backup.
899-
func (r *ProtocolIncus) DeleteStoragePoolVolumeBackup(pool string, volName string, name string) (Operation, error) {
898+
// DeleteStorageVolumeBackup deletes a custom volume backup.
899+
func (r *ProtocolIncus) DeleteStorageVolumeBackup(pool string, volName string, name string) (Operation, error) {
900900
if !r.HasExtension("custom_volume_backup") {
901901
return nil, fmt.Errorf("The server is missing the required \"custom_volume_backup\" API extension")
902902
}
@@ -910,8 +910,8 @@ func (r *ProtocolIncus) DeleteStoragePoolVolumeBackup(pool string, volName strin
910910
return op, nil
911911
}
912912

913-
// GetStoragePoolVolumeBackupFile requests the custom volume backup content.
914-
func (r *ProtocolIncus) GetStoragePoolVolumeBackupFile(pool string, volName string, name string, req *BackupFileRequest) (*BackupFileResponse, error) {
913+
// GetStorageVolumeBackupFile requests the custom volume backup content.
914+
func (r *ProtocolIncus) GetStorageVolumeBackupFile(pool string, volName string, name string, req *BackupFileRequest) (*BackupFileResponse, error) {
915915
if !r.HasExtension("custom_volume_backup") {
916916
return nil, fmt.Errorf("The server is missing the required \"custom_volume_backup\" API extension")
917917
}
@@ -977,7 +977,7 @@ func (r *ProtocolIncus) GetStoragePoolVolumeBackupFile(pool string, volName stri
977977
}
978978

979979
// CreateStoragePoolVolumeFromISO creates a custom volume from an ISO file.
980-
func (r *ProtocolIncus) CreateStoragePoolVolumeFromISO(pool string, args StoragePoolVolumeBackupArgs) (Operation, error) {
980+
func (r *ProtocolIncus) CreateStoragePoolVolumeFromISO(pool string, args StorageVolumeBackupArgs) (Operation, error) {
981981
err := r.CheckExtension("custom_volume_iso")
982982
if err != nil {
983983
return nil, err
@@ -1035,7 +1035,7 @@ func (r *ProtocolIncus) CreateStoragePoolVolumeFromISO(pool string, args Storage
10351035
}
10361036

10371037
// CreateStoragePoolVolumeFromBackup creates a custom volume from a backup file.
1038-
func (r *ProtocolIncus) CreateStoragePoolVolumeFromBackup(pool string, args StoragePoolVolumeBackupArgs) (Operation, error) {
1038+
func (r *ProtocolIncus) CreateStoragePoolVolumeFromBackup(pool string, args StorageVolumeBackupArgs) (Operation, error) {
10391039
if !r.HasExtension("custom_volume_backup") {
10401040
return nil, fmt.Errorf(`The server is missing the required "custom_volume_backup" API extension`)
10411041
}

client/interfaces.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,17 @@ type InstanceServer interface {
353353
UpdateStoragePoolVolumeSnapshot(pool string, volumeType string, volumeName string, snapshotName string, volume api.StorageVolumeSnapshotPut, ETag string) (err error)
354354

355355
// Storage volume backup functions ("custom_volume_backup" API extension)
356-
GetStoragePoolVolumeBackupNames(pool string, volName string) (names []string, err error)
357-
GetStoragePoolVolumeBackups(pool string, volName string) (backups []api.StoragePoolVolumeBackup, err error)
358-
GetStoragePoolVolumeBackup(pool string, volName string, name string) (backup *api.StoragePoolVolumeBackup, ETag string, err error)
359-
CreateStoragePoolVolumeBackup(pool string, volName string, backup api.StoragePoolVolumeBackupsPost) (op Operation, err error)
360-
RenameStoragePoolVolumeBackup(pool string, volName string, name string, backup api.StoragePoolVolumeBackupPost) (op Operation, err error)
361-
DeleteStoragePoolVolumeBackup(pool string, volName string, name string) (op Operation, err error)
362-
GetStoragePoolVolumeBackupFile(pool string, volName string, name string, req *BackupFileRequest) (resp *BackupFileResponse, err error)
363-
CreateStoragePoolVolumeFromBackup(pool string, args StoragePoolVolumeBackupArgs) (op Operation, err error)
356+
GetStorageVolumeBackupNames(pool string, volName string) (names []string, err error)
357+
GetStorageVolumeBackups(pool string, volName string) (backups []api.StorageVolumeBackup, err error)
358+
GetStorageVolumeBackup(pool string, volName string, name string) (backup *api.StorageVolumeBackup, ETag string, err error)
359+
CreateStorageVolumeBackup(pool string, volName string, backup api.StorageVolumeBackupsPost) (op Operation, err error)
360+
RenameStorageVolumeBackup(pool string, volName string, name string, backup api.StorageVolumeBackupPost) (op Operation, err error)
361+
DeleteStorageVolumeBackup(pool string, volName string, name string) (op Operation, err error)
362+
GetStorageVolumeBackupFile(pool string, volName string, name string, req *BackupFileRequest) (resp *BackupFileResponse, err error)
363+
CreateStoragePoolVolumeFromBackup(pool string, args StorageVolumeBackupArgs) (op Operation, err error)
364364

365365
// Storage volume ISO import function ("custom_volume_iso" API extension)
366-
CreateStoragePoolVolumeFromISO(pool string, args StoragePoolVolumeBackupArgs) (op Operation, err error)
366+
CreateStoragePoolVolumeFromISO(pool string, args StorageVolumeBackupArgs) (op Operation, err error)
367367

368368
// Cluster functions ("cluster" API extensions)
369369
GetCluster() (cluster *api.Cluster, ETag string, err error)
@@ -532,9 +532,9 @@ type StoragePoolVolumeMoveArgs struct {
532532
Project string
533533
}
534534

535-
// The StoragePoolVolumeBackupArgs struct is used when creating a storage volume from a backup.
535+
// The StorageVolumeBackupArgs struct is used when creating a storage volume from a backup.
536536
// API extension: custom_volume_backup.
537-
type StoragePoolVolumeBackupArgs struct {
537+
type StorageVolumeBackupArgs struct {
538538
// The backup file
539539
BackupFile io.Reader
540540

cmd/incus/storage_volume.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -1402,9 +1402,9 @@ func (c *cmdStorageVolumeInfo) Run(cmd *cobra.Command, args []string) error {
14021402
return err
14031403
}
14041404

1405-
var volBackups []api.StoragePoolVolumeBackup
1405+
var volBackups []api.StorageVolumeBackup
14061406
if client.HasExtension("custom_volume_backup") && volType == "custom" {
1407-
volBackups, err = client.GetStoragePoolVolumeBackups(resource.name, volName)
1407+
volBackups, err = client.GetStorageVolumeBackups(resource.name, volName)
14081408
if err != nil {
14091409
return err
14101410
}
@@ -2976,15 +2976,15 @@ func (c *cmdStorageVolumeExport) Run(cmd *cobra.Command, args []string) error {
29762976
return fmt.Errorf(i18n.G("Only \"custom\" volumes can be exported"))
29772977
}
29782978

2979-
req := api.StoragePoolVolumeBackupsPost{
2979+
req := api.StorageVolumeBackupsPost{
29802980
Name: "",
29812981
ExpiresAt: time.Now().Add(24 * time.Hour),
29822982
VolumeOnly: volumeOnly,
29832983
OptimizedStorage: c.flagOptimizedStorage,
29842984
CompressionAlgorithm: c.flagCompressionAlgorithm,
29852985
}
29862986

2987-
op, err := d.CreateStoragePoolVolumeBackup(name, volName, req)
2987+
op, err := d.CreateStorageVolumeBackup(name, volName, req)
29882988
if err != nil {
29892989
return fmt.Errorf(i18n.G("Failed to create storage volume backup: %w"), err)
29902990
}
@@ -3029,7 +3029,7 @@ func (c *cmdStorageVolumeExport) Run(cmd *cobra.Command, args []string) error {
30293029

30303030
defer func() {
30313031
// Delete backup after we're done
3032-
op, err = d.DeleteStoragePoolVolumeBackup(name, volName, backupName)
3032+
op, err = d.DeleteStorageVolumeBackup(name, volName, backupName)
30333033
if err == nil {
30343034
_ = op.Wait()
30353035
}
@@ -3061,7 +3061,7 @@ func (c *cmdStorageVolumeExport) Run(cmd *cobra.Command, args []string) error {
30613061
}
30623062

30633063
// Export tarball
3064-
_, err = d.GetStoragePoolVolumeBackupFile(name, volName, backupName, &backupFileRequest)
3064+
_, err = d.GetStorageVolumeBackupFile(name, volName, backupName, &backupFileRequest)
30653065
if err != nil {
30663066
_ = os.Remove(targetName)
30673067
progress.Done("")
@@ -3172,7 +3172,7 @@ func (c *cmdStorageVolumeImport) Run(cmd *cobra.Command, args []string) error {
31723172
Quiet: c.global.flagQuiet,
31733173
}
31743174

3175-
createArgs := incus.StoragePoolVolumeBackupArgs{
3175+
createArgs := incus.StorageVolumeBackupArgs{
31763176
BackupFile: &ioprogress.ProgressReader{
31773177
ReadCloser: file,
31783178
Tracker: &ioprogress.ProgressTracker{

cmd/incusd/storage_buckets_backup.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ var storagePoolBucketBackupsExportCmd = APIEndpoint{
147147
// type: array
148148
// description: List of storage bucket backups
149149
// items:
150-
// $ref: "#/definitions/StoragePoolBucketBackup"
150+
// $ref: "#/definitions/StorageBucketBackup"
151151
// "403":
152152
// $ref: "#/responses/Forbidden"
153153
// "500":
@@ -231,7 +231,7 @@ func storagePoolBucketBackupsGet(d *Daemon, r *http.Request) response.Response {
231231
// description: Storage bucket backup
232232
// required: true
233233
// schema:
234-
// $ref: "#/definitions/StoragePoolBucketBackupsPost"
234+
// $ref: "#/definitions/StorageBucketBackupsPost"
235235
// responses:
236236
// "202":
237237
// $ref: "#/responses/Operation"
@@ -431,7 +431,7 @@ func storagePoolBucketBackupsPost(d *Daemon, r *http.Request) response.Response
431431
// description: Status code
432432
// example: 200
433433
// metadata:
434-
// $ref: "#/definitions/StoragePoolBucketBackup"
434+
// $ref: "#/definitions/StorageBucketBackup"
435435
// "403":
436436
// $ref: "#/responses/Forbidden"
437437
// "500":

cmd/incusd/storage_volumes_backup.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ var storagePoolVolumeTypeCustomBackupExportCmd = APIEndpoint{
148148
// type: array
149149
// description: List of storage volume backups
150150
// items:
151-
// $ref: "#/definitions/StoragePoolVolumeBackup"
151+
// $ref: "#/definitions/StorageVolumeBackup"
152152
// "403":
153153
// $ref: "#/responses/Forbidden"
154154
// "500":
@@ -228,7 +228,7 @@ func storagePoolVolumeTypeCustomBackupsGet(d *Daemon, r *http.Request) response.
228228
}
229229

230230
resultString := []string{}
231-
resultMap := []*api.StoragePoolVolumeBackup{}
231+
resultMap := []*api.StorageVolumeBackup{}
232232

233233
for _, backup := range backups {
234234
if !recursion {
@@ -274,7 +274,7 @@ func storagePoolVolumeTypeCustomBackupsGet(d *Daemon, r *http.Request) response.
274274
// description: Storage volume backup
275275
// required: true
276276
// schema:
277-
// $ref: "#/definitions/StoragePoolVolumeBackupsPost"
277+
// $ref: "#/definitions/StorageVolumeBackupsPost"
278278
// responses:
279279
// "202":
280280
// $ref: "#/responses/Operation"
@@ -379,7 +379,7 @@ func storagePoolVolumeTypeCustomBackupsPost(d *Daemon, r *http.Request) response
379379
return response.InternalError(err)
380380
}
381381

382-
req := api.StoragePoolVolumeBackupsPost{}
382+
req := api.StorageVolumeBackupsPost{}
383383

384384
err = json.Unmarshal(body, &req)
385385
if err != nil {
@@ -504,7 +504,7 @@ func storagePoolVolumeTypeCustomBackupsPost(d *Daemon, r *http.Request) response
504504
// description: Status code
505505
// example: 200
506506
// metadata:
507-
// $ref: "#/definitions/StoragePoolVolumeBackup"
507+
// $ref: "#/definitions/StorageVolumeBackup"
508508
// "403":
509509
// $ref: "#/responses/Forbidden"
510510
// "500":
@@ -662,7 +662,7 @@ func storagePoolVolumeTypeCustomBackupPost(d *Daemon, r *http.Request) response.
662662
return resp
663663
}
664664

665-
req := api.StoragePoolVolumeBackupPost{}
665+
req := api.StorageVolumeBackupPost{}
666666
err = json.NewDecoder(r.Body).Decode(&req)
667667
if err != nil {
668668
return response.BadRequest(err)

0 commit comments

Comments
 (0)