Project

General

Profile

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

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

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