Skip to content

Commit

Permalink
feat: api gateway spec for LPR V1 API
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammad-ammar committed Sep 20, 2021
1 parent cf175cf commit 70f26ed
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 64 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Unreleased
----------

=========================
[3.2.0] - 2021-09-17
---------------------
* Add api gateway spec for LPR V1 API

[3.1.0] - 2021-09-16
---------------------
* add `primary_program_type` field in EnterpriseLearnerEnrollment
Expand Down
16 changes: 16 additions & 0 deletions api-compact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#
# Available service endpoints -- note that alternate endpoints may be presented at the API Gateway tier:
# GET /v1/enterprise-customer/{uuid}/learner-summary/
# GET /v2/enterprise-customer/{uuid}/learner-summary/

apigateway_responses_with_mapping_template_for_uuid: &apigateway_responses_with_mapping_template_for_uuid
default:
Expand Down Expand Up @@ -116,3 +117,18 @@ endpoints:
x-amazon-apigateway-integration:
<<: *apigateway_integration_enterprise_customer_learner_summary
uri: "https://${stageVariables.analytics_api_host}/enterprise/api/v0/enterprise/{uuid}/enrollments/"
v2:
# GET /v3/enterprise-customer/{uuid}/learner-summary/
enterpriseCustomerLearnerSummary:
get:
produces: *produces
parameters:
- *auth_header
- *uuid_parameter
- *page_qs_parameter
- *page_size_qs_parameter
operationId: "get_enterprise_customer_learner_summary"
responses: *responses
x-amazon-apigateway-integration:
<<: *apigateway_integration_enterprise_customer_learner_summary
uri: "https://${stageVariables.analytics_api_host}/enterprise/api/v1/enterprise/{uuid}/enrollments/"
203 changes: 140 additions & 63 deletions api.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This file is a "de-compacted" version of api-compact.yaml. The consuming tools are unable to process YAML anchors.
# This file was generated using http://www.yamllint.com/.

---
apigateway_responses_with_mapping_template_for_uuid:
200:
responseTemplates:
---
apigateway_responses_with_mapping_template_for_uuid:
200:
responseTemplates:
application/json: |
#set($inputRoot = $input.path('$')) #set($host = $stageVariables.gateway_host) #set($uuid = $input.params('uuid'))
#set($URLMatchRegex = "(^https?://)[^/]*[^?]*(.*$)") #set($updatedURL = "$1$host$context.resourcePath$2") #set($resourceUuidMatch = "{uuid}")
Expand All @@ -15,77 +15,77 @@ apigateway_responses_with_mapping_template_for_uuid:
"results": $inputRoot.results
}
statusCode: "200"
401:
401:
statusCode: "401"
403:
403:
statusCode: "403"
404:
404:
statusCode: "404"
429:
429:
statusCode: "429"
500:
500:
statusCode: "500"
default:
default:
statusCode: "400"
auth_header:
auth_header:
in: header
name: Authorization
required: true
type: string
endpoints:
v1:
enterpriseCustomerLearnerSummary:
get:
endpoints:
v1:
enterpriseCustomerLearnerSummary:
get:
operationId: get_enterprise_customer_learner_summary
parameters:
-
parameters:
-
in: header
name: Authorization
required: true
type: string
-
-
in: path
name: uuid
required: true
type: string
-
-
in: query
name: page
required: false
type: number
-
-
in: query
name: page_size
required: false
type: number
produces:
produces:
- application/json
- application/csv
responses:
200:
responses:
200:
description: OK
400:
400:
description: "Bad Request"
401:
401:
description: Unauthorized
403:
403:
description: Forbidden
404:
404:
description: "Not Found"
429:
429:
description: "Too Many Requests"
500:
500:
description: "Internal Server Error"
x-amazon-apigateway-integration:
x-amazon-apigateway-integration:
httpMethod: GET
requestParameters:
requestParameters:
integration.request.header.Authorization: method.request.header.Authorization
integration.request.path.uuid: method.request.path.uuid
integration.request.querystring.page: method.request.querystring.page
integration.request.querystring.page_size: method.request.querystring.page_size
responses:
200:
responseTemplates:
responses:
200:
responseTemplates:
application/json: |
#set($inputRoot = $input.path('$')) #set($host = $stageVariables.gateway_host) #set($uuid = $input.params('uuid'))
#set($URLMatchRegex = "(^https?://)[^/]*[^?]*(.*$)") #set($updatedURL = "$1$host$context.resourcePath$2") #set($resourceUuidMatch = "{uuid}")
Expand All @@ -96,63 +96,140 @@ endpoints:
"results": $inputRoot.results
}
statusCode: "200"
401:
401:
statusCode: "401"
403:
403:
statusCode: "403"
404:
404:
statusCode: "404"
429:
429:
statusCode: "429"
500:
500:
statusCode: "500"
default:
default:
statusCode: "400"
type: http
uri: "https://${stageVariables.analytics_api_host}/enterprise/api/v0/enterprise/{uuid}/enrollments/"
page_qs_parameter:
v2:
enterpriseCustomerLearnerSummary:
get:
operationId: get_enterprise_customer_learner_summary
parameters:
-
in: header
name: Authorization
required: true
type: string
-
in: path
name: uuid
required: true
type: string
-
in: query
name: page
required: false
type: number
-
in: query
name: page_size
required: false
type: number
produces:
- application/json
- application/csv
responses:
200:
description: OK
400:
description: "Bad Request"
401:
description: Unauthorized
403:
description: Forbidden
404:
description: "Not Found"
429:
description: "Too Many Requests"
500:
description: "Internal Server Error"
x-amazon-apigateway-integration:
httpMethod: GET
requestParameters:
integration.request.header.Authorization: method.request.header.Authorization
integration.request.path.uuid: method.request.path.uuid
integration.request.querystring.page: method.request.querystring.page
integration.request.querystring.page_size: method.request.querystring.page_size
responses:
200:
responseTemplates:
application/json: |
#set($inputRoot = $input.path('$')) #set($host = $stageVariables.gateway_host) #set($uuid = $input.params('uuid'))
#set($URLMatchRegex = "(^https?://)[^/]*[^?]*(.*$)") #set($updatedURL = "$1$host$context.resourcePath$2") #set($resourceUuidMatch = "{uuid}")
{
"count": $inputRoot.count,
"next": "$inputRoot.next.replaceAll($URLMatchRegex, $updatedURL).replace($resourceUuidMatch, $uuid)",
"previous": "$inputRoot.previous.replaceAll($URLMatchRegex, $updatedURL).replace($resourceUuidMatch, $uuid)",
"results": $inputRoot.results
}
statusCode: "200"
401:
statusCode: "401"
403:
statusCode: "403"
404:
statusCode: "404"
429:
statusCode: "429"
500:
statusCode: "500"
default:
statusCode: "400"
type: http
uri: "https://${stageVariables.analytics_api_host}/enterprise/api/v1/enterprise/{uuid}/enrollments/"
page_qs_parameter:
in: query
name: page
required: false
type: number
page_size_qs_parameter:
page_size_qs_parameter:
in: query
name: page_size
required: false
type: number
produces:
produces:
- application/json
- application/csv
responses:
200:
responses:
200:
description: OK
400:
400:
description: "Bad Request"
401:
401:
description: Unauthorized
403:
403:
description: Forbidden
404:
404:
description: "Not Found"
429:
429:
description: "Too Many Requests"
500:
500:
description: "Internal Server Error"
uuid_parameter:
uuid_parameter:
in: path
name: uuid
required: true
type: string
x-amazon-apigateway-integration-enterprise-customer-learner-summary:
x-amazon-apigateway-integration-enterprise-customer-learner-summary:
httpMethod: GET
requestParameters:
requestParameters:
integration.request.header.Authorization: method.request.header.Authorization
integration.request.path.uuid: method.request.path.uuid
integration.request.querystring.page: method.request.querystring.page
integration.request.querystring.page_size: method.request.querystring.page_size
responses:
200:
responseTemplates:
responses:
200:
responseTemplates:
application/json: |
#set($inputRoot = $input.path('$')) #set($host = $stageVariables.gateway_host) #set($uuid = $input.params('uuid'))
#set($URLMatchRegex = "(^https?://)[^/]*[^?]*(.*$)") #set($updatedURL = "$1$host$context.resourcePath$2") #set($resourceUuidMatch = "{uuid}")
Expand All @@ -163,16 +240,16 @@ x-amazon-apigateway-integration-enterprise-customer-learner-summary:
"results": $inputRoot.results
}
statusCode: "200"
401:
401:
statusCode: "401"
403:
403:
statusCode: "403"
404:
404:
statusCode: "404"
429:
429:
statusCode: "429"
500:
500:
statusCode: "500"
default:
default:
statusCode: "400"
type: http
2 changes: 1 addition & 1 deletion enterprise_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Enterprise data api application. This Django app exposes API endpoints used by enterprises.
"""

__version__ = "3.1.0"
__version__ = "3.2.0"

default_app_config = "enterprise_data.apps.EnterpriseDataAppConfig" # pylint: disable=invalid-name

0 comments on commit 70f26ed

Please sign in to comment.