-
Notifications
You must be signed in to change notification settings - Fork 589
Expand file tree
/
Copy pathdoc.go
More file actions
61 lines (51 loc) · 1.48 KB
/
doc.go
File metadata and controls
61 lines (51 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
Package snapshots provides information and interaction with snapshots in the
OpenStack Block Storage service. A snapshot is a point in time copy of the
data contained in an external storage volume, and can be controlled
programmatically.
Example to list Snapshots
allPages, err := snapshots.List(client, snapshots.ListOpts{}).AllPages(context.TODO())
if err != nil{
panic(err)
}
snapshots, err := snapshots.ExtractSnapshots(allPages)
if err != nil{
panic(err)
}
for _,s := range snapshots{
fmt.Println(s)
}
Example to get a Snapshot
snapshotID := "4a584cae-e4ce-429b-9154-d4c9eb8fda4c"
snapshot, err := snapshots.Get(context.TODO(), client, snapshotID).Extract()
if err != nil{
panic(err)
}
fmt.Println(snapshot)
Example to create a Snapshot
snapshot, err := snapshots.Create(context.TODO(), client, snapshots.CreateOpts{
Name:"snapshot_001",
VolumeID:"5aa119a8-d25b-45a7-8d1b-88e127885635",
}).Extract()
if err != nil{
panic(err)
}
fmt.Println(snapshot)
Example to delete a Snapshot
snapshotID := "4a584cae-e4ce-429b-9154-d4c9eb8fda4c"
err := snapshots.Delete(context.TODO(), client, snapshotID).ExtractErr()
if err != nil{
panic(err)
}
Example to update a Snapshot
snapshotID := "4a584cae-e4ce-429b-9154-d4c9eb8fda4c"
snapshot, err = snapshots.Update(context.TODO(), client, snapshotID, snapshots.UpdateOpts{
Name: "snapshot_002",
Description:"description_002",
}).Extract()
if err != nil{
panic(err)
}
fmt.Println(snapshot)
*/
package snapshots