diff --git a/docs/source/data-publishing/ogcapi-processes.rst b/docs/source/data-publishing/ogcapi-processes.rst index a063d40..b777bc9 100644 --- a/docs/source/data-publishing/ogcapi-processes.rst +++ b/docs/source/data-publishing/ogcapi-processes.rst @@ -65,11 +65,11 @@ Processing examples - show all jobs for the ``hello-world`` process - http://localhost:5000/processes/hello-world/jobs - execute a job for the ``hello-world`` process - - ``curl -X POST "http://localhost:5000/processes/hello-world/jobs" -H "Content-Type: application/json" -d "{\"inputs\":[{\"id\":\"name\",\"type\":\"text/plain\",\"value\":\"hi there2\"}]}"`` + - ``curl -X POST "http://localhost:5000/processes/hello-world/execution" -H "Content-Type: application/json" -d "{\"inputs\":{\"name\": \"hi there2\"}}"`` - execute a job for the ``hello-world`` process with a raw response - - ``curl -X POST "http://localhost:5000/processes/hello-world/jobs?response=raw" -H "Content-Type: application/json" -d "{\"inputs\":[{\"id\":\"name\",\"type\":\"text/plain\",\"value\":\"hi there2\"}]}"`` + - ``curl -X POST "http://localhost:5000/processes/hello-world/execution?response=raw" -H "Content-Type: application/json" -d "{\"inputs\":{\"name\": \"hi there2\"}}"`` - execute a job for the ``hello-world`` process in asynchronous mode - - ``curl -X POST "http://localhost:5000/processes/hello-world/jobs" -H "Content-Type: application/json" -d "{\"mode\": \"async\", \"inputs\":[{\"id\":\"name\",\"type\":\"text/plain\",\"value\":\"hi there2\"}]}"`` + - ``curl -X POST "http://localhost:5000/processes/hello-world/execution" -H "Content-Type: application/json" -d "{\"mode\": \"async\", \"inputs\":{\"name\": \"hi there2\"}}"`` .. todo:: add more examples once OAProc implementation is complete diff --git a/pygeoapi/api.py b/pygeoapi/api.py index ca8c1a7..8ebcdc7 100644 --- a/pygeoapi/api.py +++ b/pygeoapi/api.py @@ -2642,15 +2642,13 @@ class API: try: data_dict = {} - for input_ in data.get('inputs', []): - id_ = input_['id'] - value = input_['value'] - if id_ not in data_dict: - data_dict[id_] = value - elif id_ in data_dict and isinstance(data_dict[id_], list): - data_dict[id_].append(value) + for key, value in data.get('inputs', {}).items(): + if key not in data_dict: + data_dict[key] = value + elif key in data_dict and isinstance(data_dict[key], list): + data_dict[key].append(value) else: - data_dict[id_] = [data_dict[id_], value] + data_dict[key] = [data_dict[key], value] except KeyError: # Return 4XX client error for missing 'id' or 'value' in an input msg = 'invalid request data' @@ -2669,6 +2667,10 @@ class API: if is_async: LOGGER.debug('Asynchronous request mode detected') + if is_async and not self.manager.is_async: + LOGGER.debug('async manager not configured/enabled') + is_async = False + try: LOGGER.debug('Executing process') mime_type, outputs, status = self.manager.execute_process( diff --git a/pygeoapi/process/hello_world.py b/pygeoapi/process/hello_world.py index 6cb409b..590cecb 100644 --- a/pygeoapi/process/hello_world.py +++ b/pygeoapi/process/hello_world.py @@ -58,61 +58,47 @@ PROCESS_METADATA = { 'href': 'https://example.org/process', 'hreflang': 'en-US' }], - 'inputs': [{ - 'id': 'name', - 'title': 'Name', - 'abstract': 'The name of the person or entity that you wish to be' - 'echoed back as an output', - 'input': { - 'literalDataDomain': { - 'dataType': 'string', - 'valueDefinition': { - 'anyValue': True - } - } + 'inputs': { + 'name': { + 'title': 'Name', + 'description': 'The name of the person or entity that you wish to' + 'be echoed back as an output', + 'schema': { + 'type': 'string' + }, + 'minOccurs': 1, + 'maxOccurs': 1, + 'metadata': None, # TODO how to use? + 'keywords': ['full name', 'personal'] }, - 'minOccurs': 1, - 'maxOccurs': 1, - 'metadata': None, # TODO how to use? - 'keywords': ['full name', 'personal'] - }, { - 'id': 'message', - 'title': 'Message', - 'abstract': 'An optional message to echo as well', - 'input': { - 'literalDataDomain': { - 'dataType': 'string', - 'valueDefinition': { - 'anyValue': True - } - } - }, - 'minOccurs': 0, - 'maxOccurs': 1, - 'metadata': None, - 'keywords': ['message'] - }], - 'outputs': [{ - 'id': 'echo', - 'title': 'Hello, world', - 'description': 'A "hello world" echo with the name and (optional)' - 'message submitted for processing', - 'output': { - 'formats': [{ - 'mimeType': 'application/json' - }] + 'message': { + 'title': 'Message', + 'description': 'An optional message to echo as well', + 'schema': { + 'type': 'string' + }, + 'minOccurs': 0, + 'maxOccurs': 1, + 'metadata': None, + 'keywords': ['message'] } - }], + }, + 'outputs': { + 'echo': { + 'title': 'Hello, world', + 'description': 'A "hello world" echo with the name and (optional)' + ' message submitted for processing', + 'schema': { + 'type': 'object', + 'contentMediaType': 'application/json' + } + } + }, 'example': { - 'inputs': [{ - 'id': 'name', - 'value': 'World', - 'type': 'text/plain' - }, { - 'id': 'message', - 'value': 'An optional message.', - 'type': 'text/plain' - }] + 'inputs': { + 'name': 'World', + 'messsage': 'An optional message.', + } } } diff --git a/pygeoapi/templates/processes/process.html b/pygeoapi/templates/processes/process.html index f8f30a9..2dc87a8 100644 --- a/pygeoapi/templates/processes/process.html +++ b/pygeoapi/templates/processes/process.html @@ -27,27 +27,19 @@
- {% for input_ in data['inputs'] %} + {% for key, value in data['inputs'].items() %}