Packages
ex_aws
0.4.1
2.7.0
2.6.1
2.6.0
2.5.11
2.5.10
2.5.9
2.5.8
2.5.7
2.5.6
2.5.5
2.5.4
2.5.3
2.5.2
2.5.1
2.5.0
2.4.4
2.4.3
2.4.2
2.4.1
2.4.0
2.3.4
2.3.3
2.3.2
2.3.1
2.3.0
2.2.10
2.2.9
2.2.8
2.2.7
2.2.6
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.9
2.1.8
2.1.7
2.1.6
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.2
2.0.1
2.0.0
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0
1.0.0-rc.4
1.0.0-rc.3
1.0.0-rc.1
1.0.0-beta3
1.0.0-beta2
1.0.0-beta1
1.0.0-beta0
0.5.0
0.4.19
0.4.18
0.4.17
0.4.15
0.4.14
0.4.13
0.4.11
0.4.10
0.4.9
0.4.8
0.4.7
0.4.6
0.4.5
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.1
0.3.0
0.2.0
0.1.2
0.1.1
0.1.0
0.0.5
0.0.4
0.0.3
AWS client for Elixir. Currently supports Dynamo, DynamoStreams, EC2, Firehose, Kinesis, KMS, Lambda, RRDS, Route53, S3, SES, SNS, SQS, STS and others.
Current section
Files
Jump to
Current section
Files
lib/ex_aws/lambda/impl.ex
defmodule ExAws.Lambda.Impl do
use ExAws.Actions
import ExAws.Utils, only: [camelize_keys: 1, upcase: 1]
require Logger
@moduledoc false
# Implimentation of the AWS Kinesis API.
#
# See ExAws.Kinesis.Client for usage.
@namespace "Lambda"
@actions [
add_permission: :post,
create_event_source_mapping: :post,
create_function: :post,
delete_event_source_mapping: :delete,
delete_function: :delete,
get_event_source_mapping: :get,
get_function: :get,
get_function_configuration: :get,
get_policy: :get,
invoke: :post,
invoke_async: :post,
list_event_source_mappings: :get,
list_functions: :get,
remove_permission: :delete,
update_event_source_mapping: :put,
update_function_code: :put,
update_function_configuration: :put
]
def add_permission(client, function_name, principal, action, statement_id, opts \\ []) do
data = opts
|> normalize_opts
|> Map.merge(%{
"Action" => action,
"Principal" => principal,
"StatementId" => statement_id})
request(client, :add_permission, data, "/2015-03-31/functions/#{function_name}/versions/HEAD/policy")
end
def create_event_source_mapping(client, function_name, event_source_arn, starting_position, opts \\ []) do
data = opts
|> normalize_opts
|> Map.merge(%{
"FunctionName" => function_name,
"EventSourceArn" => event_source_arn,
"StartingPosition" => starting_position |> upcase})
request(client, :create_event_source_mapping, data, "/2015-03-31/event-source-mappings/")
end
def create_function(client, function_name, handler, zipfile, opts \\ []) do
data = opts
|> normalize_opts
|> Map.merge(%{
"FunctionName" => function_name,
"Handler" => handler,
"Code" => %{"ZipFile" => zipfile}})
request(client, :create_function, data, "/2015-03-31/functions")
end
def delete_event_source_mapping(client, source_mapping_uuid) do
request(client, :delete_event_source_mapping, %{}, "/2015-03-31/event-source-mappings/#{source_mapping_uuid}")
end
def delete_function(client, function_name) do
request(client, :delete_function, %{}, "/2015-03-31/functions/#{function_name}")
end
def get_event_source_mapping(client, source_mapping_uuid) do
request(client, :get_event_source_mapping, %{}, "/2015-03-31/event-source-mappings/#{source_mapping_uuid}")
end
def get_function(client, function_name) do
request(client, :get_function, %{}, "/2015-03-31/functions/#{function_name}/versions/HEAD")
end
def get_function_configuration(client, function_name) do
request(client, :get_function_configuration, %{}, "/2015-03-31/functions/#{function_name}/versions/HEAD/configuration")
end
def get_policy(client, function_name) do
request(client, :get_policy, %{}, "/2015-03-31/functions/#{function_name}/versions/HEAD/policy")
end
def invoke(client, function_name, payload, client_context, opts \\ []) do
opts = Enum.into(opts, %{})
headers = [invocation_type: "X-Amz-Invocation-Type", log_type: "X-Amz-Log-Type"]
|> Enum.reduce([], fn({opt, header}, headers) ->
case Map.get(opts, opt) do
nil -> headers
value -> [{header, value} |headers]
end
end)
headers = case client_context do
%{} -> headers
context ->
header = {"X-Amz-Client-Context", context |> client.config[:json_codec].encode! |> Base.encode64}
[header | headers]
end
request(client, :invoke, payload, "/2015-03-31/functions/#{function_name}/invocations", [], headers)
end
def invoke_async(client, function_name, args) do
Logger.info("This API is deprecated. See invoke/5 with the Event value set as invocation type")
request(client, :invoke, args |> normalize_opts, "/2014-11-13/functions/#{function_name}/invoke-async/")
end
def list_event_source_mappings(client, opts \\ []) do
params = opts
|> normalize_opts
request(client, :list_event_source_mappings, %{}, "/2015-03-31/event-source-mappings/", params)
end
def list_functions(client, opts \\ []) do
request(client, :list_functions, %{}, "/2015-03-31/functions/", normalize_opts(opts))
end
def remove_permission(client, function_name, statement_id) do
request(client, :remove_permission, %{}, "/2015-03-31/functions/#{function_name}/versions/HEAD/policy/#{statement_id}")
end
def update_event_source_mapping(client, uuid, attrs_to_update) do
request(client, :update_event_source_mapping, attrs_to_update, "/2015-03-31/event-source-mappings/#{uuid}")
end
def update_function_code(client, function_name, zipfile) do
data = %{"ZipFile" => zipfile}
request(client, :update_function_code, data, "/2015-03-31/functions/#{function_name}/versions/HEAD/code")
end
def update_function_configuration(client, function_name, configuration) do
data = configuration |> normalize_opts
request(client, :update_function_configuration, data, "/2015-03-31/functions/#{function_name}/versions/HEAD/configuration")
end
defp request(%{__struct__: client_module} = client, action, data, path, params \\ [], headers \\ []) do
client_module.request(client, action, data, path, params, headers)
end
defp normalize_opts(opts) do
opts
|> Enum.into(%{})
|> camelize_keys
end
end