Skip to content

Commit

Permalink
feat: update yaml files
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzawaleed01 committed Dec 13, 2023
1 parent ecd79e7 commit 820c740
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 36 deletions.
114 changes: 78 additions & 36 deletions api-compact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,41 @@ apigateway_responses: &apigateway_responses
500:
statusCode: "500"

apigateway_responses_with_mapping_template_for_uuid: &apigateway_responses_with_mapping_template_for_uuid
default:
statusCode: "400"
200:
statusCode: "200"
responseTemplates:
# Response body mapping template, this template is used for updating
# "next" and "previous" urls (both host and url path) while preserving
# the protocol (http | https) and querystring parameters.
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
}
401:
statusCode: "401"
403:
statusCode: "403"
404:
statusCode: "404"
429:
statusCode: "429"
500:
statusCode: "500"

responses: &responses
200:
description: "OK"
Expand All @@ -41,6 +76,10 @@ responses: &responses
500:
description: "Internal Server Error"

produces: &produces
- "application/json"
- "application/csv"

subscription_plan_uuid: &subscription_plan_uuid
name: "subscription_plan_uuid"
in: "path"
Expand All @@ -53,6 +92,15 @@ auth_header: &auth_header
required: true
type: "string"

x-amazon-apigateway-integration-assign-licenses: &apigateway_integration_assign_licenses
responses: *apigateway_responses_with_mapping_template_for_uuid
httpMethod: "POST"
type: "http"
requestParameters:
integration.request.header.Authorization: "method.request.header.Authorization"
integration.request.path.subscription_plan_uuid: "method.request.path.subscription_plan_uuid"


endpoints:
v1:

Expand All @@ -63,46 +111,40 @@ endpoints:
operationId: "assign_licenses"
consumes:
- "application/json"
produces:
- "application/json"
produces: *produces
parameters:
- *auth_header
- *subscription_plan_uuid
- name: "body"
in: "body"
description: "List of emails to assign licenses."
required: true
schema:
type: "array"
items:
type: "object"
properties:
user_emails:
description: "List of emails to assign licenses."
type: "array"
required: true
user_sfids:
description: "List of salesforce user ids to assign licenses."
type: "array"
required: true
greeting:
description: "Email template closing e.g Hello."
type: "string"
required: true
closing:
description: "Email template closing e.g Goodbye."
type: "string"
required: true
notify_users:
description: "Send license assignment email or not."
type: "boolean"
required: true
in: "body"
description: "List of emails to assign licenses."
required: true
schema:
type: "array"
items:
type: "object"
properties:
user_emails:
description: "List of emails to assign licenses."
type: "array"
required: true
user_sfids:
description: "List of salesforce user ids to assign licenses."
type: "array"
required: true
greeting:
description: "Email template closing e.g Hello."
type: "string"
required: true
closing:
description: "Email template closing e.g Goodbye."
type: "string"
required: true
notify_users:
description: "Send license assignment email or not."
type: "boolean"
required: true
responses: *responses
x-amazon-apigateway-integration:
responses: *apigateway_responses
httpMethod: "POST"
type: "http"
requestParameters:
integration.request.header.Authorization: "method.request.header.Authorization"
integration.request.path.subscription_plan_uuid: "method.request.path.subscription_plan_uuid"
<<: *apigateway_integration_assign_licenses
uri: "https://${stageVariables.license_manager_host}/v1/subscriptions/{subscription_plan_uuid}/licenses/assign/"
80 changes: 80 additions & 0 deletions api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@ apigateway_responses:
statusCode: "500"
default:
statusCode: "400"
apigateway_responses_with_mapping_template_for_uuid:
"200":
statusCode: "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
}
"401":
statusCode: "401"
"403":
statusCode: "403"
"404":
statusCode: "404"
"429":
statusCode: "429"
"500":
statusCode: "500"
default:
statusCode: "400"
responses:
"200":
description: OK
Expand All @@ -29,6 +57,9 @@ responses:
description: Too Many Requests
"500":
description: Internal Server Error
produces:
- application/json
- application/csv
subscription_plan_uuid:
name: subscription_plan_uuid
in: path
Expand All @@ -39,6 +70,40 @@ auth_header:
in: header
required: true
type: string
x-amazon-apigateway-integration-assign-licenses:
responses:
"200":
statusCode: "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
}
"401":
statusCode: "401"
"403":
statusCode: "403"
"404":
statusCode: "404"
"429":
statusCode: "429"
"500":
statusCode: "500"
default:
statusCode: "400"
httpMethod: POST
type: http
requestParameters:
integration.request.header.Authorization: method.request.header.Authorization
integration.request.path.subscription_plan_uuid: method.request.path.subscription_plan_uuid
endpoints:
v1:
assignLicenses:
Expand All @@ -49,6 +114,7 @@ endpoints:
- application/json
produces:
- application/json
- application/csv
parameters:
- name: Authorization
in: header
Expand Down Expand Up @@ -106,6 +172,20 @@ endpoints:
responses:
"200":
statusCode: "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
}
"401":
statusCode: "401"
"403":
Expand Down

0 comments on commit 820c740

Please sign in to comment.