Packages
ex_aws
1.1.4
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/firehose.ex
defmodule ExAws.Firehose do
@moduledoc """
AWS Kinesis Firehose
"""
import ExAws.Utils, only: [camelize_keys: 1]
require Logger
@namespace "Firehose_20150804"
## Streams
######################
@type stream_name :: binary
@doc "Lists streams"
@type list_delivery_stream_opts :: [
{:exclusive_start_delivery_stream_name, binary} |
{:limit, pos_integer}
]
@spec list_delivery_streams() :: ExAws.Operation.JSON.t
@spec list_delivery_streams(opts :: list_delivery_stream_opts) :: ExAws.Operation.JSON.t
def list_delivery_streams(opts \\ []) do
data = opts
|> camelize_keys
|> Map.merge(%{})
request(:list_delivery_streams, data)
end
@doc "Describe Stream"
@type describe_delivery_stream_opts :: [
{:limit, pos_integer} |
{:exclusive_start_destination_id, binary}
]
@spec describe_delivery_stream(stream_name :: stream_name) :: ExAws.Operation.JSON.t
@spec describe_delivery_stream(stream_name :: stream_name, opts :: describe_delivery_stream_opts) :: ExAws.Operation.JSON.t
def describe_delivery_stream(stream_name, opts \\ []) do
data = opts
|> camelize_keys
|> Map.merge(%{"DeliveryStreamName" => stream_name})
request(:describe_delivery_stream, data)
end
@doc "Creates stream"
@type create_delivery_stream_opts :: [
{:elasticsearch_destination_configuration, Keyword.t} |
{:redshift_destination_configuration, Keyword.t} |
{:s3_destination_configuration, Keyword.t}
]
@spec create_delivery_stream(stream_name :: stream_name) :: ExAws.Operation.JSON.t
@spec create_delivery_stream(stream_name :: stream_name, opts :: create_delivery_stream_opts) :: ExAws.Operation.JSON.t
def create_delivery_stream(stream_name, shard_count \\ 1) do
data = %{
"ShardCount" => shard_count,
"DeliveryStreamName" => stream_name}
request(:create_delivery_stream, data)
end
@doc "Deletes stream"
@spec delete_delivery_stream(stream_name :: stream_name) :: ExAws.Operation.JSON.t
def delete_delivery_stream(stream_name) do
request(:delete_delivery_stream, %{"DeliveryStreamName" => stream_name})
end
## Records
######################
@doc "Puts a record on a stream"
@spec put_record(stream_name :: stream_name, data :: binary) :: ExAws.Operation.JSON.t
def put_record(stream_name, data, opts \\ []) do
data = opts
|> camelize_keys
|> Map.merge(%{
"Record" => format_record(data),
"DeliveryStreamName" => stream_name})
request(:put_record, data)
end
@doc "Put multiple records on a stream"
@type put_record_batch_record :: [
{:data, binary}
]
@spec put_record_batch(stream_name :: stream_name, records :: [put_record_batch_record]) :: ExAws.Operation.JSON.t
def put_record_batch(stream_name, records) when is_list(records) do
data = %{
"Records" => records |> Enum.map(&format_record/1),
"DeliveryStreamName" => stream_name
}
request(:put_record_batch, data)
end
defp format_record(data) when is_binary(data), do: format_record(%{data: data})
defp format_record(%{data: data}) do
%{"Data" => data |> Base.encode64}
end
## Destinations
######################
@doc "Updates the specified destination of the specified delivery stream."
@type update_destination_opts :: [
{:elasticsearch_destination_update, Keyword.t} |
{:redshift_destination_update, Keyword.t} |
{:s3_destination_update, Keyword.t}
]
@spec update_destination(stream_name :: stream_name, version_id :: binary, destination_id :: binary) :: ExAws.Operation.JSON.t
@spec update_destination(stream_name :: stream_name, version_id :: binary, destination_id :: binary, opts :: update_destination_opts) :: ExAws.Operation.JSON.t
def update_destination(stream_name, version_id, destination_id, opts \\ []) do
data = opts
|> camelize_keys
|> Map.merge(%{
"DeliveryStreamName" => stream_name,
"CurrentDeliveryStreamVersionId" => version_id,
"DestinationId" => destination_id,
})
request(:update_destination, data)
end
defp request(action, data, opts \\ %{}) do
operation =
action
|> Atom.to_string
|> Macro.camelize
ExAws.Operation.JSON.new(:firehose, %{
data: data,
headers: [
{"x-amz-target", "#{@namespace}.#{operation}"},
{"content-type", "application/x-amz-json-1.1"}
]
} |> Map.merge(opts))
end
end