From b1ac4cd31a3e9f658f5040bec562f851ca146b4c Mon Sep 17 00:00:00 2001 From: chris-heath Date: Wed, 3 Jun 2020 12:17:25 -0400 Subject: [PATCH] Added ListAccountAliases --- README.md | 1 + lib/ex_aws/iam.ex | 13 +++++++++++++ lib/ex_aws/iam/parser.ex | 9 +++++++++ lib/ex_aws/iam/parsers/account_alias.ex | 22 ++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 lib/ex_aws/iam/parsers/account_alias.ex diff --git a/README.md b/README.md index 3cf0fda..fa7cd25 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ Parsers are currently implemented for the following actions: * GetGroup * GetUser * ListAccessKeys + * ListAccountAliases * ListGroup * ListRoles * ListRoleTags diff --git a/lib/ex_aws/iam.ex b/lib/ex_aws/iam.ex index a159eab..ca5e65d 100644 --- a/lib/ex_aws/iam.ex +++ b/lib/ex_aws/iam.ex @@ -46,6 +46,7 @@ defmodule ExAws.Iam do * GetGroup * GetUser * ListAccessKeys + * ListAccountAliases * ListGroup * ListRoles * ListRoleTags @@ -452,6 +453,18 @@ defmodule ExAws.Iam do operation(:list_role_tags, [role_name: role_name] ++ opts) end + @doc """ + Creates an ExAws operation for a `ListAccountAliases` IAM request. + ## Options + * `:marker` - Use this parameter only when paginating results. + * `:max_items` - Use this only when paginating results to indicate + the maximum number of items you want in the response. + See shared options in moduledoc. + """ + def list_account_aliases(opts \\ []) do + operation(:list_account_aliases, opts) + end + defp to_operation(params, opts) do %ExAws.Operation.Query{ action: params["Action"], diff --git a/lib/ex_aws/iam/parser.ex b/lib/ex_aws/iam/parser.ex index 2e7ef1b..5f389e5 100644 --- a/lib/ex_aws/iam/parser.ex +++ b/lib/ex_aws/iam/parser.ex @@ -12,6 +12,7 @@ defmodule ExAws.Iam.Parser do alias ExAws.Iam.Parsers.{ AccessKey, + AccountAlias, Group, Metadata, Role, @@ -80,4 +81,12 @@ defmodule ExAws.Iam.Parser do defp dispatch(xml, action) when action in @metadata_only_actions do Metadata.parse(xml, action) end + + @account_alias_actions ~w[ + ListAccountAliases + ] + + defp dispatch(xml, action) when action in @account_alias_actions do + AccountAlias.parse(xml, action) + end end diff --git a/lib/ex_aws/iam/parsers/account_alias.ex b/lib/ex_aws/iam/parsers/account_alias.ex new file mode 100644 index 0000000..03e1168 --- /dev/null +++ b/lib/ex_aws/iam/parsers/account_alias.ex @@ -0,0 +1,22 @@ +defmodule ExAws.Iam.Parsers.AccountAlias do + @moduledoc """ + Defines parsers for handling AWS IAM `AccountAlias` query reponses. + + """ + + import SweetXml, only: [sigil_x: 2] + + @doc """ + Parses XML from IAM `ListAccountAliases` response. + + """ + def parse(xml, "ListAccountAliases") do + xml + |> SweetXml.xpath(~x"//ListAccountAliasesResponse", + account_aliases: ~x"./ListAccountAliasesResult/AccountAliases/member/text()"sl, + marker: ~x"./ListAccountAliasesResult/Marker/text()"o, + is_truncated: ~x"./ListAccountAliasesResult/IsTruncated/text()"s, + request_id: ~x"./ResponseMetadata/RequestId/text()"s + ) + end +end