Skip to content

Commit

Permalink
support json/xml according to accept header + add job status links (#58
Browse files Browse the repository at this point in the history
…) + extra job routes (#86) + compliance with ogc api
  • Loading branch information
fmigneault committed Sep 21, 2020
1 parent a24ea74 commit 55ae095
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ boto3
# windows fixes until
# https://github.com/celery/billiard/issues/260
# https://github.com/celery/billiard/issues/313
# celery 5 to be released in near future
# celery >=4.4.3 breaks on 'future.utils' import
billiard; sys_platform != "win32"
billiard>3.2,<3.4; sys_platform == "win32"
# celery 5 to be released in near future
# celery >=4.4.3 breaks on 'future.utils' import
celery[mongodb]==4.4.2; sys_platform != "win32"
celery[mongodb]<4; sys_platform == "win32"
cffi
Expand Down
5 changes: 5 additions & 0 deletions weaver/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
LANGUAGE_EN_US,
])

# Languages
LANGUAGE_EN_CA = "en-CA"
LANGUAGE_FR_CA = "fr-CA"
LANGUAGE_EN_US = "en-US"

# Content-Types
# MIME-type nomenclature:
# <type> "/" [x- | <tree> "."] <subtype> ["+" suffix] *[";" parameter=value]
Expand Down
3 changes: 1 addition & 2 deletions weaver/tweens.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

def ows_response_tween(request, handler):
"""Tween that wraps any API request with appropriate dispatch of error conversion to handle formatting."""
exc_log_lvl = logging.WARNING
try:
result = handler(request)
if hasattr(handler, OWS_TWEEN_HANDLED):
Expand All @@ -33,13 +34,11 @@ def ows_response_tween(request, handler):
raised_error = err
return_error = err
exc_info_err = False
exc_log_lvl = logging.WARNING
except NotImplementedError as err:
LOGGER.debug("not implemented error -> ows exception response")
raised_error = err
return_error = OWSNotImplemented(str(err))
exc_info_err = sys.exc_info()
exc_log_lvl = logging.WARNING
except Exception as err:
LOGGER.debug("unhandled %s exception -> ows exception response", type(err).__name__)
raised_error = err
Expand Down
2 changes: 0 additions & 2 deletions weaver/wps_restapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def api_frontpage_body(settings):
weaver_api = asbool(settings.get("weaver.wps_restapi"))
weaver_api_url = get_wps_restapi_base_url(settings) if weaver_api else None
weaver_api_def = weaver_api_url + sd.api_swagger_ui_service.path if weaver_api else None

weaver_wps = asbool(settings.get("weaver.wps"))
weaver_wps_url = get_wps_url(settings) if weaver_wps else None
weaver_conform_url = weaver_url + sd.api_conformance_service.path
Expand Down Expand Up @@ -192,7 +191,6 @@ def api_swagger_json(request): # noqa: F811
weaver_server_url = get_weaver_url(request)
LOGGER.debug("Request app URL: [%s]", request.url)
LOGGER.debug("Weaver config URL: [%s]", weaver_server_url)
# http_scheme=request.scheme, http_host=request.host
return get_swagger_json(base_url=weaver_server_url, use_docstring_summary=True)


Expand Down
32 changes: 25 additions & 7 deletions weaver/wps_restapi/swagger_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,30 @@ class JobOutputsEndpoint(JobPath):
header = Headers()


class ProcessInputsEndpoint(ProcessPath, JobPath):
header = AcceptHeader()


class ProviderInputsEndpoint(ProviderPath, ProcessPath, JobPath):
header = AcceptHeader()


class JobInputsEndpoint(JobPath):
header = AcceptHeader()


class ProcessOutputsEndpoint(ProcessPath, JobPath):
header = AcceptHeader()


class ProviderOutputsEndpoint(ProviderPath, ProcessPath, JobPath):
header = AcceptHeader()


class JobOutputsEndpoint(JobPath):
header = AcceptHeader()


class ProcessResultsEndpoint(ProcessPath, JobPath):
header = Headers()

Expand Down Expand Up @@ -931,13 +955,7 @@ class AlternateQuotationList(ExtendedSequenceSchema):
step = AlternateQuotation(description="Quote of a workflow step process.")


# same as base Format, but for process/job responses instead of process submission
# (ie: 'Format' is for allowed/supported formats, this is the result format)
class DataEncodingAttributes(Format):
pass


class Reference(DataEncodingAttributes):
class Reference(Format):
href = URL(description="Endpoint of the reference.")
body = ExtendedSchemaNode(String(), missing=drop)
bodyReference = URL(missing=drop)
Expand Down

0 comments on commit 55ae095

Please sign in to comment.