{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SES.ListIdentityPolicies
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of sending authorization policies that are attached to
-- the given identity (an email address or a domain). This API returns only
-- a list. If you want the actual policy content, you can use
-- @GetIdentityPolicies@.
--
-- This API is for the identity owner only. If you have not verified the
-- identity, this API will return an error.
--
-- Sending authorization is a feature that enables an identity owner to
-- authorize other senders to use its identities. For information about
-- using sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- You can execute this operation no more than once per second.
module Amazonka.SES.ListIdentityPolicies
  ( -- * Creating a Request
    ListIdentityPolicies (..),
    newListIdentityPolicies,

    -- * Request Lenses
    listIdentityPolicies_identity,

    -- * Destructuring the Response
    ListIdentityPoliciesResponse (..),
    newListIdentityPoliciesResponse,

    -- * Response Lenses
    listIdentityPoliciesResponse_httpStatus,
    listIdentityPoliciesResponse_policyNames,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SES.Types

-- | Represents a request to return a list of sending authorization policies
-- that are attached to an identity. Sending authorization is an Amazon SES
-- feature that enables you to authorize other senders to use your
-- identities. For information, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- /See:/ 'newListIdentityPolicies' smart constructor.
data ListIdentityPolicies = ListIdentityPolicies'
  { -- | The identity that is associated with the policy for which the policies
    -- will be listed. You can specify an identity by using its name or by
    -- using its Amazon Resource Name (ARN). Examples: @user\@example.com@,
    -- @example.com@,
    -- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@.
    --
    -- To successfully call this API, you must own the identity.
    ListIdentityPolicies -> Text
identity :: Prelude.Text
  }
  deriving (ListIdentityPolicies -> ListIdentityPolicies -> Bool
(ListIdentityPolicies -> ListIdentityPolicies -> Bool)
-> (ListIdentityPolicies -> ListIdentityPolicies -> Bool)
-> Eq ListIdentityPolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIdentityPolicies -> ListIdentityPolicies -> Bool
$c/= :: ListIdentityPolicies -> ListIdentityPolicies -> Bool
== :: ListIdentityPolicies -> ListIdentityPolicies -> Bool
$c== :: ListIdentityPolicies -> ListIdentityPolicies -> Bool
Prelude.Eq, ReadPrec [ListIdentityPolicies]
ReadPrec ListIdentityPolicies
Int -> ReadS ListIdentityPolicies
ReadS [ListIdentityPolicies]
(Int -> ReadS ListIdentityPolicies)
-> ReadS [ListIdentityPolicies]
-> ReadPrec ListIdentityPolicies
-> ReadPrec [ListIdentityPolicies]
-> Read ListIdentityPolicies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListIdentityPolicies]
$creadListPrec :: ReadPrec [ListIdentityPolicies]
readPrec :: ReadPrec ListIdentityPolicies
$creadPrec :: ReadPrec ListIdentityPolicies
readList :: ReadS [ListIdentityPolicies]
$creadList :: ReadS [ListIdentityPolicies]
readsPrec :: Int -> ReadS ListIdentityPolicies
$creadsPrec :: Int -> ReadS ListIdentityPolicies
Prelude.Read, Int -> ListIdentityPolicies -> ShowS
[ListIdentityPolicies] -> ShowS
ListIdentityPolicies -> String
(Int -> ListIdentityPolicies -> ShowS)
-> (ListIdentityPolicies -> String)
-> ([ListIdentityPolicies] -> ShowS)
-> Show ListIdentityPolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIdentityPolicies] -> ShowS
$cshowList :: [ListIdentityPolicies] -> ShowS
show :: ListIdentityPolicies -> String
$cshow :: ListIdentityPolicies -> String
showsPrec :: Int -> ListIdentityPolicies -> ShowS
$cshowsPrec :: Int -> ListIdentityPolicies -> ShowS
Prelude.Show, (forall x. ListIdentityPolicies -> Rep ListIdentityPolicies x)
-> (forall x. Rep ListIdentityPolicies x -> ListIdentityPolicies)
-> Generic ListIdentityPolicies
forall x. Rep ListIdentityPolicies x -> ListIdentityPolicies
forall x. ListIdentityPolicies -> Rep ListIdentityPolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListIdentityPolicies x -> ListIdentityPolicies
$cfrom :: forall x. ListIdentityPolicies -> Rep ListIdentityPolicies x
Prelude.Generic)

-- |
-- Create a value of 'ListIdentityPolicies' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'identity', 'listIdentityPolicies_identity' - The identity that is associated with the policy for which the policies
-- will be listed. You can specify an identity by using its name or by
-- using its Amazon Resource Name (ARN). Examples: @user\@example.com@,
-- @example.com@,
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@.
--
-- To successfully call this API, you must own the identity.
newListIdentityPolicies ::
  -- | 'identity'
  Prelude.Text ->
  ListIdentityPolicies
newListIdentityPolicies :: Text -> ListIdentityPolicies
newListIdentityPolicies Text
pIdentity_ =
  ListIdentityPolicies' :: Text -> ListIdentityPolicies
ListIdentityPolicies' {$sel:identity:ListIdentityPolicies' :: Text
identity = Text
pIdentity_}

-- | The identity that is associated with the policy for which the policies
-- will be listed. You can specify an identity by using its name or by
-- using its Amazon Resource Name (ARN). Examples: @user\@example.com@,
-- @example.com@,
-- @arn:aws:ses:us-east-1:123456789012:identity\/example.com@.
--
-- To successfully call this API, you must own the identity.
listIdentityPolicies_identity :: Lens.Lens' ListIdentityPolicies Prelude.Text
listIdentityPolicies_identity :: (Text -> f Text) -> ListIdentityPolicies -> f ListIdentityPolicies
listIdentityPolicies_identity = (ListIdentityPolicies -> Text)
-> (ListIdentityPolicies -> Text -> ListIdentityPolicies)
-> Lens ListIdentityPolicies ListIdentityPolicies Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIdentityPolicies' {Text
identity :: Text
$sel:identity:ListIdentityPolicies' :: ListIdentityPolicies -> Text
identity} -> Text
identity) (\s :: ListIdentityPolicies
s@ListIdentityPolicies' {} Text
a -> ListIdentityPolicies
s {$sel:identity:ListIdentityPolicies' :: Text
identity = Text
a} :: ListIdentityPolicies)

instance Core.AWSRequest ListIdentityPolicies where
  type
    AWSResponse ListIdentityPolicies =
      ListIdentityPoliciesResponse
  request :: ListIdentityPolicies -> Request ListIdentityPolicies
request = Service -> ListIdentityPolicies -> Request ListIdentityPolicies
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ListIdentityPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListIdentityPolicies)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ListIdentityPolicies))
-> Logger
-> Service
-> Proxy ListIdentityPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListIdentityPolicies)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ListIdentityPoliciesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> [Text] -> ListIdentityPoliciesResponse
ListIdentityPoliciesResponse'
            (Int -> [Text] -> ListIdentityPoliciesResponse)
-> Either String Int
-> Either String ([Text] -> ListIdentityPoliciesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String ([Text] -> ListIdentityPoliciesResponse)
-> Either String [Text]
-> Either String ListIdentityPoliciesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PolicyNames" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String [Text]) -> Either String [Text]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member"
                        )
      )

instance Prelude.Hashable ListIdentityPolicies

instance Prelude.NFData ListIdentityPolicies

instance Core.ToHeaders ListIdentityPolicies where
  toHeaders :: ListIdentityPolicies -> ResponseHeaders
toHeaders = ResponseHeaders -> ListIdentityPolicies -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ListIdentityPolicies where
  toPath :: ListIdentityPolicies -> ByteString
toPath = ByteString -> ListIdentityPolicies -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ListIdentityPolicies where
  toQuery :: ListIdentityPolicies -> QueryString
toQuery ListIdentityPolicies' {Text
identity :: Text
$sel:identity:ListIdentityPolicies' :: ListIdentityPolicies -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ListIdentityPolicies" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"Identity" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
identity
      ]

-- | A list of names of sending authorization policies that apply to an
-- identity.
--
-- /See:/ 'newListIdentityPoliciesResponse' smart constructor.
data ListIdentityPoliciesResponse = ListIdentityPoliciesResponse'
  { -- | The response's http status code.
    ListIdentityPoliciesResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list of names of policies that apply to the specified identity.
    ListIdentityPoliciesResponse -> [Text]
policyNames :: [Prelude.Text]
  }
  deriving (ListIdentityPoliciesResponse
-> ListIdentityPoliciesResponse -> Bool
(ListIdentityPoliciesResponse
 -> ListIdentityPoliciesResponse -> Bool)
-> (ListIdentityPoliciesResponse
    -> ListIdentityPoliciesResponse -> Bool)
-> Eq ListIdentityPoliciesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIdentityPoliciesResponse
-> ListIdentityPoliciesResponse -> Bool
$c/= :: ListIdentityPoliciesResponse
-> ListIdentityPoliciesResponse -> Bool
== :: ListIdentityPoliciesResponse
-> ListIdentityPoliciesResponse -> Bool
$c== :: ListIdentityPoliciesResponse
-> ListIdentityPoliciesResponse -> Bool
Prelude.Eq, ReadPrec [ListIdentityPoliciesResponse]
ReadPrec ListIdentityPoliciesResponse
Int -> ReadS ListIdentityPoliciesResponse
ReadS [ListIdentityPoliciesResponse]
(Int -> ReadS ListIdentityPoliciesResponse)
-> ReadS [ListIdentityPoliciesResponse]
-> ReadPrec ListIdentityPoliciesResponse
-> ReadPrec [ListIdentityPoliciesResponse]
-> Read ListIdentityPoliciesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListIdentityPoliciesResponse]
$creadListPrec :: ReadPrec [ListIdentityPoliciesResponse]
readPrec :: ReadPrec ListIdentityPoliciesResponse
$creadPrec :: ReadPrec ListIdentityPoliciesResponse
readList :: ReadS [ListIdentityPoliciesResponse]
$creadList :: ReadS [ListIdentityPoliciesResponse]
readsPrec :: Int -> ReadS ListIdentityPoliciesResponse
$creadsPrec :: Int -> ReadS ListIdentityPoliciesResponse
Prelude.Read, Int -> ListIdentityPoliciesResponse -> ShowS
[ListIdentityPoliciesResponse] -> ShowS
ListIdentityPoliciesResponse -> String
(Int -> ListIdentityPoliciesResponse -> ShowS)
-> (ListIdentityPoliciesResponse -> String)
-> ([ListIdentityPoliciesResponse] -> ShowS)
-> Show ListIdentityPoliciesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIdentityPoliciesResponse] -> ShowS
$cshowList :: [ListIdentityPoliciesResponse] -> ShowS
show :: ListIdentityPoliciesResponse -> String
$cshow :: ListIdentityPoliciesResponse -> String
showsPrec :: Int -> ListIdentityPoliciesResponse -> ShowS
$cshowsPrec :: Int -> ListIdentityPoliciesResponse -> ShowS
Prelude.Show, (forall x.
 ListIdentityPoliciesResponse -> Rep ListIdentityPoliciesResponse x)
-> (forall x.
    Rep ListIdentityPoliciesResponse x -> ListIdentityPoliciesResponse)
-> Generic ListIdentityPoliciesResponse
forall x.
Rep ListIdentityPoliciesResponse x -> ListIdentityPoliciesResponse
forall x.
ListIdentityPoliciesResponse -> Rep ListIdentityPoliciesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListIdentityPoliciesResponse x -> ListIdentityPoliciesResponse
$cfrom :: forall x.
ListIdentityPoliciesResponse -> Rep ListIdentityPoliciesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListIdentityPoliciesResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'listIdentityPoliciesResponse_httpStatus' - The response's http status code.
--
-- 'policyNames', 'listIdentityPoliciesResponse_policyNames' - A list of names of policies that apply to the specified identity.
newListIdentityPoliciesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListIdentityPoliciesResponse
newListIdentityPoliciesResponse :: Int -> ListIdentityPoliciesResponse
newListIdentityPoliciesResponse Int
pHttpStatus_ =
  ListIdentityPoliciesResponse' :: Int -> [Text] -> ListIdentityPoliciesResponse
ListIdentityPoliciesResponse'
    { $sel:httpStatus:ListIdentityPoliciesResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:policyNames:ListIdentityPoliciesResponse' :: [Text]
policyNames = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The response's http status code.
listIdentityPoliciesResponse_httpStatus :: Lens.Lens' ListIdentityPoliciesResponse Prelude.Int
listIdentityPoliciesResponse_httpStatus :: (Int -> f Int)
-> ListIdentityPoliciesResponse -> f ListIdentityPoliciesResponse
listIdentityPoliciesResponse_httpStatus = (ListIdentityPoliciesResponse -> Int)
-> (ListIdentityPoliciesResponse
    -> Int -> ListIdentityPoliciesResponse)
-> Lens
     ListIdentityPoliciesResponse ListIdentityPoliciesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIdentityPoliciesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListIdentityPoliciesResponse' :: ListIdentityPoliciesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListIdentityPoliciesResponse
s@ListIdentityPoliciesResponse' {} Int
a -> ListIdentityPoliciesResponse
s {$sel:httpStatus:ListIdentityPoliciesResponse' :: Int
httpStatus = Int
a} :: ListIdentityPoliciesResponse)

-- | A list of names of policies that apply to the specified identity.
listIdentityPoliciesResponse_policyNames :: Lens.Lens' ListIdentityPoliciesResponse [Prelude.Text]
listIdentityPoliciesResponse_policyNames :: ([Text] -> f [Text])
-> ListIdentityPoliciesResponse -> f ListIdentityPoliciesResponse
listIdentityPoliciesResponse_policyNames = (ListIdentityPoliciesResponse -> [Text])
-> (ListIdentityPoliciesResponse
    -> [Text] -> ListIdentityPoliciesResponse)
-> Lens
     ListIdentityPoliciesResponse
     ListIdentityPoliciesResponse
     [Text]
     [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIdentityPoliciesResponse' {[Text]
policyNames :: [Text]
$sel:policyNames:ListIdentityPoliciesResponse' :: ListIdentityPoliciesResponse -> [Text]
policyNames} -> [Text]
policyNames) (\s :: ListIdentityPoliciesResponse
s@ListIdentityPoliciesResponse' {} [Text]
a -> ListIdentityPoliciesResponse
s {$sel:policyNames:ListIdentityPoliciesResponse' :: [Text]
policyNames = [Text]
a} :: ListIdentityPoliciesResponse) (([Text] -> f [Text])
 -> ListIdentityPoliciesResponse -> f ListIdentityPoliciesResponse)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> ListIdentityPoliciesResponse
-> f ListIdentityPoliciesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListIdentityPoliciesResponse