Skip to content

Commit 8a59085

Browse files
authored
feat(cli): onboard iaas snapshot api (#774)
1 parent b27b82c commit 8a59085

24 files changed

+2248
-8
lines changed

docs/stackit_volume.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ stackit volume [flags]
3737
* [stackit volume list](./stackit_volume_list.md) - Lists all volumes of a project
3838
* [stackit volume performance-class](./stackit_volume_performance-class.md) - Provides functionality for volume performance classes available inside a project
3939
* [stackit volume resize](./stackit_volume_resize.md) - Resizes a volume
40+
* [stackit volume snapshot](./stackit_volume_snapshot.md) - Provides functionality for snapshots
4041
* [stackit volume update](./stackit_volume_update.md) - Updates a volume
4142

docs/stackit_volume_snapshot.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## stackit volume snapshot
2+
3+
Provides functionality for snapshots
4+
5+
### Synopsis
6+
7+
Provides functionality for snapshots.
8+
9+
```
10+
stackit volume snapshot [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help Help for "stackit volume snapshot"
17+
```
18+
19+
### Options inherited from parent commands
20+
21+
```
22+
-y, --assume-yes If set, skips all confirmation prompts
23+
--async If set, runs the command asynchronously
24+
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
25+
-p, --project-id string Project ID
26+
--region string Target region for region-specific requests
27+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
28+
```
29+
30+
### SEE ALSO
31+
32+
* [stackit volume](./stackit_volume.md) - Provides functionality for volumes
33+
* [stackit volume snapshot create](./stackit_volume_snapshot_create.md) - Creates a snapshot from a volume
34+
* [stackit volume snapshot delete](./stackit_volume_snapshot_delete.md) - Deletes a snapshot
35+
* [stackit volume snapshot describe](./stackit_volume_snapshot_describe.md) - Describes a snapshot
36+
* [stackit volume snapshot list](./stackit_volume_snapshot_list.md) - Lists all snapshots
37+
* [stackit volume snapshot update](./stackit_volume_snapshot_update.md) - Updates a snapshot
38+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## stackit volume snapshot create
2+
3+
Creates a snapshot from a volume
4+
5+
### Synopsis
6+
7+
Creates a snapshot from a volume.
8+
9+
```
10+
stackit volume snapshot create [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Create a snapshot from a volume with ID "xxx"
17+
$ stackit volume snapshot create --volume-id xxx
18+
19+
Create a snapshot from a volume with ID "xxx" and name "my-snapshot"
20+
$ stackit volume snapshot create --volume-id xxx --name my-snapshot
21+
22+
Create a snapshot from a volume with ID "xxx" and labels
23+
$ stackit volume snapshot create --volume-id xxx --labels key1=value1,key2=value2
24+
```
25+
26+
### Options
27+
28+
```
29+
-h, --help Help for "stackit volume snapshot create"
30+
--labels stringToString Key-value string pairs as labels (default [])
31+
--name string Name of the snapshot
32+
--volume-id string ID of the volume from which a snapshot should be created
33+
```
34+
35+
### Options inherited from parent commands
36+
37+
```
38+
-y, --assume-yes If set, skips all confirmation prompts
39+
--async If set, runs the command asynchronously
40+
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
41+
-p, --project-id string Project ID
42+
--region string Target region for region-specific requests
43+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
44+
```
45+
46+
### SEE ALSO
47+
48+
* [stackit volume snapshot](./stackit_volume_snapshot.md) - Provides functionality for snapshots
49+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## stackit volume snapshot delete
2+
3+
Deletes a snapshot
4+
5+
### Synopsis
6+
7+
Deletes a snapshot by its ID.
8+
9+
```
10+
stackit volume snapshot delete SNAPSHOT_ID [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Delete a snapshot with ID "xxx"
17+
$ stackit volume snapshot delete xxx
18+
```
19+
20+
### Options
21+
22+
```
23+
-h, --help Help for "stackit volume snapshot delete"
24+
```
25+
26+
### Options inherited from parent commands
27+
28+
```
29+
-y, --assume-yes If set, skips all confirmation prompts
30+
--async If set, runs the command asynchronously
31+
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
32+
-p, --project-id string Project ID
33+
--region string Target region for region-specific requests
34+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
35+
```
36+
37+
### SEE ALSO
38+
39+
* [stackit volume snapshot](./stackit_volume_snapshot.md) - Provides functionality for snapshots
40+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## stackit volume snapshot describe
2+
3+
Describes a snapshot
4+
5+
### Synopsis
6+
7+
Describes a snapshot by its ID.
8+
9+
```
10+
stackit volume snapshot describe SNAPSHOT_ID [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Get details of a snapshot with ID "xxx"
17+
$ stackit volume snapshot describe xxx
18+
19+
Get details of a snapshot with ID "xxx" in JSON format
20+
$ stackit volume snapshot describe xxx --output-format json
21+
```
22+
23+
### Options
24+
25+
```
26+
-h, --help Help for "stackit volume snapshot describe"
27+
```
28+
29+
### Options inherited from parent commands
30+
31+
```
32+
-y, --assume-yes If set, skips all confirmation prompts
33+
--async If set, runs the command asynchronously
34+
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
35+
-p, --project-id string Project ID
36+
--region string Target region for region-specific requests
37+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
38+
```
39+
40+
### SEE ALSO
41+
42+
* [stackit volume snapshot](./stackit_volume_snapshot.md) - Provides functionality for snapshots
43+

docs/stackit_volume_snapshot_list.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## stackit volume snapshot list
2+
3+
Lists all snapshots
4+
5+
### Synopsis
6+
7+
Lists all snapshots in a project.
8+
9+
```
10+
stackit volume snapshot list [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
List all snapshots
17+
$ stackit volume snapshot list
18+
19+
List snapshots with a limit of 10
20+
$ stackit volume snapshot list --limit 10
21+
22+
List snapshots filtered by label
23+
$ stackit volume snapshot list --label-selector key1=value1
24+
```
25+
26+
### Options
27+
28+
```
29+
-h, --help Help for "stackit volume snapshot list"
30+
--label-selector string Filter snapshots by labels
31+
--limit int Maximum number of entries to list
32+
```
33+
34+
### Options inherited from parent commands
35+
36+
```
37+
-y, --assume-yes If set, skips all confirmation prompts
38+
--async If set, runs the command asynchronously
39+
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
40+
-p, --project-id string Project ID
41+
--region string Target region for region-specific requests
42+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
43+
```
44+
45+
### SEE ALSO
46+
47+
* [stackit volume snapshot](./stackit_volume_snapshot.md) - Provides functionality for snapshots
48+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## stackit volume snapshot update
2+
3+
Updates a snapshot
4+
5+
### Synopsis
6+
7+
Updates a snapshot by its ID.
8+
9+
```
10+
stackit volume snapshot update SNAPSHOT_ID [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Update a snapshot name with ID "xxx"
17+
$ stackit volume snapshot update xxx --name my-new-name
18+
19+
Update a snapshot labels with ID "xxx"
20+
$ stackit volume snapshot update xxx --labels key1=value1,key2=value2
21+
```
22+
23+
### Options
24+
25+
```
26+
-h, --help Help for "stackit volume snapshot update"
27+
--labels stringToString Key-value string pairs as labels (default [])
28+
--name string Name of the snapshot
29+
```
30+
31+
### Options inherited from parent commands
32+
33+
```
34+
-y, --assume-yes If set, skips all confirmation prompts
35+
--async If set, runs the command asynchronously
36+
-o, --output-format string Output format, one of ["json" "pretty" "none" "yaml"]
37+
-p, --project-id string Project ID
38+
--region string Target region for region-specific requests
39+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
40+
```
41+
42+
### SEE ALSO
43+
44+
* [stackit volume snapshot](./stackit_volume_snapshot.md) - Provides functionality for snapshots
45+

internal/cmd/volume/backup/describe/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func outputResult(p *print.Printer, outputFormat string, backup *iaas.Backup) er
128128
table.AddSeparator()
129129
table.AddRow("NAME", utils.PtrString(backup.Name))
130130
table.AddSeparator()
131-
table.AddRow("SIZE", utils.PtrByteSizeDefault(backup.Size, ""))
131+
table.AddRow("SIZE", utils.PtrGigaByteSizeDefault(backup.Size, "n/a"))
132132
table.AddSeparator()
133133
table.AddRow("STATUS", utils.PtrString(backup.Status))
134134
table.AddSeparator()

internal/cmd/volume/backup/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func outputResult(p *print.Printer, outputFormat string, backups []iaas.Backup)
184184
table.AddRow(
185185
utils.PtrString(backup.Id),
186186
utils.PtrString(backup.Name),
187-
utils.PtrByteSizeDefault(backup.Size, ""),
187+
utils.PtrGigaByteSizeDefault(backup.Size, "n/a"),
188188
utils.PtrString(backup.Status),
189189
utils.PtrString(backup.SnapshotId),
190190
utils.PtrString(backup.VolumeId),

internal/cmd/volume/backup/update/update_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/stackitcloud/stackit-cli/internal/cmd/params"
88
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
99
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
10+
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1011

1112
"github.com/google/go-cmp/cmp"
1213
"github.com/google/go-cmp/cmp/cmpopts"
@@ -68,12 +69,7 @@ func fixtureRequest(mods ...func(request *iaas.ApiUpdateBackupRequest)) iaas.Api
6869
payload := iaas.NewUpdateBackupPayloadWithDefaults()
6970
payload.Name = &testName
7071

71-
// Convert test labels to map[string]interface{}
72-
labelsMap := map[string]interface{}{}
73-
for k, v := range testLabels {
74-
labelsMap[k] = v
75-
}
76-
payload.Labels = &labelsMap
72+
payload.Labels = utils.ConvertStringMapToInterfaceMap(utils.Ptr(testLabels))
7773

7874
request = request.UpdateBackupPayload(*payload)
7975
for _, mod := range mods {

0 commit comments

Comments
 (0)