diff --git a/terraform/api-specification-templates/hydrocron_aws_api.yml b/terraform/api-specification-templates/hydrocron_aws_api.yml index af8a4a86..8aadc881 100644 --- a/terraform/api-specification-templates/hydrocron_aws_api.yml +++ b/terraform/api-specification-templates/hydrocron_aws_api.yml @@ -109,17 +109,59 @@ paths: items: type: string x-openapi-router-controller: hydrocron_api.controllers.timeseries -x-amazon-apigateway-policy: - Version: '2012-10-17' - Statement: - - Effect: Allow - Principal: '*' - Action: 'execute-api:Invoke' - Resource: '*' - - Effect: Deny - Principal: '*' - Action: 'execute-api:Invoke' - Resource: '*' - Condition: - StringNotEquals: - 'aws:SourceVpc': ${vpc_id} \ No newline at end of file + + x-amazon-apigateway-integration: + uri: ${hydrocron_lambda_timeseries} + responses: + default: + statusCode: "200" + responseTemplates: + application/json: | + #set($inputRoot = $input.path('$')) + #if($inputRoot.toString().contains('206 PARTIAL CONTENT')) + #set($context.responseOverride.status = 206) + #end + $input.json('$') + ^400.*: + statusCode: "400" + responseTemplates: + application/json: |- + { + "error" : "$input.path('$.errorMessage')" + } + ^404.*: + statusCode: "404" + responseTemplates: + application/json: |- + { + "error" : "$input.path('$.errorMessage')" + } + ^413.*: + statusCode: "413" + responseTemplates: + application/json: |- + { + "error" : "$input.path('$.errorMessage')" + } + ^[^1-5].*: + statusCode: "500" + responseTemplates: + application/json: |- + { + "error" : "$input.path('$.errorMessage')" + } + requestTemplates: + application/json: |- + { + "body": { + "exact":"$input.params('exact')", + "region": "$input.params('region')", + "page_number": "$input.params('page_number')" , + "page_size": "$input.params('page_size')" , + "polygon_format": "$input.params('polygon_format')" + } + } + passthroughBehavior: when_no_templates + httpMethod: POST + contentHandling: CONVERT_TO_TEXT + type: aws \ No newline at end of file