Skip to content

Commit

Permalink
chore(readme): update readme
Browse files Browse the repository at this point in the history
Update README to support of creating record with given did

chore(swagger): update swagger

support index creation with given did

fix(plueprint): remove redundant uuid check format
  • Loading branch information
giangbui committed Jan 26, 2018
1 parent 1d9df35 commit 6287263
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,55 @@ HTTP/1.1 200 OK

[Full schema for creating an index](indexd/index/schema.py)

### Create an index given did

POST /index/
Content-Type: application/json
```
{
"did": "3d313755-cbb4-4b08-899d-7bbac1f6e67d",
"form": "object",
"size": 123,
"file_name": "abc.txt",
"version": "ver_123",
"urls": ["s3://endpointurl/bucket/key"],
"hashes": {"md5": "8b9942cf415384b27cadf1f4d2d682e5"}
}
```

| Parameters | Values |
| -----:|:-----|
| did | Unique digital ID |
| form | Can be one of 'object', 'container', 'multipart' |
| size | File size in bytes (commonly computed via wc -c filename) |
| file_name | Optional file name |
| version | Optional version string |
| urls | URLs where the datafile is stored, can be multiple locations both internally and externally |
| hashes | Dictionary is a string:string datastore supporting md5, sha, sha256, sha512 hash types |

Curl example:
```
curl http://localhost/index/ -u test:test -H "Content-type: application/json" -X POST -d '{"form": "object","size": 123,"did": "3d313755-cbb4-4b08-899d-7bbac1f6e67d", urls": ["s3://endpointurl/bucket/key"],"hashes": {"md5": "8b9942cf415384b27cadf1f4d2d682e5"}}'
```

***Response***
HTTP/1.1 200 OK
```
{
"did": "3d313755-cbb4-4b08-899d-7bbac1f6e67d",
"baseid": "703d4g20-103f-8452-a672-878vb42ef8a5"
"rev": "c6fc83d0"
}
```

| Parameters | Values |
| ----:|:----|
| did | Unique digital ID |
| baseid | Internal UUID assigned by the index service. All versions of a record share the same baseid |
| rev | 8-digit hex revision ID assigned by the index service |

[Full schema for creating an index](indexd/index/schema.py)

### Update an index

PUT /index/UUID?rev=REVSTRING
Expand Down
7 changes: 1 addition & 6 deletions indexd/index/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
'sha512': re.compile(r'^[0-9a-f]{128}$').match,
}

DID_PATTERN = re.compile(r'^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$').match

def validate_hashes(**hashes):
'''
Expand Down Expand Up @@ -178,14 +177,10 @@ def post_index_record():
raise UserError(err)

did = flask.request.json.get('did')

if did is not None:
if DID_PATTERN(did) is None:
raise UserError('wrong did format')

form = flask.request.json['form']
size = flask.request.json['size']
urls = flask.request.json['urls']

hashes = flask.request.json['hashes']
file_name = flask.request.json.get('file_name')
metadata = flask.request.json.get('metadata')
Expand Down
4 changes: 4 additions & 0 deletions openapis/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ definitions:
- urls
- form
properties:
did:
type: string
pattern: >-
^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$
base_id:
type: string
pattern: >-
Expand Down

0 comments on commit 6287263

Please sign in to comment.