Skip to content

Commit

Permalink
add new endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
devksingh4 committed Jul 18, 2023
1 parent 08b9aeb commit bb65c02
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
10 changes: 10 additions & 0 deletions cloudformation/lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ Resources:
Principal: apigateway.amazonaws.com
SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ResumeBookApiGateway}/*/GET/api/v1/student/getUploadURL

ResumeBookLambdaApiGatewayRecruiterGetURL:
Type: AWS::Lambda::Permission
DependsOn:
- ResumeBookApiGateway
Properties:
Action: lambda:InvokeFunction
FunctionName: !GetAtt ResumeBookApiLambdaFunction.Arn
Principal: apigateway.amazonaws.com
SourceArn: !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ResumeBookApiGateway}/*/GET/api/v1/recruiter/getResumeListings

ResumeBookApiGatewayDomainName:
Type: 'AWS::ApiGateway::DomainName'
Properties:
Expand Down
2 changes: 1 addition & 1 deletion code/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
def lambda_handler(event, context):
method = event['httpMethod']
path = event['path']
print(f"Processing request: method {method}, path {path}.")
print(f"INFO: Processing request: method {method}, path {path}.")
return mapper.execute(method, path)
9 changes: 5 additions & 4 deletions code/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ def healthzHandler():
"statusCode": 200,
"body": "UP"
}
def getUploadURLHandler():
def notImplemented():
return {
"statusCode": 200,
"statusCode": 404,
"body": "Method not implemented."
}
find_handler = {
"GET": {
"/api/v1/healthz": healthzHandler,
"/api/v1/student/getUploadURL": getUploadURLHandler
"/api/v1/student/getUploadURL": notImplemented,
"/api/v1/recruiter/getResumeListings": notImplemented,
}
}

Expand All @@ -20,7 +21,7 @@ def execute(method: str, path: str) -> None:
func: function = find_handler[method][path]
return func()
except KeyError:
print(f"No handler found for method {method} and path {path}.")
print(f"ERROR: No handler found for method {method} and path {path}.")
return {
"statusCode": 404,
"body": f"No handler found for method {method} path {path}."
Expand Down
20 changes: 19 additions & 1 deletion docs/swagger-resume-book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,27 @@ paths:

/api/v1/student/getUploadURL:
get:
summary: Ping the API
summary: Get URL for student to upload resume.
operationId: studentGetUploadURL

x-amazon-apigateway-auth:
type: NONE

x-amazon-apigateway-integration:
responses:
default:
statusCode: 200
passthroughBehavior: when_no_match
httpMethod: POST
contentHandling: CONVERT_TO_TEXT
type: aws_proxy
uri: arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:298118738376:function:infra-resume-book-api-lambda/invocations

/api/v1/recruiter/getResumeListings:
get:
summary: Get resume listings based on criteria
operationId: recruiterGetResumeListings

x-amazon-apigateway-auth:
type: NONE

Expand Down

0 comments on commit bb65c02

Please sign in to comment.