github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/objectstorage/v1/containers/doc.go (about) 1 /* 2 Package containers contains functionality for working with Object Storage 3 container resources. A container serves as a logical namespace for objects 4 that are placed inside it - an object with the same name in two different 5 containers represents two different objects. 6 7 In addition to containing objects, you can also use the container to control 8 access to objects by using an access control list (ACL). 9 10 Note: When referencing the Object Storage API docs, some of the API actions 11 are listed under "accounts" rather than "containers". This was an intentional 12 design in Gophercloud to make some container actions feel more natural. 13 14 Example to List Containers 15 16 listOpts := containers.ListOpts{ 17 Full: true, 18 } 19 20 allPages, err := containers.List(objectStorageClient, listOpts).AllPages() 21 if err != nil { 22 panic(err) 23 } 24 25 allContainers, err := containers.ExtractInfo(allPages) 26 if err != nil { 27 panic(err) 28 } 29 30 for _, container := range allContainers { 31 fmt.Printf("%+v\n", container) 32 } 33 34 Example to List Only Container Names 35 36 listOpts := containers.ListOpts{ 37 Full: false, 38 } 39 40 allPages, err := containers.List(objectStorageClient, listOpts).AllPages() 41 if err != nil { 42 panic(err) 43 } 44 45 allContainers, err := containers.ExtractNames(allPages) 46 if err != nil { 47 panic(err) 48 } 49 50 for _, container := range allContainers { 51 fmt.Printf("%+v\n", container) 52 } 53 54 Example to Create a Container 55 56 createOpts := containers.CreateOpts{ 57 ContentType: "application/json", 58 Metadata: map[string]string{ 59 "foo": "bar", 60 }, 61 } 62 63 container, err := containers.Create(objectStorageClient, createOpts).Extract() 64 if err != nil { 65 panic(err) 66 } 67 68 Example to Update a Container 69 70 containerName := "my_container" 71 72 updateOpts := containers.UpdateOpts{ 73 Metadata: map[string]string{ 74 "bar": "baz", 75 }, 76 } 77 78 container, err := containers.Update(objectStorageClient, containerName, updateOpts).Extract() 79 if err != nil { 80 panic(err) 81 } 82 83 Example to Delete a Container 84 85 containerName := "my_container" 86 87 container, err := containers.Delete(objectStorageClient, containerName).Extract() 88 if err != nil { 89 panic(err) 90 } 91 */ 92 package containers