Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

61 get our openapi spec working for the data analysis pipeline api #182

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a01be45
baseline dap api spec for testing
thecaffiend Nov 7, 2024
f641a9d
changed handlers to use jinja template notation
thecaffiend Nov 7, 2024
f552d91
added jinja2 to requirements
thecaffiend Nov 7, 2024
18689b1
rearranging/renaming dap api handlers and spec
thecaffiend Nov 7, 2024
5948e9b
start of config for api endpoints
thecaffiend Nov 7, 2024
c983ddf
changed uri ids to be more pythonic
thecaffiend Nov 7, 2024
7b62cfa
started config for api handlers
thecaffiend Nov 8, 2024
5f2102d
finishing merge of main to here
thecaffiend Nov 8, 2024
cfd3b31
Merge remote-tracking branch 'gh/main' into 61-get-our-openapi-spec-w…
thecaffiend Nov 8, 2024
d631cbd
gave openapi spec file a jinja 2 extension for clarity
thecaffiend Nov 11, 2024
2384453
removed x- anchors as they don't seem to be supported by the AWS open…
thecaffiend Nov 12, 2024
65a9ed6
added a short name to the api handler config, cleaned up comments
thecaffiend Nov 12, 2024
88a2aac
removed api config that matched default values. removed obe comments
thecaffiend Nov 12, 2024
93cc558
changed the dap specific policy function to be more usable for other …
thecaffiend Nov 12, 2024
159a893
initial api implementation (aws apigw rest apis only)
thecaffiend Nov 12, 2024
956df4e
changed to work with new CapeRestApi class (removed all previous api …
thecaffiend Nov 12, 2024
7a613b2
added env_vars config for rest apis, fixed a wrong doc
thecaffiend Nov 12, 2024
5200958
changed plural dict keys to singular as it represents a type.
thecaffiend Nov 12, 2024
087fcfc
changed to allow configuration of env vars for apis by tracking a lim…
thecaffiend Nov 12, 2024
e05763f
added todo re: env var exposure
thecaffiend Nov 13, 2024
641b19a
changed POST params to match case expected by API
thecaffiend Nov 13, 2024
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
51 changes: 50 additions & 1 deletion Pulumi.cape-cod-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,58 @@ config:
# each item should have:
# - desc: A description for the api. Will be used in
# description tags.
# TODO: ISSUE #61 - openapi spec file would go here
# - spec_file: An OpenApi 3.0.1 yaml specification. This
# should include *no* AWS id's, names,
# account info, etc
# - env_vars: a list of swimlane-exposed env vars that the
# API requires access to. the env vars will be
# passed into the environment of the lambda
# and basic permissions will be given to the
# lambda to access the resources referenced by
# the env var.
# - handlers: a list of objects containing
# - id:
# the id in the spec file that will be replaced
# with the arn of the created lambda function
# - name:
# a short name that will be used in resource
# creation (naming of the resources)
# - code:
# the path in the repo for the lambda that
# implements the endpoint
# - funct_args:
# arguments to pass *as is* to the lambda
# function constructor. the keys used need to map
# to actual argument names of the pulumi lambda
# function constructor. additionally, most args
# will be ignored (e.g. environment, role) as
# they are dynamically injected in code or not
# used currently. If not provided, the handler
# will default to "index.index_handler" and the
# runtime will default to "python3.10". The
# following arguments are supported:
# - architectures (list, defaults to ["x86_64"])
# - description
# - handler (defaults to "index.index_handler")
# - memory_size (MB, defaults to 128)
# - runtime (defaults to "python3.10")
# - timeout (seconds, defaults to 3)
dap:
desc: "Data Analysis Pipeline API"
spec_file: "assets/api/data-analysis-pipeline/dap-openapi-301.yaml.j2"
env_vars:
- "DAP_QUEUE_NAME"
- "DAP_REG_DDB_TABLE"
handlers:
- id: "list_daps_handler"
name: "lsdaps"
code: "assets/api/data-analysis-pipeline/handlers/list_daps.py"
- id: "list_dap_executors_handler"
name: "lsexec"
code: "assets/api/data-analysis-pipeline/handlers/list_dap_executors.py"
- id: "submit_dap_run_handler"
name: "sbmtdap"
code: "assets/api/data-analysis-pipeline/handlers/submit_dap_run.py"
# static apps are deployed to s3 as html/js/css bundles and are
# exposed through an application load balancer. these may hit API
# endpoints (assuming the required permissions/roles are available),
Expand Down
69 changes: 0 additions & 69 deletions assets/api/analysis-pipeline/dap-api-spec.yaml

This file was deleted.

212 changes: 212 additions & 0 deletions assets/api/data-analysis-pipeline/dap-openapi-301.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
openapi: "3.0.1"
info:
title: "CAPE Data Analysis Pipeline API"
description:
"CAPE Data Analysis Pipeline API (***TODO: add more comment***)"
version: "2024-11-04T20:50:49Z"
servers:
# we do not provide x-amazon-apigateway-endpoint-configuration here (setting up the vpc endpoint)
# as we expect that to be set in the pulumi code setting up the RestApi. Don't want AWS ids in the
# repo
- url: "https://api.cape-dev.org/{basePath}"
variables:
basePath:
# This value needs to map to the stage name exposed via the ALB
default: "dap-dev"
paths:
/analysispipelines:
get:
responses:
"200":
# TODO: need the response headers (i.e. cors)
description: "Success"
content:
application/json:
schema:
type: array
description:
"An array of available pipelines to run."
items:
type: object
properties:
pipeline_name:
type: string
description: The pipeline name
pipeline_type:
type: string
description:
The type of pipeline execution
environment (e.g. 'nextflow')
version:
type: string
description: The pipeline version
"500":
description:
"Server Error - Unable to read the pipeline registry."
x-amazon-apigateway-integration:
# this is the integration http method, not the endpoint http method. all lambda backed
# integrations are post
httpMethod: "POST"
uri: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/{{ list_daps_handler }}/invocations"
passthroughBehavior: "when_no_match"
timeoutInMillis: 29000
type: "aws_proxy"
options:
responses:
"200":
$ref: "#/components/responses/200OptionsCors"
x-amazon-apigateway-integration:
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Methods: "'OPTIONS,POST'"
method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: "{'statusCode':200}"
passthroughBehavior: "when_no_match"
timeoutInMillis: 29000
type: "mock"
/pipelineexecutors:
get:
responses:
"200":
# TODO: need the response headers (i.e. cors)
description: "Success"
content:
application/json:
schema:
type: array
description:
"An array of available pipeline executors."
items:
type: object
properties:
instance_id:
type: string
description:
The ID of the executor EC2
instance
instance_name:
type: string
description:
The name of the executor EC2
instance
pipeline_type:
type: string
description:
The type of pipeline supported
by the executor EC2 instance.
"500":
description:
"Server error while getting list of available executors."
x-amazon-apigateway-integration:
httpMethod: "POST"
uri: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/{{ list_dap_executors_handler }}/invocations"
passthroughBehavior: "when_no_match"
timeoutInMillis: 29000
type: "aws_proxy"
options:
responses:
"200":
$ref: "#/components/responses/200OptionsCors"
x-amazon-apigateway-integration:
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Methods: "'OPTIONS,POST'"
method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: "{'statusCode':200}"
passthroughBehavior: "when_no_match"
timeoutInMillis: 29000
type: "mock"
/analysispipeline:
post:
requestBody:
description: Submit a data analysis pipeline for execution.
required: true
content:
application/json:
schema:
type: object
properties:
pipelineName:
type: string
description: The name of the pipeline to run
pipelineVersion:
type: string
description:
The version of the pipeline to run
outputPath:
type: string
description: >
The S3 location to put pipeline output.
Assumes permissions are set correctly.
# TODO: ISSUE #TBD all below fields are specific to bactopia right now. also, the
# descriptions are bunk if we keep using these params
r1Path:
type: string
description: The R1 path.
r2Path:
type: string
description: The R2 path.
ec2Id:
type: string
description:
The id of the EC2 instance serving as
executor.
sample:
type: string
description: >
The name of the sample being processed.
Affects output directory and file names
responses:
"200":
# TODO: need the response headers (i.e. cors)
description: "Success submitting pipeline for execution."
x-amazon-apigateway-integration:
httpMethod: "POST"
uri: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/{{ submit_dap_run_handler }}/invocations"
passthroughBehavior: "when_no_match"
timeoutInMillis: 29000
type: "aws_proxy"
options:
responses:
"200":
$ref: "#/components/responses/200OptionsCors"
x-amazon-apigateway-integration:
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Methods: "'OPTIONS,POST'"
method.response.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
method.response.header.Access-Control-Allow-Origin: "'*'"
requestTemplates:
application/json: "{'statusCode':200}"
passthroughBehavior: "when_no_match"
timeoutInMillis: 29000
type: "mock"
# resusable components that follow OpenApi 3.0.1 spec
components:
responses:
200OptionsCors:
description: "200 response"
headers:
Access-Control-Allow-Origin:
schema:
type: "string"
Access-Control-Allow-Methods:
schema:
type: "string"
Access-Control-Allow-Headers:
schema:
type: "string"
content: {}
# we do not provide x-amazon-apigateway-policy here (setting up the policy for using the API)
# as we expect that to be set in the pulumi code setting up the RestApi. Don't want AWS ids and
# perms in the repo
Loading