File: doc.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,416 kB
  • sloc: sh: 99; makefile: 21
file content (95 lines) | stat: -rw-r--r-- 2,176 bytes parent folder | download | duplicates (2)
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