Skip to content

Commit

Permalink
fixup! Fix: Swagger UI for indexer is a stub (#5051)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc committed May 6, 2023
1 parent d976eeb commit a81d1c0
Showing 1 changed file with 37 additions and 16 deletions.
53 changes: 37 additions & 16 deletions lambdas/indexer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
json_content,
)
from azul.openapi.spec import (
AuxSpec,
CommonEndpointSpecs,
)

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -110,17 +110,17 @@ def static_resource(file):
return app.swagger_resource(file)


aux_spec = AuxSpec(app_name='indexer')
common_specs = CommonEndpointSpecs(app_name='indexer')


@app.route('/openapi', methods=['GET'], cors=True, **aux_spec.openapi())
@app.route('/openapi', methods=['GET'], cors=True, **common_specs.openapi)
def openapi():
return Response(status_code=200,
headers={'content-type': 'application/json'},
body=app.spec())


@app.route('/version', methods=['GET'], cors=True, **aux_spec.version())
@app.route('/version', methods=['GET'], cors=True, **common_specs.version)
def version():
from azul.changelog import (
compact_changes,
Expand All @@ -131,27 +131,39 @@ def version():
}


@app.route('/health', methods=['GET'], cors=True, **aux_spec.full_health())
@app.route('/health', methods=['GET'], cors=True, **common_specs.full_health)
def health():
return app.health_controller.health()


@app.route('/health/basic', methods=['GET'], cors=True, **aux_spec.basic_health())
@app.route('/health/basic',
methods=['GET'],
cors=True,
**common_specs.basic_health)
def basic_health():
return app.health_controller.basic_health()


@app.route('/health/cached', methods=['GET'], cors=True, **aux_spec.cached_health())
@app.route('/health/cached',
methods=['GET'],
cors=True,
**common_specs.cached_health)
def cached_health():
return app.health_controller.cached_health()


@app.route('/health/fast', methods=['GET'], cors=True, **aux_spec.fast_health())
@app.route('/health/fast',
methods=['GET'],
cors=True,
**common_specs.fast_health)
def fast_health():
return app.health_controller.fast_health()


@app.route('/health/{keys}', methods=['GET'], cors=True, **aux_spec.custom_health())
@app.route('/health/{keys}',
methods=['GET'],
cors=True,
**common_specs.custom_health)
def health_by_key(keys: Optional[str] = None):
return app.health_controller.custom_health(keys)

Expand All @@ -164,17 +176,26 @@ def update_health_cache(_event: chalice.app.CloudWatchEvent):
@app.route('/{catalog}/{action}', methods=['POST'], method_spec={
'tags': ['Indexing'],
'summary': 'Notify the indexer to perform an action on a bundle',
'description': format_description('''
Queue a bundle for addition to or deletion from the index. If the
request body contains a valid bundle notification, the notification is
sent to an SQS queue that will deliver it to an indexer Lambda function.
The request must be authenticated using HMAC via the ``signature``
header. Each Azul deployment has its own unique HMAC key. The HMAC
components are the request method, request path, and the SHA256 digest
of the request body.
'''),
'requestBody': {
'description': 'Contents of the notification',
'required': True,
**json_content(schema.object(
match=schema.object(
bundle_uuid=str,
bundle_version=str
),
source=schema.object(
id=str,
spec=str
bundle_fqid=schema.object(
uuid=str,
version=str,
source=schema.object(
id=str,
spec=str
)
)
))
},
Expand Down

0 comments on commit a81d1c0

Please sign in to comment.