Packages
ex_aws
0.4.6
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/s3/client.ex
defmodule ExAws.S3.Client do
use Behaviour
@moduledoc """
The purpose of this module is to surface the ExAws.S3 API tied to a single
configuration chosen, such that it does not need passed in with every request.
Usage:
```
defmodule MyApp.S3 do
use ExAws.S3.Client, otp_app: :my_otp_app
end
```
In your config
```
config :my_otp_app, :ex_aws,
s3: [], # S3 config goes here
```
You can now use MyApp.S3 as the root module for the S3 api without needing
to pass in a particular configuration.
This enables different otp apps to configure their AWS configuration separately.
The alignment with a particular OTP app while convenient is however entirely optional.
The following also works:
```
defmodule MyApp.S3 do
use ExAws.S3.Client
def config_root do
Application.get_all_env(:my_aws_config_root)
end
end
```
ExAws now expects the config for that S3 client to live under
```elixir
config :my_aws_config_root
s3: [] # S3 config goes here
```
This is in fact how the functions in ExAws.S3 that do not require a config work.
Default config values can be found in ExAws.Config. The default configuration is always used,
and then the configuration of a particular client is merged in and overrides the defaults.
"""
## Bucket functions
# Delete
@doc "Delete a bucket"
defcallback delete_bucket(bucket :: binary) :: ExAws.Request.response_t
@doc "Delete a bucket cors"
defcallback delete_bucket_cors(bucket :: binary) :: ExAws.Request.response_t
@doc "Delete a bucket lifecycle"
defcallback delete_bucket_lifecycle(bucket :: binary) :: ExAws.Request.response_t
@doc "Delete a bucket policy"
defcallback delete_bucket_policy(bucket :: binary) :: ExAws.Request.response_t
@doc "Delete a bucket replication"
defcallback delete_bucket_replication(bucket :: binary) :: ExAws.Request.response_t
@doc "Delete a bucket tagging"
defcallback delete_bucket_tagging(bucket :: binary) :: ExAws.Request.response_t
@doc "Delete a bucket website"
defcallback delete_bucket_website(bucket :: binary) :: ExAws.Request.response_t
# Get
@doc "List buckets"
defcallback list_buckets() :: ExAws.Request.response_t
defcallback list_buckets(opts :: Keyword.t) :: ExAws.Request.response_t
@type list_objects_opts :: [
{:delimiter, binary} |
{:encoding_type, binary} |
{:marker, binary} |
{:max_keys, 0..1000} |
{:prefix, binary}
]
@doc "List objects in bucket"
defcallback list_objects(bucket :: binary) :: ExAws.Request.response_t
defcallback list_objects(bucket :: binary, opts :: list_objects_opts) :: ExAws.Request.response_t
@doc "Same as list_objects/1,2 but returns the result and raises on failure."
defcallback list_objects!(bucket :: binary) :: ExAws.Request.response_t
defcallback list_objects!(bucket :: binary, opts :: list_objects_opts) :: ExAws.Request.response_t
@doc "Stream list of objects in bucket"
defcallback stream_objects!(bucket :: binary) :: Enumerable.t
defcallback stream_objects!(bucket :: binary, opts :: list_objects_opts) :: Enumerable.t
@doc "Get bucket acl"
defcallback get_bucket_acl(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket cors"
defcallback get_bucket_cors(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket lifecycle"
defcallback get_bucket_lifecycle(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket policy"
defcallback get_bucket_policy(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket location"
defcallback get_bucket_location(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket logging"
defcallback get_bucket_logging(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket notification"
defcallback get_bucket_notification(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket replication"
defcallback get_bucket_replication(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket tagging"
defcallback get_bucket_tagging(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket object versions"
defcallback get_bucket_object_versions(bucket :: binary) :: ExAws.Request.response_t
defcallback get_bucket_object_versions(bucket :: binary, opts :: Keyword.t) :: ExAws.Request.response_t
@doc "Get bucket payment configuration"
defcallback get_bucket_request_payment(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket versioning"
defcallback get_bucket_versioning(bucket :: binary) :: ExAws.Request.response_t
@doc "Get bucket website"
defcallback get_bucket_website(bucket :: binary) :: ExAws.Request.response_t
@doc "Determine if a bucket exists"
defcallback head_bucket(bucket :: binary) :: ExAws.Request.response_t
@doc "List multipart uploads for a bucket"
defcallback list_multipart_uploads(bucket :: binary) :: ExAws.Request.response_t
defcallback list_multipart_uploads(bucket :: binary, opts :: Keyword.t) :: ExAws.Request.response_t
@doc "Creates a bucket. Same as create_bucket/2"
defcallback put_bucket(bucket :: binary, region :: binary) :: ExAws.Request.response_t
@doc "Update or create a bucket bucket access control"
defcallback put_bucket_acl(bucket :: binary, grants :: %{}) :: ExAws.Request.response_t
@doc "Update or create a bucket CORS policy"
defcallback put_bucket_cors(bucket :: binary, cors_config :: %{}) :: ExAws.Request.response_t
@doc "Update or create a bucket lifecycle configuration"
defcallback put_bucket_lifecycle(bucket :: binary, lifecycle_config :: %{}) :: ExAws.Request.response_t
@doc "Update or create a bucket policy configuration"
defcallback put_bucket_policy(bucket :: binary, policy :: %{}) :: ExAws.Request.response_t
@doc "Update or create a bucket logging configuration"
defcallback put_bucket_logging(bucket :: binary, logging_config :: %{}) :: ExAws.Request.response_t
@doc "Update or create a bucket notification configuration"
defcallback put_bucket_notification(bucket :: binary, notification_config :: %{}) :: ExAws.Request.response_t
@doc "Update or create a bucket replication configuration"
defcallback put_bucket_replication(bucket :: binary, replication_config :: %{}) :: ExAws.Request.response_t
@doc "Update or create a bucket tagging configuration"
defcallback put_bucket_tagging(bucket :: binary, tags :: %{}) :: ExAws.Request.response_t
@doc "Update or create a bucket requestpayment configuration"
defcallback put_bucket_requestpayment(bucket :: binary, payer :: :requester | :bucket_owner) :: ExAws.Request.response_t
@doc "Update or create a bucket versioning configuration"
defcallback put_bucket_versioning(bucket :: binary, version_config :: binary) :: ExAws.Request.response_t
@doc "Update or create a bucket website configuration"
defcallback put_bucket_website(bucket :: binary, website_config :: binary) :: ExAws.Request.response_t
## Object functions
@doc "Delete object object in bucket"
defcallback delete_object(bucket :: binary, object :: binary) :: ExAws.Request.response_t
@doc "Same as delete_object/2 but returns just the response or raises on error"
defcallback delete_object!(bucket :: binary, object :: binary) :: ExAws.Request.response_t
@doc "Delete multiple objects within a bucket"
defcallback delete_multiple_objects(
bucket :: binary,
objects :: [binary | {binary, binary}, ...]):: ExAws.Request.response_t
@type customer_encryption_opts :: [customer_algorithm: binary, customer_key: binary, customer_key_md5: binary]
@type get_object_response_opts :: [
{:content_language, binary}
| {:expires, binary}
| {:cach_control, binary}
| {:content_disposition, binary}
| {:content_encoding, binary}
]
@type get_object_opts :: [
{:response, get_object_response_opts}
| {:encryption, customer_encryption_opts}
| {:range, binary}
| {:if_modified_since, binary}
| {:if_unmodified_since, binary}
| {:if_match, binary}
| {:if_none_match, binary}
]
@doc "Get an object from a bucket"
defcallback get_object(bucket :: binary, object :: binary) :: ExAws.Request.response_t
defcallback get_object(bucket :: binary, object :: binary, opts :: get_object_opts) :: ExAws.Request.response_t
@doc "Same as get_object/2,3 but returns just the response or raises on error"
defcallback get_object!(bucket :: binary, object :: binary) :: ExAws.Request.response_t
defcallback get_object!(bucket :: binary, object :: binary, opts :: get_object_opts) :: ExAws.Request.response_t
@doc "Get an object's access control policy"
defcallback get_object_acl(bucket :: binary, object :: binary) :: ExAws.Request.response_t
defcallback get_object_acl(bucket :: binary, object :: binary, opts :: Keyword.t) :: ExAws.Request.response_t
@doc "Get a torrent for a bucket"
defcallback get_object_torrent(bucket :: binary, object :: binary) :: ExAws.Request.response_t
@doc "Determine of an object exists"
defcallback head_object(bucket :: binary, object :: binary) :: ExAws.Request.response_t
defcallback head_object(bucket :: binary, object :: binary, opts :: Keyword.t) :: ExAws.Request.response_t
@doc "Determine the CORS configuration for an object"
defcallback options_object(
bucket :: binary,
object :: binary,
origin :: binary,
request_method :: atom) :: ExAws.Request.response_t
defcallback options_object(
bucket :: binary,
object :: binary,
origin :: binary,
request_method :: atom,
request_headers :: [binary, ...]) :: ExAws.Request.response_t
@doc """
Create an object within a bucket.
Generally speaking put_object ought to be used. AWS POST object exists to
support the AWS UI.
"""
defcallback post_object(bucket :: binary, object :: binary) :: ExAws.Request.response_t
defcallback post_object(bucket :: binary, object :: binary, opts :: Keyword.t) :: ExAws.Request.response_t
@doc "Restore an object to a particular version FIXME"
defcallback post_object_restore(
bucket :: binary,
object :: binary,
version_id :: binary,
number_of_days :: pos_integer) :: ExAws.Request.response_t
@type canned_acl :: :private
| :public_read
| :public_read_write
| :authenticated_read
| :bucket_owner_read
| :bucket_owner_full_control
@type grant :: [ {:email, binary}
| {:id, binary}
| {:uri, binary}
]
@type encryption_opts :: binary | [aws_kms_key_id: binary] | customer_encryption_opts
@type put_object_opts :: [ {:cache_control, binary}
| {:content_disposition, binary}
| {:content_encoding, binary}
| {:content_length, binary}
| {:content_type, binary}
| {:expect, binary}
| {:expires, binary}
| {:storage_class, binary}
| {:website_redirect_location, binary}
| {:grant_read, grant}
| {:grant_read_acp, grant}
| {:grant_write_acp, grant}
| {:grant_full_control, grant}
| {:acl, canned_acl}
| {:encryption, encryption_opts}
]
@doc "Create an object within a bucket"
defcallback put_object(bucket :: binary, object :: binary, body :: binary) :: ExAws.Request.response_t
defcallback put_object(bucket :: binary, object :: binary, body :: binary, opts :: put_object_opts) :: ExAws.Request.response_t
@doc "Same as put_object/2 but returns just the response or raises on error"
defcallback put_object!(bucket :: binary, object :: binary, body :: binary) :: ExAws.Request.response_t
defcallback put_object!(bucket :: binary, object :: binary, body :: binary, opts :: put_object_opts) :: ExAws.Request.response_t
@doc "Create or update an object's access control FIXME"
defcallback put_object_acl(bucket :: binary, object :: binary, acl :: %{}) :: ExAws.Request.response_t
@doc "Copy an object"
defcallback put_object_copy(
dest_bucket :: binary,
dest_object :: binary,
src_bucket :: binary,
src_object :: binary) :: ExAws.Request.response_t
defcallback put_object_copy(
dest_bucket :: binary,
dest_object :: binary,
src_bucket :: binary,
src_object :: binary,
opts :: %{}) :: ExAws.Request.response_t
@doc "Initiate a multipart upload"
defcallback initiate_multipart_upload(bucket :: binary, object :: binary) :: ExAws.Request.response_t
defcallback initiate_multipart_upload(bucket :: binary, object :: binary, opts :: Keyword.t) :: ExAws.Request.response_t
@doc "Upload a part for a multipart upload"
defcallback upload_part(
bucket :: binary,
object :: binary,
upload_id :: binary,
part_number :: pos_integer) :: ExAws.Request.response_t
@doc "Upload a part for a multipart copy"
defcallback upload_part_copy(
dest_bucket :: binary,
dest_object :: binary,
src_bucket :: binary,
src_object :: binary) :: ExAws.Request.response_t
defcallback upload_part_copy(
dest_bucket :: binary,
dest_object :: binary,
src_bucket :: binary,
src_object :: binary,
opts :: %{}) :: ExAws.Request.response_t
@doc "Complete a multipart upload"
defcallback complete_multipart_upload(
bucket :: binary,
object :: binary,
upload_id :: binary,
parts :: %{}) :: ExAws.Request.response_t
@doc "Abort a multipart upload"
defcallback abort_multipart_upload(bucket :: binary, object :: binary, upload_id :: binary) :: ExAws.Request.response_t
@doc "List the parts of a multipart upload"
defcallback list_parts(bucket :: binary, object :: binary, upload_id :: binary) :: ExAws.Request.response_t
defcallback list_parts(bucket :: binary, object :: binary, upload_id :: binary, opts :: Keyword.t) :: ExAws.Request.response_t
@doc """
Enables custom request handling.
By default this just forwards the request to the ExAws.S3.Request.request/4.
However, this can be overriden in your client to provide pre-request adjustments to headers, params, etc.
"""
defcallback request(client :: %{}, http_method :: atom, bucket :: binary, path :: binary) :: ExAws.Request.response_t
defcallback request(client :: %{}, http_method :: atom, bucket :: binary, path :: binary, data :: Keyword.t) :: ExAws.Request.response_t
@doc "Retrieves the root AWS config for this client"
defcallback config_root() :: Keyword.t
defmacro __using__(opts) do
boilerplate = __MODULE__
|> ExAws.Client.generate_boilerplate(opts)
quote do
defstruct config: nil, service: :s3
unquote(boilerplate)
@doc false
def request(client, http_method, bucket, path, data \\ []) do
ExAws.S3.Request.request(client, http_method, bucket, path, data)
end
defoverridable config_root: 0, request: 4, request: 5
end
end
end