AWS-Lambda-Quick
view release on metacpan or search on metacpan
lib/AWS/Lambda/Quick/Upload.pm view on Meta::CPAN
}
$self->debug('putting new method');
$self->aws_do(
'apigateway',
'put-method',
{
@identifiers,
'authorization-type' => 'NONE',
},
);
$self->debug('new method put');
return ();
}
sub _create_method_response {
my $self = shift;
my $resource_id = shift;
my $identifiers = {
'rest-api-id' => $self->rest_api_id,
'resource-id' => $resource_id,
'http-method' => 'ANY',
'status-code' => 200,
};
$self->debug('checking for existing method response');
# get the current method response
my $result = $self->aws->apigateway(
'get-method-response', $identifiers,
);
if ($result) {
$self->debug('found existing method response');
return ();
}
$self->debug('putting new method response');
$self->aws_do(
'apigateway',
'put-method-response',
$identifiers,
);
$self->debug('new method response put');
return ();
}
sub _create_integration {
my $self = shift;
my $function_arn = shift;
my $resource_id = shift;
my $identifiers = {
'rest-api-id' => $self->rest_api_id,
'resource-id' => $resource_id,
'http-method' => 'ANY',
};
# according the the documentation at https://docs.aws.amazon.com/cli/latest/reference/apigateway/put-integration.html
# the uri has the form arn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}
# "lambda:path/2015-03-31/functions" is the {subdomain.service|service}:path|action for lambda functions
my $uri
= "arn:aws:apigateway:@{[ $self->region ]}:lambda:path/2015-03-31/functions/$function_arn/invocations";
$self->debug('checking for existing integration');
# get the current method response
my $result = $self->aws->apigateway(
'get-integration', $identifiers,
);
if ($result) {
$self->debug('found existing integration');
return ();
}
$self->debug('putting new integration');
$self->aws_do(
'apigateway',
'put-integration',
{
%{$identifiers},
type => 'AWS_PROXY',
'integration-http-method' => 'POST',
'credential' => $self->_role_arn,
uri => $uri,
}
);
$self->debug('new integration put');
return ();
}
sub _create_integration_response {
my $self = shift;
my $resource_id = shift;
my $identifiers = {
'rest-api-id' => $self->rest_api_id,
'resource-id' => $resource_id,
'http-method' => 'ANY',
'status-code' => 200,
};
$self->debug('checking for existing integration response');
# get the current method response
my $result = $self->aws->apigateway(
'get-integration-response', $identifiers,
);
if ($result) {
$self->debug('found existing integration response');
return ();
}
$self->debug('putting new integration');
$self->aws_do(
'apigateway',
'put-integration-response',
{
( run in 1.250 second using v1.01-cache-2.11-cpan-39bf76dae61 )