Project

General

Profile

RESTful API for DR Geo-Replication » History » Version 2

Jessica Mack, 06/01/2015 06:27 PM

1 1 Jessica Mack
h1. RESTful API for DR  Geo-Replication
2
3
h3. System User Special Requests
4
5
In general, a system user (a user that has the system flag set on) may operate on behalf of other users. Certain requests may either have special request params (always prefixed by 'rgwx-') or may have special header fields (prefixed by 'Rgwx-').
6
7
h4. Params:
8
9
* rgwx-uid
10
11
The effective user id for this request
12
 
13
h4. Create bucket for a non-master region
14
15
Tells the master region that a user tries to create a bucket. Can only be executed by a system user. The original bucket creation request is being forwarded under a different user context, with some extra params.
16
 
17
Syntax:
18
 
19
PUT /bucket
20
 
21
Extra Params:
22
 
23
1. rgwx-region: source region for request
24
2. rgwx-uid: effective user id for bucket creation
25
 
26
Response:
27
Response data for a successful bucket creation returns the JSON encoded bucket object metadata version and the bucket info.
28
 
29
h4. Extended object GET
30
31
Read an object, send extra metadata about object. This request extends generic object read.
32
 
33
Syntax
34
GET /bucket/object
35
 
36
Extra Params:
37
1. rgwx-prepend-metadata: whether object metadata will be prepended to object data as part of the response.
38
 
39
Extra Response Headers:
40
 
41
1.  Rgwx-Embedded-Metadata-Len: Length of prepended metadata (if requested)
42
 
43
h4. Extended object PUT
44
45
Writes an object, return extra object metadata. Extends regular object write.
46
 
47
Syntax
48
PUT /bucket/object
49
 
50
Extra Response Headers:
51
1. Rgwx-Mtime: Object modification time.
52
*Sync object from zone within region (intra-region copy)*
53
54
Syntax:
55
PUT /bucket/objcect
56
 
57
Extra Params:
58
1. rgwx-source-zone: the source zone for where 
59
2. rgwx-client-id: the id of the agent that initiated the request
60
3. rgwx-op-od: a unique op id, created by the agent
61
 
62
It is up for the agent to provide a meaningful client id and a unique (for that agent) op id. These will be used for handling opstate information.
63
 
64
%{color:yellow}Metadata%
65
 
66
h4. List metadata
67
68
Display list of metadata sections, keys.
69
70
Syntax:
71
72
GET /admin/metadata[/section]
73
74
Response:
75
76
JSON encoded list of sections or keys.
77
78
Examples:
79
80
1. GET /admin/metadata
81
82
[
83
    "user"]
84
85
86
2. GET /admin/metadata/user
87
88
[
89
    "yehsad",
90
    "greg"]
91
 
92
h4. Get metadata info
93
94
Syntax:
95
96
GET /admin/metadata/<section>?key=<key>
97
98
Response:
99
100
JSON encoded metadata info
101
102
Examples:
103
104
GET /admin/metadata/user?key=yehsad
105
106
{ "key": "user:yehsad",
107
  "ver": { "ver": 3,
108
      "tag": "8L0en1nFM1Y+NaQrBAzgPliZ"},
109
  "data": { "user_id": "yehsad",
110
      "display_name": "yehuda",
111
      "email": "",
112
      "suspended": 0,
113
      "max_buckets": 1000,
114
      "auid": 0,
115
      "subusers": [
116
            { "id": "yehsad:yehsad",
117
              "permissions": "<none>"}],
118
      "keys": [
119
            { "user": "yehsad",
120
              "access_key": "foo",
121
              "secret_key": "bar"}],
122
      "swift_keys": [
123
            { "user": "yehsad:yehsad",
124
              "secret_key": "zxczxc"}],
125
      "caps": []}}
126
127
 
128
h4. Set metadata info
129
130
Syntax:
131
132
PUT /admin/metadata/<section>?key=<key>
133
134
<JSON encoded metadata>
135
136
Response:
137
138
Examples:
139
140
PUT /admin/metadata/user?key=yehsad
141
142
{ "key": "user:yehsad",
143
  "ver": { "ver": 4,
144
      "tag": "8L0en1nFM1Y+NaQrBAzgPliZ"},
145
  "data": { "user_id": "yehsad",
146
      "display_name": "yehuda",
147
      "email": "",
148
      "suspended": 0,
149
      "max_buckets": 10,
150
      "auid": 0,
151
      "subusers": [
152
            { "id": "yehsad:yehsad",
153
              "permissions": "<none>"}],
154
      "keys": [
155
            { "user": "yehsad",
156
              "access_key": "foo",
157
              "secret_key": "bar"}],
158
      "swift_keys": [
159
            { "user": "yehsad:yehsad",
160
              "secret_key": "zxczxc"}],
161
      "caps": []}}
162
 
163
164
h4. Remove metadata
165
 
166
Remove a metadata key
167
168
Syntax:
169
170
DELETE /admin/metadata/<section>?key=<key>
171
172
Response:
173
174
Example:
175
176
DELETE /admin/metadata/user?key=yehsad
177
178
179
h3. Data, Metadata Logs
180
181 2 Jessica Mack
h4. get log info
182 1 Jessica Mack
 
183
Returns info about the log. Currently that only includes the number of log shards.
184
 
185
Syntax:
186
 
187
GET /admin/log?type=<type>
188
 
189
params:
190
1. type: metadata, data
191
 
192
result:
193
 
194
return a JSON representation of the data log information
195
 
196
{
197
  num_objects = <num>
198
}
199
 
200 2 Jessica Mack
h4. ?get shard info
201 1 Jessica Mack
 
202
Retuns information about the current log shard state. Shard id is in the range of 0 to num_objects - 1 (num_objects can be retrieved by the get log info request).
203
 
204
Syntax:
205
 
206
GET /admin/log?info&type=<type>&id=<shard-id>
207
 
208
params:
209
1. type: metadata, data
210
2. id: shard id
211
 
212
result:
213
 
214
return a JSON representation of the data log information
215
 
216
{
217
  num_objects = <num>
218
}
219
 
220
h4. Lock log shard
221
 
222
POST /admin/log?lock
223
 
224
 
225
params:
226
 
227
1. type: metadata, data
228
2. id: shard id (0..num_objects)
229
3. length: time in seconds for lock to be valid
230
4. zone-id: locker zone id
231
5. locker-id: client id (e.g., agent id).
232
 
233
Returns 404 if there are no entries of the specified type in the shard.
234
235
h4. Unlock log shard
236
 
237
POST /admin/log?unlock
238
 
239
params:
240
 
241
1. type: metadata, data
242
2. id: shard id (0..num_objects)
243
3. zone-id: locker zone id
244
4. locker-id: unique user identifier that corresponds to a previous lock call
245
 
246
h4. list log
247
 
248
GET /admin/log?id=<shard id>
249
 
250
params:
251
 
252
1. type: metadata, data
253
2. id=<shard id>
254
3. start-time=<start time> (optional)
255
4. end-time=<end time> (optional)
256
5. marker=<start marker> (optional)
257
 
258
Need to have either one pair of start-time and end-time specified, or start-marker and end-marker specified. Markers supersede timestamps, and they correspond to the 'id' field in the log entries.
259
 
260
h4. trim data log
261
 
262
DELETE /admin/log?id=<shard id>
263
 
264
params:
265
 
266
1. type: metadata, data
267
2. id=<shard id>
268
3. start-time=<start time>
269
4. end-time=<end time>
270
5. start-marker=<start marker>
271
6. end-marker=<end marker> 
272
 
273
Need to have either one pair of start-time and end-time specified, or start-marker and end-marker specified. Markers supersede timestamps, and they correspond to the 'id' field in the log entries.
274
 
275
h3. Bucket Index Log
276
 
277
h4. List bucket index log
278
279
GET /admin/log?type=bucket-index
280
281
params:
282
283
1. bucket=<bucket name>
284
2. bucket-instance=<bucket instance id>
285
3. start-marker=<start-marker>
286
4. end-marker=<end-marker>
287
Notes:
288
 - One of either bucket or bucket-instance must be specified.
289
 - The marker param can be used to iterate through entries. It corresponds to the "id" field in a returned entry.
290
 
291
h4. Get bucket index log info
292
 
293
Get information about bucket index log state. Can be used to retrieve current last log entry's marker position.
294
295
GET /admin/log?info&type=bucket-index
296
297
params:
298
299
1. bucket=<bucket name>
300
2. bucket-instance=<bucket instance id>Notes:
301
 - One of either bucket or bucket-instance must be specified.
302
 
303
h4. trim bucket index log
304
305
306
DELETE /admin/log?type=bucket-index
307
308
params:
309
310
1. bucket=<bucket name>
311
2. bucket-instance=<bucket instance>
312
3. marker=<marker> (optional)
313
4. max-entries=<max entries> (optional, default is 1000)
314
 
315
Notes:
316
 - One of either bucket or bucket-instance must be specified.
317
 
318
h3. Replica Log
319
320
h4. Data/Metadata Replica Log
321
322
h4. Set a Worker Bound
323
324
POST /admin/replica_log?work_bound
325
 
326
params:
327
1) type: metadata, data
328
2) id: shard id
329
3) marker: as used for log listing
330
4) time: the lower bound master zone time (corresponds to the marker)
331
5) daemon_id: a user-provided string, which can be anything.
332
 
333
Currenly there can only be one worker bound stored for a data or metadata shard, and there are a few constraints on setting it:
334
daemon_id must be the same as the existing entry, if there is one
335
time must not be before the existing timestamp, if there is one
336
marker must not be empty
337
 
338
body:
339
the body of the request includes a JSON-encoded list of buckets which are "in progress" from before the lower bound, plus a lower bound on the time associated with each of them:
340
[ { "bucket": <name>, "time": <time> }, { "bucket": <name2>, "time": <time2> } ]
341
 
342
h4. Get the Worker bounds
343
344
GET /admin/replica_log?bounds
345
params:
346
1) type: metadata, data, bucket-index (see below)
347
2) id: shard id
348
 
349
This returns a JSON object containing a list of the lower bounds and bucket collections for each daemon_id, plus the aggregate's lowest marker and oldest time bound:
350
{
351
  "markers":
352
  [ { "entity": <id1>, "position_marker": <marker1>, "postion_time": <time1>, "items_in_progress": [ { "name": <name>, "timestamp":2 <time2> }, { "name": <name2>, "timestamp": <time3> } ] },
353
    { "entity": <id2>, "positon_marker": <marker2>, "position_time": <time4>, "items_in_progress": [ ] }
354
  ],
355
  "marker": <marker1>,
356
  "oldest_time": <time3>
357
}
358
 
359
h4. Remove a daemon's bound
360
361
DELETE /admin/replica_log?work_bound
362
params:
363
1) type: metadata, data, bucket-index (see below)
364
2) id: shard id
365
3) daemon_id: a user-provided string, which can be anything
366
 
367
h3. Bucket Index Replica Log
368
369
h4. Set a Worker Bound
370
371
POST /admin/replica_log?work_bound
372
params:
373
1) type=bucket-index
374
2) bucket-instance: bucket instance id
375
3) marker: as used for bucket log listing
376
4) time: the lower bound master zone time for this bucket (corresponds to the marker)
377
5) daemon_id: a user-provided string, which can be anything
378
 
379
Currenly there can only be one worker bound stored for a bucket-instance, and there are a few constraints on setting it:
380
daemon_id must be the same as the existing entry, if there is one
381
time must not be before the existing timestamp, if there is one
382
marker must not be empty
383
 
384
The request body includes a JSON list of objects in progress, which includes the time each of them became out-of-date:
385
[ { name:"objfoo", time:<time1>}, { name:"objbar", time:<time2>}, { name:"objbaz", time:<time3>} ]
386
 
387
h4. Get a Worker Bound
388
389
GET /admin/replica_log?bounds
390
params:
391
1) type=bucket-index
392
2) bucket-instance: bucket instance id
393
 
394
It returns an object containing the post data and the params from the last call for each daemon, plus an aggregate lowest bound marker and oldest_time
395
{
396
  "markers": [ { "entity": <id1>, "position_marker": <marker1>, "position_time": <time1>, "items_in_progress": [ { name:"objfoo", time:<time1>}, { name:"objbar", time:<time2>}, { name:"objbaz", time:<time3>} ],
397
    { "entity": <id2>, "position_marker": <marker2>, "position_time": <time2>, "items_in_progress": [] } ],
398
  "marker": <marker1>,
399
  "oldest_time": <time3>
400
}
401
 
402
h4. Delete a Worker's Bound
403
404
DELETE /admin/replica_log?work_bound
405
params:
406
1) type: bucket-index
407
2) bucket-instance: bucket instance id
408
3) daemon_id: a user-provided string, which can be anything
409
 
410
h3. OpState
411
 
412
h4. List entries
413
414
GET /admin/opstate
415
416
params:
417
418
1. client-id=<client-id> (optional)
419
2. op-id=<op-id> (optional)
420
3. object=<object> (optional)
421
4. max-entries=<max entries> (optional, default is 1000)
422
 
423
h4. Set entry
424
 
425
POST /admin/opstate
426
params:
427
1. client-id=<client-id> (required)
428
2. op-id=<op-id> (required)
429
3. object=<object> (requiredl)
430
4. state=<state> (required)
431
5. renew (optional)
432
if renew is specified then operation can only succeed if the state specified matches the existing state.
433
 
434
h4. Remove entry
435
 
436
DELETE /admin/opstate
437
params:
438
1. client-id=<client-id> (required)
439
2. op-id=<op-id> (required)
440
3. object=<object> (requiredl)
441
 
442
 
443
h3. Reading Configuration
444
 
445
At the moment, region configuration information is read-only.
446
 
447
h4. Get region map
448
 
449
Syntax:
450
GET /admin/config