Skip to content

Commit

Permalink
Improves documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
abitdodgy committed Oct 19, 2018
1 parent 95fe27d commit ad97939
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ExAws IAM

Easily interact with the AWS IAM API to work with users, access keys, and much more. This is an IAM service module for [ExAws](https://github.com/ex-aws/ex_aws).
Easily interact with the AWS IAM API to work with users, access keys, and much more.

This is an IAM service module for [ExAws](https://github.com/ex-aws/ex_aws).

```elixir
user =
Expand Down Expand Up @@ -61,7 +63,7 @@ config :ex_aws,

## Usage

The following operations are currently available.
See the documentation for details. The following operations are currently available.

### User

Expand Down
22 changes: 20 additions & 2 deletions lib/ex_aws/iam.ex
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,27 @@ defmodule ExAws.Iam do
|> to_op()
end

def to_user({:ok, %{body: body}}), do: User.new(body)
@doc """
Converts a parsed IAM response into a `User` struct.
## Parameters
* `resp` - The parsed response of an IAM API query request.
"""
def to_user({:ok, %{body: body}}) do
User.new(body)
end

@doc """
Converts a parsed IAM response into an `AccessKey` struct.
def to_access_key({:ok, %{body: body}}), do: AccessKey.new(body)
* `resp` - The parsed response of an IAM API query request.
"""
def to_access_key({:ok, %{body: body}}) do
AccessKey.new(body)
end

defp to_params(action, opts, args \\ []) do
@shared_opts
Expand Down
4 changes: 4 additions & 0 deletions lib/ex_aws/iam/access_key.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ defmodule ExAws.Iam.AccessKey do
username: String.t()
}

@doc """
Returns a struct representation of an IAM AccessKey.
"""
def new(%{list_access_keys_result: %{access_key_metadata: access_keys}}) do
Enum.map(access_keys, fn key ->
access_key_to_struct(key)
Expand Down
7 changes: 5 additions & 2 deletions lib/ex_aws/iam/parsers/access_key.ex
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
defmodule ExAws.Iam.Parsers.AccessKey do
@moduledoc false
@moduledoc """
Defines parsers for handling AWS IAM access key query reponses.
"""

import SweetXml, only: [sigil_x: 2]

@doc """
Parses XML from IAM API query responses.
Parses XML from IAM API access key query responses.
"""
def parse(xml, "ListAccessKeys") do
Expand Down
9 changes: 8 additions & 1 deletion lib/ex_aws/iam/parsers/user.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
defmodule ExAws.Iam.Parsers.User do
@moduledoc false
@moduledoc """
Defines parsers for handling AWS IAM user query reponses.
"""

import SweetXml, only: [sigil_x: 2]

@doc """
Parses XML from IAM API user query responses.
"""
def parse(xml, "ListUsers") do
SweetXml.xpath(xml, ~x"//ListUsersResponse",
list_users_result: [
Expand Down
4 changes: 4 additions & 0 deletions lib/ex_aws/iam/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ defmodule ExAws.Iam.User do
username: String.t()
}

@doc """
Returns a struct representation of an IAM User.
"""
def new(%{get_user_result: %{user: user}}), do: to_struct(user)

def new(%{create_user_result: %{user: user}}), do: to_struct(user)
Expand Down

0 comments on commit ad97939

Please sign in to comment.