Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
feat(aws-sdk.js): support cognito calls (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranrib authored Apr 6, 2021
1 parent 100227a commit c6baf12
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/events/aws_sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,37 @@ const CloudWatchEventsEventCreator = {
},
};


const CognitoIDPEventsEventCreator = {
/**
* Updates an event with the appropriate fields from an AWS Cognito IDP Events request
* @param {object} request The AWS.Request object
* @param {proto.event_pb.Event} event The event to update the data on
*/
requestHandler(request, event) {
const parameters = request.params || {};
const resource = event.getResource();
if (parameters.UserPoolId) {
resource.setName(parameters.UserPoolId);
}
resource.setType('cognito-idp');
eventInterface.addToMetadata(event, {}, {
'aws.cognito.request': parameters,
});
},

/**
* Updates an event with the appropriate fields from an AWS Cognito IDP Events response
* @param {object} response The AWS.Response object
* @param {proto.event_pb.Event} event The event to update the data on
*/
responseHandler(response, event) {
eventInterface.addToMetadata(event, {}, {
'aws.cognito.response': response.data,
});
},
};

const CloudWatchLogsEventCreator = {
/**
* Updates an event with the appropriate fields from an AWS CloudWatch Logs request
Expand Down Expand Up @@ -888,6 +919,7 @@ const specificEventCreators = {
stepfunctions: stepFunctionsEventCreator,
batch: batchEventCreator,
cloudwatchevents: CloudWatchEventsEventCreator,
cognitoidentityserviceprovider: CognitoIDPEventsEventCreator,
eventbridge: CloudWatchEventsEventCreator,
cloudwatchlogs: CloudWatchLogsEventCreator,
ssm: SSMEventCreator,
Expand All @@ -905,6 +937,7 @@ function AWSSDKWrapper(wrappedFunction) {
const { serviceIdentifier } = (
request.service.constructor.prototype
);

if (!(serviceIdentifier in specificEventCreators)) {
// resource is not supported yet
return wrappedFunction.apply(this, [callback]);
Expand Down

0 comments on commit c6baf12

Please sign in to comment.