Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ OGC API - Processes - Part 1: Core 1.0
>>> hello_world['title']
'Hello World'

>>> result = p.execute('hello-world', inputs={'name': 'World', 'message': 'Testing from OWSLib'})
>>> result
{'outputs': [{'id': 'echo', 'value': 'Hello World! Testing from OWSLib'}]}


OGC API - Maps - Part 1: Core 1.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 2 additions & 0 deletions owslib/feature/wfs110.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def get_namespaces():

namespaces = get_namespaces()

LOGGER = logging.getLogger(__name__)


class WebFeatureService_1_1_0(WebFeatureService_):
"""Abstraction for OGC Web Feature Service (WFS).
Expand Down
41 changes: 39 additions & 2 deletions owslib/ogcapi/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,50 @@ def processes(self) -> list:

def process(self, process_id: str) -> dict:
"""
implements /processs/{processId}
implements /processses/{processId}

@type process_id: string
@param process_id: id of process

@returns: `dict` of process desceription
@returns: `dict` of process description
"""

path = f'processes/{process_id}'
return self._request(path=path)

def execute(self, process_id: str, inputs: dict, outputs: dict = {},
response: str = 'document', async_: bool = False) -> dict:
"""
implements /processes/{processId}/execution

@type process_id: string
@param process_id: id of process
@type data: string
@param data: request payload
@type inputs: inputs
@param inputs: input parameters
@type outputs: outputs
@param outputs: output parameters
@type async_: bool
@param outputs: whether to execute request in asychronous mode

@returns: `dict` of response or URL reference to job
"""

data = {}

if inputs:
data['inputs'] = inputs
if outputs:
data['outputs'] = outputs

data['response'] = response

if async_:
self.headers['Prefer'] = 'respond-async'
else:
self.headers['Prefer'] = 'respond-sync'

path = f'processes/{process_id}/execution'

return self._request(method='POST', path=path, data=data)
15 changes: 15 additions & 0 deletions tests/test_ogcapi_processes_pygeoapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,18 @@ def test_ogcapi_processes_pygeoapi():
hello_world = p.process('hello-world')
assert hello_world['id'] == 'hello-world'
assert hello_world['title'] == 'Hello World'

inputs = {
'name': 'World',
'message': 'Testing from OWSLib'
}

execution = p.execute('hello-world', inputs=inputs)

assert execution['outputs'][0]['id'] == 'echo'
assert execution['outputs'][0]['value'] == 'Hello World! Testing from OWSLib' # noqa

execution = p.execute('hello-world', inputs=inputs, response='raw')

assert execution['id'] == 'echo'
assert execution['value'] == 'Hello World! Testing from OWSLib'