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
22 changes: 17 additions & 5 deletions pygeoapi/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,6 @@ def landing_page(api: API,
'type': FORMAT_TYPES[F_JSON],
'title': l10n.translate('Processes', request.locale),
'href': f"{api.base_url}/processes"
}, {
'rel': f'{OGC_RELTYPES_BASE}/job-list',
'type': FORMAT_TYPES[F_JSON],
'title': l10n.translate('Jobs', request.locale),
'href': f"{api.base_url}/jobs"
}, {
'rel': f'{OGC_RELTYPES_BASE}/tiling-schemes',
'type': FORMAT_TYPES[F_JSON],
Expand All @@ -730,6 +725,20 @@ def landing_page(api: API,

fcm['links'].append(pubsub_link)

if api.manager.is_async:
fcm['links'].append({
'rel': f'{OGC_RELTYPES_BASE}/job-list',
'type': FORMAT_TYPES[F_JSON],
'title': l10n.translate('Jobs', request.locale),
'href': f"{api.base_url}/jobs"
})
fcm['links'].append({
'rel': f'{OGC_RELTYPES_BASE}/job-list',
'type': FORMAT_TYPES[F_HTML],
'title': l10n.translate('Jobs', request.locale),
'href': f"{api.base_url}/jobs?f=html"
})

if api.asyncapi:
fcm['links'].append({
'rel': 'service-doc',
Expand Down Expand Up @@ -760,6 +769,9 @@ def landing_page(api: API,
'tile'):
fcm['tile'] = True

if api.manager.is_async:
fcm['jobs'] = True

if api.pubsub_client is not None and not api.pubsub_client.hidden:
fcm['pubsub'] = {
'name': api.pubsub_client.name,
Expand Down
155 changes: 79 additions & 76 deletions pygeoapi/api/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def describe_processes(api: API, request: APIRequest,

p2['links'] = p2.get('links', [])

jobs_url = f"{api.base_url}/jobs"
process_url = f"{api.base_url}/processes/{key}"

# TODO translation support
Expand All @@ -164,23 +163,22 @@ def describe_processes(api: API, request: APIRequest,
}
p2['links'].append(link)

link = {
'type': FORMAT_TYPES[F_HTML],
'rel': 'http://www.opengis.net/def/rel/ogc/1.0/job-list',
'href': f'{jobs_url}?f={F_HTML}',
'title': l10n.translate('Jobs list as HTML', request.locale), # noqa
'hreflang': api.default_locale
}
p2['links'].append(link)

link = {
'type': FORMAT_TYPES[F_JSON],
'rel': 'http://www.opengis.net/def/rel/ogc/1.0/job-list',
'href': f'{jobs_url}?f={F_JSON}',
'title': l10n.translate('Jobs list as JSON', request.locale), # noqa
'hreflang': api.default_locale
}
p2['links'].append(link)
if api.manager.is_async:
jobs_url = f"{api.base_url}/jobs"
p2['links'].append({
'type': FORMAT_TYPES[F_HTML],
'rel': 'http://www.opengis.net/def/rel/ogc/1.0/job-list',
'href': f'{jobs_url}?f={F_HTML}',
'title': l10n.translate('Jobs list as HTML', request.locale), # noqa
'hreflang': api.default_locale
})
p2['links'].append({
'type': FORMAT_TYPES[F_JSON],
'rel': 'http://www.opengis.net/def/rel/ogc/1.0/job-list',
'href': f'{jobs_url}?f={F_JSON}',
'title': l10n.translate('Jobs list as JSON', request.locale), # noqa
'hreflang': api.default_locale
})

link = {
'type': FORMAT_TYPES[F_JSON],
Expand Down Expand Up @@ -825,68 +823,73 @@ def get_oas_30(cfg: dict, locale: str
}
}

paths['/jobs'] = {
'get': {
'summary': 'Retrieve jobs list',
'description': 'Retrieve a list of jobs',
'tags': ['jobs'],
'operationId': 'getJobs',
'responses': {
'200': {'$ref': '#/components/responses/200'},
'404': {'$ref': f"{OPENAPI_YAML['oapip']}/responses/NotFound.yaml"}, # noqa
'default': {'$ref': '#/components/responses/default'}
tag_objects = [{'name': 'processes'}]

if process_manager.is_async:
paths['/jobs'] = {
'get': {
'summary': 'Retrieve jobs list',
'description': 'Retrieve a list of jobs',
'tags': ['jobs'],
'operationId': 'getJobs',
'responses': {
'200': {'$ref': '#/components/responses/200'},
'404': {'$ref': f"{OPENAPI_YAML['oapip']}/responses/NotFound.yaml"}, # noqa
'default': {'$ref': '#/components/responses/default'}
}
}
}
}

paths['/jobs/{jobId}'] = {
'get': {
'summary': 'Retrieve job details',
'description': 'Retrieve job details',
'tags': ['jobs'],
'parameters': [
name_in_path,
{'$ref': '#/components/parameters/f'}
],
'operationId': 'getJob',
'responses': {
'200': {'$ref': '#/components/responses/200'},
'404': {'$ref': f"{OPENAPI_YAML['oapip']}/responses/NotFound.yaml"}, # noqa
'default': {'$ref': '#/components/responses/default'}
}
},
'delete': {
'summary': 'Cancel / delete job',
'description': 'Cancel / delete job',
'tags': ['jobs'],
'parameters': [
name_in_path
],
'operationId': 'deleteJob',
'responses': {
'204': {'$ref': '#/components/responses/204'},
'404': {'$ref': f"{OPENAPI_YAML['oapip']}/responses/NotFound.yaml"}, # noqa
'default': {'$ref': '#/components/responses/default'}
}
},
}
paths['/jobs/{jobId}'] = {
'get': {
'summary': 'Retrieve job details',
'description': 'Retrieve job details',
'tags': ['jobs'],
'parameters': [
name_in_path,
{'$ref': '#/components/parameters/f'}
],
'operationId': 'getJob',
'responses': {
'200': {'$ref': '#/components/responses/200'},
'404': {'$ref': f"{OPENAPI_YAML['oapip']}/responses/NotFound.yaml"}, # noqa
'default': {'$ref': '#/components/responses/default'}
}
},
'delete': {
'summary': 'Cancel / delete job',
'description': 'Cancel / delete job',
'tags': ['jobs'],
'parameters': [
name_in_path
],
'operationId': 'deleteJob',
'responses': {
'204': {'$ref': '#/components/responses/204'},
'404': {'$ref': f"{OPENAPI_YAML['oapip']}/responses/NotFound.yaml"}, # noqa
'default': {'$ref': '#/components/responses/default'}
}
},
}

paths['/jobs/{jobId}/results'] = {
'get': {
'summary': 'Retrieve job results',
'description': 'Retrieve job results',
'tags': ['jobs'],
'parameters': [
name_in_path,
{'$ref': '#/components/parameters/f'}
],
'operationId': 'getJobResults',
'responses': {
'200': {'$ref': '#/components/responses/200'},
'404': {'$ref': f"{OPENAPI_YAML['oapip']}/responses/NotFound.yaml"}, # noqa
'default': {'$ref': '#/components/responses/default'}
paths['/jobs/{jobId}/results'] = {
'get': {
'summary': 'Retrieve job results',
'description': 'Retrieve job results',
'tags': ['jobs'],
'parameters': [
name_in_path,
{'$ref': '#/components/parameters/f'}
],
'operationId': 'getJobResults',
'responses': {
'200': {'$ref': '#/components/responses/200'},
'404': {'$ref': f"{OPENAPI_YAML['oapip']}/responses/NotFound.yaml"}, # noqa
'default': {'$ref': '#/components/responses/default'}
}
}
}
}

return [{'name': 'processes'}, {'name': 'jobs'}], {'paths': paths}
tag_objects.append({'name': 'jobs'})

return tag_objects, {'paths': paths}
2 changes: 2 additions & 0 deletions pygeoapi/templates/landing_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ <h2>{% trans %}Processes{% endtrans %}</h2>
<a href="{{ config['server']['url'] }}/processes?f=html">{% trans %}View the processes in this service{% endtrans %}</a>
</p>
</section>
{% if data['jobs'] %}
<section id="jobs">
<h2>{% trans %}Jobs{% endtrans %}</h2>
<p>
<a title="Browse jobs" href="{{config.server.url}}/jobs">{% trans %}Browse jobs{% endtrans %}</a>
</p>
</section>
{% endif %}
{% endif %}
{% if data['tile'] %}
<section id="tilematrixsets">
<h2>{% trans %}Tile Matrix Sets{% endtrans %}</h2>
Expand Down
2 changes: 2 additions & 0 deletions pygeoapi/templates/processes/process.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ <h2>{% trans %}Execution modes{% endtrans %}</h2>
{% if 'sync-execute' in data.jobControlOptions %}<li>{% trans %}Synchronous{% endtrans %}</li>{% endif %}
{% if 'async-execute' in data.jobControlOptions %}<li>{% trans %}Asynchronous{% endtrans %}</li>{% endif %}
</ul>
{% if data['jobs'] %}
<h2>{% trans %}Jobs{% endtrans %}</h2>
<a title="Browse jobs" href="{{config.server.url}}/jobs">{% trans %}Browse jobs{% endtrans %}</a>
{% endif %}
<h2>{% trans %}Links{% endtrans %}</h2>
<ul>
{% for link in data['links'] %}
Expand Down
3 changes: 2 additions & 1 deletion tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def test_root(config, api_):
for link in root['links'])
assert any(link['href'].endswith('f=html') and link['rel'] == 'alternate'
for link in root['links'])
assert len(root['links']) == 12
assert len(root['links']) == 13
assert 'title' in root
assert root['title'] == 'pygeoapi default instance'
assert 'description' in root
Expand Down Expand Up @@ -622,6 +622,7 @@ def test_describe_collections(config, api_):
collections = json.loads(response)

assert len(collections) == 2
print(json.dumps(collections['collections']))
assert len(collections['collections']) == 10
assert len(collections['links']) == 3

Expand Down
6 changes: 3 additions & 3 deletions tests/api/test_pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_landing_page(config, openapi, asyncapi):

content = json.loads(response)

assert len(content['links']) == 15
assert len(content['links']) == 16

for link in content['links']:
if link.get('rel') == 'hub':
Expand All @@ -76,7 +76,7 @@ def test_landing_page(config, openapi, asyncapi):

content = json.loads(response)

assert len(content['links']) == 12
assert len(content['links']) == 13

for link in content['links']:
if link.get('rel') == 'hub':
Expand All @@ -96,7 +96,7 @@ def test_landing_page(config, openapi, asyncapi):

content = json.loads(response)

assert len(content['links']) == 15
assert len(content['links']) == 16

for link in content['links']:
if link.get('rel') == 'hub':
Expand Down
Loading