Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / doc / radosgw / swift / containerops.rst
1 ======================
2  Container Operations
3 ======================
4
5 A container is a mechanism for storing data objects. An account may
6 have many containers, but container names must be unique. This API enables a 
7 client to create a container, set access controls and metadata, 
8 retrieve a container's contents, and delete a container. Since this API 
9 makes requests related to information in a particular user's account, all 
10 requests in this API must be authenticated unless a container's access control
11 is deliberately made publicly accessible (i.e., allows anonymous requests).
12
13 .. note:: The Amazon S3 API uses the term 'bucket' to describe a data container.
14    When you hear someone refer to a 'bucket' within the Swift API, the term 
15    'bucket' may be construed as the equivalent of the term 'container.'
16    
17 One facet of object storage is that it does not support hierarchical paths
18 or directories. Instead, it supports one level consisting of one or more
19 containers, where each container may have objects. The RADOS Gateway's
20 Swift-compatible API supports the notion of 'pseudo-hierarchical containers,'
21 which is a means of using object naming to emulate a container (or directory)
22 hierarchy without actually implementing one in the storage system. You may 
23 name objects with pseudo-hierarchical names 
24 (e.g., photos/buildings/empire-state.jpg), but container names cannot
25 contain a forward slash (``/``) character.
26
27
28 Create a Container
29 ==================
30
31 To create a new container, make a ``PUT`` request with the API version, account,
32 and the name of the new container. The container name must be unique, must not
33 contain a forward-slash (/) character, and should be less than 256 bytes. You 
34 may include access control headers and metadata headers in the request. The 
35 operation is idempotent; that is, if you make a request to create a container
36 that already exists, it will return with a HTTP 202 return code, but will not
37 create another container.
38
39
40 Syntax
41 ~~~~~~
42
43 ::
44
45         PUT /{api version}/{account}/{container} HTTP/1.1
46         Host: {fqdn}
47         X-Auth-Token: {auth-token}
48         X-Container-Read: {comma-separated-uids}
49         X-Container-Write: {comma-separated-uids}
50         X-Container-Meta-{key}: {value}
51
52
53 Headers
54 ~~~~~~~
55
56 ``X-Container-Read``
57
58 :Description: The user IDs with read permissions for the container. 
59 :Type: Comma-separated string values of user IDs.
60 :Required: No
61
62 ``X-Container-Write``
63
64 :Description: The user IDs with write permissions for the container.
65 :Type: Comma-separated string values of user IDs.
66 :Required: No
67
68 ``X-Container-Meta-{key}``
69
70 :Description:  A user-defined meta data key that takes an arbitrary string value.
71 :Type: String
72 :Required: No
73
74
75 HTTP Response
76 ~~~~~~~~~~~~~
77
78 If a container with the same name already exists, and the user is the
79 container owner then the operation will succeed. Otherwise the operation
80 will fail.
81
82 ``409``
83
84 :Description: The container already exists under a different user's ownership.
85 :Status Code: ``BucketAlreadyExists``
86
87
88
89
90 List a Container's Objects
91 ==========================
92
93 To list the objects within a container, make a ``GET`` request with the with the 
94 API version, account, and the name of the container.  You can specify query 
95 parameters to filter the full list, or leave out the parameters to return a list 
96 of the first 10,000 object names stored in the container.
97
98
99 Syntax
100 ~~~~~~
101
102 ::
103
104    GET /{api version}/{container} HTTP/1.1
105         Host: {fqdn}
106         X-Auth-Token: {auth-token}
107
108
109 Parameters
110 ~~~~~~~~~~
111
112 ``format``
113
114 :Description: Defines the format of the result. 
115 :Type: String
116 :Valid Values: ``json`` | ``xml``
117 :Required: No
118
119 ``prefix``
120
121 :Description: Limits the result set to objects beginning with the specified prefix.
122 :Type: String
123 :Required: No
124
125 ``marker``
126
127 :Description: Returns a list of results greater than the marker value.
128 :Type: String
129 :Required: No
130
131 ``limit``
132
133 :Description: Limits the number of results to the specified value.
134 :Type: Integer
135 :Valid Range: 0 - 10,000
136 :Required: No
137
138 ``delimiter``
139
140 :Description: The delimiter between the prefix and the rest of the object name.
141 :Type: String
142 :Required: No
143
144 ``path``
145
146 :Description: The pseudo-hierarchical path of the objects.
147 :Type: String
148 :Required: No
149
150
151 Response Entities
152 ~~~~~~~~~~~~~~~~~
153
154 ``container``
155
156 :Description: The container. 
157 :Type: Container
158
159 ``object``
160
161 :Description: An object within the container.
162 :Type: Container
163
164 ``name``
165
166 :Description: The name of an object within the container.
167 :Type: String
168
169 ``hash``
170
171 :Description: A hash code of the object's contents.
172 :Type: String
173
174 ``last_modified``
175
176 :Description: The last time the object's contents were modified.
177 :Type: Date
178
179 ``content_type``
180
181 :Description: The type of content within the object.
182 :Type: String
183
184
185
186 Update a Container's ACLs
187 =========================
188
189 When a user creates a container, the user has read and write access to the
190 container by default. To allow other users to read a container's contents or
191 write to a container, you must specifically enable the user. 
192 You may also specify ``*`` in the ``X-Container-Read`` or ``X-Container-Write``
193 settings, which effectively enables all users to either read from or write
194 to the container. Setting ``*`` makes the container public. That is it 
195 enables anonymous users to either read from or write to the container.
196
197
198 Syntax
199 ~~~~~~
200
201 ::
202
203    POST /{api version}/{account}/{container} HTTP/1.1
204    Host: {fqdn}
205         X-Auth-Token: {auth-token}
206         X-Container-Read: *
207         X-Container-Write: {uid1}, {uid2}, {uid3}
208
209 Request Headers
210 ~~~~~~~~~~~~~~~
211
212 ``X-Container-Read``
213
214 :Description: The user IDs with read permissions for the container. 
215 :Type: Comma-separated string values of user IDs.
216 :Required: No
217
218 ``X-Container-Write``
219
220 :Description: The user IDs with write permissions for the container.
221 :Type: Comma-separated string values of user IDs.
222 :Required: No
223
224
225 Add/Update Container Metadata
226 =============================
227
228 To add metadata to a container, make a ``POST`` request with the API version, 
229 account, and container name. You must have write permissions on the 
230 container to add or update metadata.
231
232 Syntax
233 ~~~~~~
234
235 ::
236
237    POST /{api version}/{account}/{container} HTTP/1.1
238    Host: {fqdn}
239         X-Auth-Token: {auth-token}
240         X-Container-Meta-Color: red
241         X-Container-Meta-Taste: salty
242         
243 Request Headers
244 ~~~~~~~~~~~~~~~
245
246 ``X-Container-Meta-{key}``
247
248 :Description:  A user-defined meta data key that takes an arbitrary string value.
249 :Type: String
250 :Required: No
251
252
253
254 Delete a Container
255 ==================
256
257 To delete a container, make a ``DELETE`` request with the API version, account,
258 and the name of the container. The container must be empty. If you'd like to check 
259 if the container is empty, execute a ``HEAD`` request against the container. Once 
260 you have successfully removed the container, you will be able to reuse the container name.
261
262 Syntax
263 ~~~~~~
264
265 ::
266
267         DELETE /{api version}/{account}/{container} HTTP/1.1
268         Host: {fqdn}
269         X-Auth-Token: {auth-token}    
270
271
272 HTTP Response
273 ~~~~~~~~~~~~~
274
275 ``204``
276
277 :Description: The container was removed.
278 :Status Code: ``NoContent``
279