Skip to content

Commit

Permalink
Fixes (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwdunham committed Jun 13, 2018
1 parent 9105797 commit 2cd181a
Show file tree
Hide file tree
Showing 26 changed files with 1,318 additions and 282 deletions.
3 changes: 3 additions & 0 deletions storage_service/.pytest_cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"locations/tests/test_api_v3.py": true
}
10 changes: 10 additions & 0 deletions storage_service/.pytest_cache/v/cache/nodeids
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
"locations/tests/test_api_v3.py::TestV3FileAPI::test_auth",
"locations/tests/test_api_v3.py::TestV3FileAPI::test_files_search",
"locations/tests/test_api_v3.py::TestV3FileAPI::test_get_create_update_data",
"locations/tests/test_api_v3.py::TestV3FileAPI::test_get_many_files",
"locations/tests/test_api_v3.py::TestV3FileAPI::test_mutate_location",
"locations/tests/test_api_v3.py::TestV3FileAPI::test_mutate_space",
"locations/tests/test_api_v3.py::TestV3FileAPI::test_new_search",
"locations/tests/test_api_v3.py::TestV3FileAPI::test_read_only_resources"
]
2 changes: 1 addition & 1 deletion storage_service/locations/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
v2_api.register(v2.AsyncResource())

urlpatterns = [
url(r'v3/', include(v3_api.urls)),
url(r'', include(v1_api.urls)),
url(r'v1/sword/$', views.service_document, name='sword_service_document'),
url(r'', include(v2_api.urls)),
url(r'v2/sword/$', views.service_document, name='sword_service_document'),
url(r'v3/', include(v3_api.urls)),
]
11 changes: 7 additions & 4 deletions storage_service/locations/api/v3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
| Purpose | HTTP Method | Path | Method |
+-----------------+-------------+----------------------------+------------+
| Create new | POST | /<cllctn_name>/ | create |
| Create data | GET | /<cllctn_name>/new/ | new |
| Get create data | GET | /<cllctn_name>/new/ | new |
| Read all | GET | /<cllctn_name>/ | index |
| Read specific | GET | /<cllctn_name>/<id>/ | show |
| Update specific | PUT | /<cllctn_name>/<id>/ | update |
| Update data | GET | /<cllctn_name>/<id>/edit/ | edit |
| Get update data | GET | /<cllctn_name>/<id>/edit/ | edit |
| Delete specific | DELETE | /<cllctn_name>/<id>/ | delete |
| Search | SEARCH | /<cllctn_name>/ | search |
| Search | POST | /<cllctn_name>/search/ | search |
| Search data | GET | /<cllctn_name>/new_search/ | new_search |
| Get search data | GET | /<cllctn_name>/new_search/ | new_search |
+-----------------+-------------+----------------------------+------------+
.. note:: To remove the search-related routes for a given resource, create a
Expand All @@ -45,6 +45,7 @@

from locations.api.v3.remple import API
from locations.api.v3.resources import (
Files,
Locations,
Packages,
Spaces,
Expand All @@ -56,9 +57,11 @@

resources = {
'location': {'resource_cls': Locations},
'package': {'resource_cls': Packages}, # Readonly because of super-class of ``Packages``
'space': {'resource_cls': Spaces},
'pipeline': {'resource_cls': Pipelines},
# The following resources are read-only because of their super-classes
'file': {'resource_cls': Files},
'package': {'resource_cls': Packages},
}

api = API(api_version=API_VERSION, service_name=SERVICE_NAME)
Expand Down
4 changes: 2 additions & 2 deletions storage_service/locations/api/v3/remple/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
get_member_targeting_regex,
)
from . import utils
from .schemata import ValidModelObject
from .schemata import ResourceURI

__all__ = ('API', 'UUID_PATT', 'ID_PATT', 'utils', 'ReadonlyResources',
'QueryBuilder', 'Resources', 'ValidModelObject',
'QueryBuilder', 'Resources', 'ResourceURI',
'get_collection_targeting_regex', 'get_member_targeting_regex',)
4 changes: 4 additions & 0 deletions storage_service/locations/api/v3/remple/clientbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ def get_param_docstring_line(arg, arg_cfg):
if arg_type:
_, arg_type = openapitype2pythontype.get(arg_type, (None, arg_type))
arg_format = arg_cfg.get('format', arg_cfg.get('schema', {}).get('format'))
if (not arg_format) and arg_type == 'list':
arg_format = arg_cfg.get('items', {}).get('format')
if arg_format:
arg_format = 'each element is a {}'.format(arg_format)
if arg_format:
arg_line.append(' ({}; {}):'.format(arg_type, arg_format))
else:
Expand Down
68 changes: 45 additions & 23 deletions storage_service/locations/api/v3/remple/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
from django.db.models.fields import (
AutoField,
BigIntegerField,
IntegerField,
BooleanField,
CharField,
TextField,
UUIDField,
DateTimeField,
)
from jsonfield.fields import JSONField
from formencode.validators import (
Int,
IPAddress,
OneOf,
Bool,
UnicodeString,
URL,
)


JSONDecodeErrorResponse = {
'error': 'JSON decode error: the parameters provided were not valid'
' JSON.'
Expand All @@ -10,27 +31,28 @@
READONLY_RSLT = {'error': 'This resource is read-only.'}

OK_STATUS = 200
CREATED_STATUS = 201
BAD_REQUEST_STATUS = 400
FORBIDDEN_STATUS = 403
NOT_FOUND_STATUS = 404
METHOD_NOT_ALLOWED_STATUS = 405


django_field_class2openapi_type = {
'AutoField': 'integer',
'BigIntegerField': 'integer',
'IntegerField': 'integer',
'BooleanField': 'boolean',
'CharField': 'string',
'TextField': 'string',
'UUIDField': 'string',
'DateTimeField': 'string',
'JSONField': 'object',
django_field2openapi_type = {
AutoField: 'integer',
BigIntegerField: 'integer',
IntegerField: 'integer',
BooleanField: 'boolean',
CharField: 'string',
TextField: 'string',
UUIDField: 'string',
DateTimeField: 'string',
JSONField: 'object',
}

django_field_class2openapi_format = {
'UUIDField': 'uuid',
'DateTimeField': 'date-time',
django_field2openapi_format = {
UUIDField: 'uuid',
DateTimeField: 'date-time',
}

python_type2openapi_type = {
Expand All @@ -39,16 +61,16 @@
float: 'integer',
}

formencode_field_class2openapi_type = {
'UnicodeString': 'string',
'OneOf': 'string', # note: not universally accurate
'IPAddress': 'string',
'URL': 'string',
'Int': 'integer',
'Bool': 'boolean',
formencode_field2openapi_type = {
UnicodeString: 'string',
OneOf: 'string', # note: not universally accurate
IPAddress: 'string',
URL: 'string',
Int: 'integer',
Bool: 'boolean',
}

formencode_field_class2openapi_format = {
'IPAddress': 'ipv4',
'URL': 'uri',
formencode_field2openapi_format = {
IPAddress: 'ipv4',
URL: 'uri',
}
Loading

0 comments on commit 2cd181a

Please sign in to comment.