{-# 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.IAM.ListSAMLProviders
-- 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)
--
-- Lists the SAML provider resource objects defined in IAM in the account.
-- IAM resource-listing operations return a subset of the available
-- attributes for the resource. For example, this operation does not return
-- tags, even though they are an attribute of the returned object. To view
-- all of the information for a SAML provider, see GetSAMLProvider.
--
-- This operation requires
-- <https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html Signature Version 4>.
module Amazonka.IAM.ListSAMLProviders
  ( -- * Creating a Request
    ListSAMLProviders (..),
    newListSAMLProviders,

    -- * Destructuring the Response
    ListSAMLProvidersResponse (..),
    newListSAMLProvidersResponse,

    -- * Response Lenses
    listSAMLProvidersResponse_sAMLProviderList,
    listSAMLProvidersResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListSAMLProviders' smart constructor.
data ListSAMLProviders = ListSAMLProviders'
  {
  }
  deriving (ListSAMLProviders -> ListSAMLProviders -> Bool
(ListSAMLProviders -> ListSAMLProviders -> Bool)
-> (ListSAMLProviders -> ListSAMLProviders -> Bool)
-> Eq ListSAMLProviders
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSAMLProviders -> ListSAMLProviders -> Bool
$c/= :: ListSAMLProviders -> ListSAMLProviders -> Bool
== :: ListSAMLProviders -> ListSAMLProviders -> Bool
$c== :: ListSAMLProviders -> ListSAMLProviders -> Bool
Prelude.Eq, ReadPrec [ListSAMLProviders]
ReadPrec ListSAMLProviders
Int -> ReadS ListSAMLProviders
ReadS [ListSAMLProviders]
(Int -> ReadS ListSAMLProviders)
-> ReadS [ListSAMLProviders]
-> ReadPrec ListSAMLProviders
-> ReadPrec [ListSAMLProviders]
-> Read ListSAMLProviders
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSAMLProviders]
$creadListPrec :: ReadPrec [ListSAMLProviders]
readPrec :: ReadPrec ListSAMLProviders
$creadPrec :: ReadPrec ListSAMLProviders
readList :: ReadS [ListSAMLProviders]
$creadList :: ReadS [ListSAMLProviders]
readsPrec :: Int -> ReadS ListSAMLProviders
$creadsPrec :: Int -> ReadS ListSAMLProviders
Prelude.Read, Int -> ListSAMLProviders -> ShowS
[ListSAMLProviders] -> ShowS
ListSAMLProviders -> String
(Int -> ListSAMLProviders -> ShowS)
-> (ListSAMLProviders -> String)
-> ([ListSAMLProviders] -> ShowS)
-> Show ListSAMLProviders
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSAMLProviders] -> ShowS
$cshowList :: [ListSAMLProviders] -> ShowS
show :: ListSAMLProviders -> String
$cshow :: ListSAMLProviders -> String
showsPrec :: Int -> ListSAMLProviders -> ShowS
$cshowsPrec :: Int -> ListSAMLProviders -> ShowS
Prelude.Show, (forall x. ListSAMLProviders -> Rep ListSAMLProviders x)
-> (forall x. Rep ListSAMLProviders x -> ListSAMLProviders)
-> Generic ListSAMLProviders
forall x. Rep ListSAMLProviders x -> ListSAMLProviders
forall x. ListSAMLProviders -> Rep ListSAMLProviders x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSAMLProviders x -> ListSAMLProviders
$cfrom :: forall x. ListSAMLProviders -> Rep ListSAMLProviders x
Prelude.Generic)

-- |
-- Create a value of 'ListSAMLProviders' 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.
newListSAMLProviders ::
  ListSAMLProviders
newListSAMLProviders :: ListSAMLProviders
newListSAMLProviders = ListSAMLProviders
ListSAMLProviders'

instance Core.AWSRequest ListSAMLProviders where
  type
    AWSResponse ListSAMLProviders =
      ListSAMLProvidersResponse
  request :: ListSAMLProviders -> Request ListSAMLProviders
request = Service -> ListSAMLProviders -> Request ListSAMLProviders
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ListSAMLProviders
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListSAMLProviders)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ListSAMLProviders))
-> Logger
-> Service
-> Proxy ListSAMLProviders
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListSAMLProviders)))
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
"ListSAMLProvidersResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [SAMLProviderListEntry] -> Int -> ListSAMLProvidersResponse
ListSAMLProvidersResponse'
            (Maybe [SAMLProviderListEntry] -> Int -> ListSAMLProvidersResponse)
-> Either String (Maybe [SAMLProviderListEntry])
-> Either String (Int -> ListSAMLProvidersResponse)
forall (f :: * -> *) a b. Functor 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
"SAMLProviderList"
                            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 (Maybe [SAMLProviderListEntry]))
-> Either String (Maybe [SAMLProviderListEntry])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [SAMLProviderListEntry])
-> [Node] -> Either String (Maybe [SAMLProviderListEntry])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [SAMLProviderListEntry]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> ListSAMLProvidersResponse)
-> Either String Int -> Either String ListSAMLProvidersResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable ListSAMLProviders

instance Prelude.NFData ListSAMLProviders

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

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

instance Core.ToQuery ListSAMLProviders where
  toQuery :: ListSAMLProviders -> QueryString
toQuery =
    QueryString -> ListSAMLProviders -> QueryString
forall a b. a -> b -> a
Prelude.const
      ( [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ListSAMLProviders" :: Prelude.ByteString),
            ByteString
"Version"
              ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString)
          ]
      )

-- | Contains the response to a successful ListSAMLProviders request.
--
-- /See:/ 'newListSAMLProvidersResponse' smart constructor.
data ListSAMLProvidersResponse = ListSAMLProvidersResponse'
  { -- | The list of SAML provider resource objects defined in IAM for this
    -- Amazon Web Services account.
    ListSAMLProvidersResponse -> Maybe [SAMLProviderListEntry]
sAMLProviderList :: Prelude.Maybe [SAMLProviderListEntry],
    -- | The response's http status code.
    ListSAMLProvidersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListSAMLProvidersResponse -> ListSAMLProvidersResponse -> Bool
(ListSAMLProvidersResponse -> ListSAMLProvidersResponse -> Bool)
-> (ListSAMLProvidersResponse -> ListSAMLProvidersResponse -> Bool)
-> Eq ListSAMLProvidersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSAMLProvidersResponse -> ListSAMLProvidersResponse -> Bool
$c/= :: ListSAMLProvidersResponse -> ListSAMLProvidersResponse -> Bool
== :: ListSAMLProvidersResponse -> ListSAMLProvidersResponse -> Bool
$c== :: ListSAMLProvidersResponse -> ListSAMLProvidersResponse -> Bool
Prelude.Eq, ReadPrec [ListSAMLProvidersResponse]
ReadPrec ListSAMLProvidersResponse
Int -> ReadS ListSAMLProvidersResponse
ReadS [ListSAMLProvidersResponse]
(Int -> ReadS ListSAMLProvidersResponse)
-> ReadS [ListSAMLProvidersResponse]
-> ReadPrec ListSAMLProvidersResponse
-> ReadPrec [ListSAMLProvidersResponse]
-> Read ListSAMLProvidersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSAMLProvidersResponse]
$creadListPrec :: ReadPrec [ListSAMLProvidersResponse]
readPrec :: ReadPrec ListSAMLProvidersResponse
$creadPrec :: ReadPrec ListSAMLProvidersResponse
readList :: ReadS [ListSAMLProvidersResponse]
$creadList :: ReadS [ListSAMLProvidersResponse]
readsPrec :: Int -> ReadS ListSAMLProvidersResponse
$creadsPrec :: Int -> ReadS ListSAMLProvidersResponse
Prelude.Read, Int -> ListSAMLProvidersResponse -> ShowS
[ListSAMLProvidersResponse] -> ShowS
ListSAMLProvidersResponse -> String
(Int -> ListSAMLProvidersResponse -> ShowS)
-> (ListSAMLProvidersResponse -> String)
-> ([ListSAMLProvidersResponse] -> ShowS)
-> Show ListSAMLProvidersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSAMLProvidersResponse] -> ShowS
$cshowList :: [ListSAMLProvidersResponse] -> ShowS
show :: ListSAMLProvidersResponse -> String
$cshow :: ListSAMLProvidersResponse -> String
showsPrec :: Int -> ListSAMLProvidersResponse -> ShowS
$cshowsPrec :: Int -> ListSAMLProvidersResponse -> ShowS
Prelude.Show, (forall x.
 ListSAMLProvidersResponse -> Rep ListSAMLProvidersResponse x)
-> (forall x.
    Rep ListSAMLProvidersResponse x -> ListSAMLProvidersResponse)
-> Generic ListSAMLProvidersResponse
forall x.
Rep ListSAMLProvidersResponse x -> ListSAMLProvidersResponse
forall x.
ListSAMLProvidersResponse -> Rep ListSAMLProvidersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListSAMLProvidersResponse x -> ListSAMLProvidersResponse
$cfrom :: forall x.
ListSAMLProvidersResponse -> Rep ListSAMLProvidersResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListSAMLProvidersResponse' 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:
--
-- 'sAMLProviderList', 'listSAMLProvidersResponse_sAMLProviderList' - The list of SAML provider resource objects defined in IAM for this
-- Amazon Web Services account.
--
-- 'httpStatus', 'listSAMLProvidersResponse_httpStatus' - The response's http status code.
newListSAMLProvidersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListSAMLProvidersResponse
newListSAMLProvidersResponse :: Int -> ListSAMLProvidersResponse
newListSAMLProvidersResponse Int
pHttpStatus_ =
  ListSAMLProvidersResponse' :: Maybe [SAMLProviderListEntry] -> Int -> ListSAMLProvidersResponse
ListSAMLProvidersResponse'
    { $sel:sAMLProviderList:ListSAMLProvidersResponse' :: Maybe [SAMLProviderListEntry]
sAMLProviderList =
        Maybe [SAMLProviderListEntry]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListSAMLProvidersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of SAML provider resource objects defined in IAM for this
-- Amazon Web Services account.
listSAMLProvidersResponse_sAMLProviderList :: Lens.Lens' ListSAMLProvidersResponse (Prelude.Maybe [SAMLProviderListEntry])
listSAMLProvidersResponse_sAMLProviderList :: (Maybe [SAMLProviderListEntry]
 -> f (Maybe [SAMLProviderListEntry]))
-> ListSAMLProvidersResponse -> f ListSAMLProvidersResponse
listSAMLProvidersResponse_sAMLProviderList = (ListSAMLProvidersResponse -> Maybe [SAMLProviderListEntry])
-> (ListSAMLProvidersResponse
    -> Maybe [SAMLProviderListEntry] -> ListSAMLProvidersResponse)
-> Lens
     ListSAMLProvidersResponse
     ListSAMLProvidersResponse
     (Maybe [SAMLProviderListEntry])
     (Maybe [SAMLProviderListEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSAMLProvidersResponse' {Maybe [SAMLProviderListEntry]
sAMLProviderList :: Maybe [SAMLProviderListEntry]
$sel:sAMLProviderList:ListSAMLProvidersResponse' :: ListSAMLProvidersResponse -> Maybe [SAMLProviderListEntry]
sAMLProviderList} -> Maybe [SAMLProviderListEntry]
sAMLProviderList) (\s :: ListSAMLProvidersResponse
s@ListSAMLProvidersResponse' {} Maybe [SAMLProviderListEntry]
a -> ListSAMLProvidersResponse
s {$sel:sAMLProviderList:ListSAMLProvidersResponse' :: Maybe [SAMLProviderListEntry]
sAMLProviderList = Maybe [SAMLProviderListEntry]
a} :: ListSAMLProvidersResponse) ((Maybe [SAMLProviderListEntry]
  -> f (Maybe [SAMLProviderListEntry]))
 -> ListSAMLProvidersResponse -> f ListSAMLProvidersResponse)
-> ((Maybe [SAMLProviderListEntry]
     -> f (Maybe [SAMLProviderListEntry]))
    -> Maybe [SAMLProviderListEntry]
    -> f (Maybe [SAMLProviderListEntry]))
-> (Maybe [SAMLProviderListEntry]
    -> f (Maybe [SAMLProviderListEntry]))
-> ListSAMLProvidersResponse
-> f ListSAMLProvidersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SAMLProviderListEntry]
  [SAMLProviderListEntry]
  [SAMLProviderListEntry]
  [SAMLProviderListEntry]
-> Iso
     (Maybe [SAMLProviderListEntry])
     (Maybe [SAMLProviderListEntry])
     (Maybe [SAMLProviderListEntry])
     (Maybe [SAMLProviderListEntry])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [SAMLProviderListEntry]
  [SAMLProviderListEntry]
  [SAMLProviderListEntry]
  [SAMLProviderListEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListSAMLProvidersResponse