Skip to content

Commit

Permalink
feat: create get all resume urls enpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Sneha Sundar authored and Sneha Sundar committed Mar 1, 2024
1 parent f8b1fed commit c69af73
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
18 changes: 17 additions & 1 deletion code/mapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from student.upload import get_upload_url
from recruiter.get import get_resume_url
from recruiter.get import get_resume_url, get_all_resume_urls
from student.user import get_user, update_user, register_user
import json
import traceback
Expand Down Expand Up @@ -67,6 +67,21 @@ def getResumeUrl(context, queryParams, body):
traceback.print_exc()
return rval

def getAllResumeUrls(context, queryParams, body):
try:
url: str | None = get_resume_url(queryParams['uid'])
rval = {
'statusCode': 200,
'body': json.dumps({
'url':url
})
}
except:
rval = serverError("Could not create S3 download URL.")
traceback.print_exc()
return rval


def getUser(context, queryParams, body):
rval = {}
try:
Expand Down Expand Up @@ -98,6 +113,7 @@ def updateUser(context, queryParams, body):
"/api/v1/healthz": healthzHandler,
"/api/v1/student/getUploadURL": getUploadUrl,
"/api/v1/recruiter/getResumeUrl": getResumeUrl,
"/api/v1/recruiter/getAllResumeUrls": getAllResumeUrls,
"/api/v1/recruiter/getResumeListings": notImplemented,
"/api/v1/student": getUser,
"/api/v1/student/id": getUserId
Expand Down
18 changes: 17 additions & 1 deletion code/recruiter/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,20 @@ def get_resume_url(uid: str) -> str | None:
"Key": filename
},
ExpiresIn=3600
)
)

# write new endpoint (get_all_resumes)
def get_all_resume_urls():
#use boto3 to download all of the resumes
bucket = f'infra-resume-book-pdfs-{os.environ.get("RunEnvironment", "prod")}'
response = s3.list_objects_v2(bucket)
mylist = response['Contents']
resume_list = []
resume_url_list = []
for item in mylist:
if item['Key'].endswith('@illinois.edu.pdf'):
resume_list.append(item['Key'])
#then return them zipped
for resume in resume_list:
resume_url_list.append(get_resume_url(resume))
return resume_url_list
26 changes: 26 additions & 0 deletions docs/swagger-resume-book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,29 @@ paths:
type: aws_proxy
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${LambdaFunctionName}/invocations

/api/v1/recruiter/getAllResumeUrls:
get:
summary: Get all resume URLs in the bucket
operationId: recruiterGetAllResumeUrls

responses:
200:
description: OK

security:
- CombinedAuthorizer: []

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:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${LambdaFunctionName}/invocations

0 comments on commit c69af73

Please sign in to comment.