/
doc.go
95 lines (73 loc) · 2.13 KB
/
doc.go
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
Package containers contains functionality for working with Object Storage
container resources. A container serves as a logical namespace for objects
that are placed inside it - an object with the same name in two different
containers represents two different objects.
In addition to containing objects, you can also use the container to control
access to objects by using an access control list (ACL).
Note: When referencing the Object Storage API docs, some of the API actions
are listed under "accounts" rather than "containers". This was an intentional
design in Gophercloud to make some container actions feel more natural.
Example to List Containers
listOpts := containers.ListOpts{
Full: true,
}
allPages, err := containers.List(objectStorageClient, listOpts).AllPages()
if err != nil {
panic(err)
}
allContainers, err := containers.ExtractInfo(allPages)
if err != nil {
panic(err)
}
for _, container := range allContainers {
fmt.Printf("%+v\n", container)
}
Example to List Only Container Names
listOpts := containers.ListOpts{
Full: false,
}
allPages, err := containers.List(objectStorageClient, listOpts).AllPages()
if err != nil {
panic(err)
}
allContainers, err := containers.ExtractNames(allPages)
if err != nil {
panic(err)
}
for _, container := range allContainers {
fmt.Printf("%+v\n", container)
}
Example to Create a Container
createOpts := containers.CreateOpts{
ContentType: "application/json",
Metadata: map[string]string{
"foo": "bar",
},
}
container, err := containers.Create(objectStorageClient, createOpts).Extract()
if err != nil {
panic(err)
}
Example to Update a Container
containerName := "my_container"
updateOpts := containers.UpdateOpts{
Metadata: map[string]string{
"bar": "baz",
},
RemoveMetadata: []string{
"foo",
},
}
container, err := containers.Update(objectStorageClient, containerName, updateOpts).Extract()
if err != nil {
panic(err)
}
Example to Delete a Container
containerName := "my_container"
container, err := containers.Delete(objectStorageClient, containerName).Extract()
if err != nil {
panic(err)
}
*/
package containers