Skip to content

Commit

Permalink
feat(url_metadata): add urls_metadata field (#118)
Browse files Browse the repository at this point in the history
* feat(url_metadata): add urls_metadata field

* fix(iter): py3 compat
  • Loading branch information
philloooo authored Apr 26, 2018
1 parent dbf63b8 commit 60dd22b
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 121 deletions.
15 changes: 11 additions & 4 deletions indexd/index/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def post_index_record():
'''
Create a new record.
'''
try: jsonschema.validate(flask.request.json, POST_RECORD_SCHEMA)
try:
jsonschema.validate(flask.request.json, POST_RECORD_SCHEMA)
except jsonschema.ValidationError as err:
raise UserError(err)

Expand All @@ -197,6 +198,7 @@ def post_index_record():
hashes = flask.request.json['hashes']
file_name = flask.request.json.get('file_name')
metadata = flask.request.json.get('metadata')
urls_metadata = flask.request.json.get('urls_metadata')
version = flask.request.json.get('version')
baseid = flask.request.json.get('baseid')

Expand All @@ -206,6 +208,7 @@ def post_index_record():
size=size,
file_name=file_name,
metadata=metadata,
urls_metadata=urls_metadata,
version=version,
urls=urls,
acl=acl,
Expand Down Expand Up @@ -239,6 +242,7 @@ def put_index_record(record):
urls = flask.request.json.get('urls')
acl = flask.request.json.get('acl')
metadata = flask.request.json.get('metadata')
urls_metadata = flask.request.json.get('urls_metadata')

did, baseid, rev = blueprint.index_driver.update(
record,
Expand All @@ -248,6 +252,7 @@ def put_index_record(record):
urls=urls,
acl=acl,
metadata=metadata,
urls_metadata=urls_metadata,
)

ret = {
Expand Down Expand Up @@ -291,9 +296,10 @@ def add_index_record_version(record):
urls = flask.request.json['urls']
acl = flask.request.json.get('acl', [])
hashes = flask.request.json['hashes']
file_name = flask.request.json.get('file_name', None)
metadata = flask.request.json.get('metadata', None)
version = flask.request.json.get('version', None)
file_name = flask.request.json.get('file_name')
metadata = flask.request.json.get('metadata')
urls_metadata = flask.request.json.get('urls_metadata')
version = flask.request.json.get('version')

did, baseid, rev = blueprint.index_driver.add_version(
record,
Expand All @@ -304,6 +310,7 @@ def add_index_record_version(record):
acl=acl,
file_name=file_name,
metadata=metadata,
urls_metadata=urls_metadata,
version=version,
hashes=hashes,
)
Expand Down
10 changes: 7 additions & 3 deletions indexd/index/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def hashes_to_urls(self, size, hashes, start=0, limit=100):
raise NotImplementedError('TODO')

@abc.abstractmethod
def add(self, form, did=None, size=None, urls=None, hashes=None, file_name=None, metadata=None, version=None):
def add(
self, form, did=None, size=None, urls=None,
hashes=None, file_name=None, metadata=None,
urls_metadata=None, version=None):
'''
Creates record for given data.
'''
Expand All @@ -53,7 +56,7 @@ def get(self, did):
@abc.abstractmethod
def update(self,
did, rev, urls=None, file_name=None,
version=None, metadata=None):
urls_metadata=None, version=None, metadata=None):
'''
Updates record with new values.
'''
Expand All @@ -69,7 +72,8 @@ def delete(self, did, rev):
@abc.abstractmethod
def add_version(
self, did, form, size=None,
file_name=None, metadata=None, urls=None, hashes=None, version=None):
file_name=None, metadata=None, urls=None,
urls_metadata=None, hashes=None, version=None):
'''
Add a record version given did
'''
Expand Down
Loading

0 comments on commit 60dd22b

Please sign in to comment.