diff --git a/code/mapper.py b/code/mapper.py index a2a63e6..02d459b 100644 --- a/code/mapper.py +++ b/code/mapper.py @@ -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 @@ -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: @@ -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 diff --git a/code/recruiter/get.py b/code/recruiter/get.py index 3ff399b..9498225 100644 --- a/code/recruiter/get.py +++ b/code/recruiter/get.py @@ -20,4 +20,20 @@ def get_resume_url(uid: str) -> str | None: "Key": filename }, ExpiresIn=3600 - ) \ No newline at end of file + ) + +# 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 \ No newline at end of file diff --git a/docs/swagger-resume-book.yml b/docs/swagger-resume-book.yml index 4a30eab..39ca3a6 100644 --- a/docs/swagger-resume-book.yml +++ b/docs/swagger-resume-book.yml @@ -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