{-# 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.CognitoIdentity.DescribeIdentityPool
-- 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)
--
-- Gets details about a particular identity pool, including the pool name,
-- ID description, creation date, and current number of users.
--
-- You must use AWS Developer credentials to call this API.
module Amazonka.CognitoIdentity.DescribeIdentityPool
  ( -- * Creating a Request
    DescribeIdentityPool (..),
    newDescribeIdentityPool,

    -- * Request Lenses
    describeIdentityPool_identityPoolId,

    -- * Destructuring the Response
    IdentityPool (..),
    newIdentityPool,

    -- * Response Lenses
    identityPool_samlProviderARNs,
    identityPool_supportedLoginProviders,
    identityPool_allowClassicFlow,
    identityPool_developerProviderName,
    identityPool_identityPoolTags,
    identityPool_openIdConnectProviderARNs,
    identityPool_cognitoIdentityProviders,
    identityPool_identityPoolId,
    identityPool_identityPoolName,
    identityPool_allowUnauthenticatedIdentities,
  )
where

import Amazonka.CognitoIdentity.Types
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

-- | Input to the DescribeIdentityPool action.
--
-- /See:/ 'newDescribeIdentityPool' smart constructor.
data DescribeIdentityPool = DescribeIdentityPool'
  { -- | An identity pool ID in the format REGION:GUID.
    DescribeIdentityPool -> Text
identityPoolId :: Prelude.Text
  }
  deriving (DescribeIdentityPool -> DescribeIdentityPool -> Bool
(DescribeIdentityPool -> DescribeIdentityPool -> Bool)
-> (DescribeIdentityPool -> DescribeIdentityPool -> Bool)
-> Eq DescribeIdentityPool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeIdentityPool -> DescribeIdentityPool -> Bool
$c/= :: DescribeIdentityPool -> DescribeIdentityPool -> Bool
== :: DescribeIdentityPool -> DescribeIdentityPool -> Bool
$c== :: DescribeIdentityPool -> DescribeIdentityPool -> Bool
Prelude.Eq, ReadPrec [DescribeIdentityPool]
ReadPrec DescribeIdentityPool
Int -> ReadS DescribeIdentityPool
ReadS [DescribeIdentityPool]
(Int -> ReadS DescribeIdentityPool)
-> ReadS [DescribeIdentityPool]
-> ReadPrec DescribeIdentityPool
-> ReadPrec [DescribeIdentityPool]
-> Read DescribeIdentityPool
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeIdentityPool]
$creadListPrec :: ReadPrec [DescribeIdentityPool]
readPrec :: ReadPrec DescribeIdentityPool
$creadPrec :: ReadPrec DescribeIdentityPool
readList :: ReadS [DescribeIdentityPool]
$creadList :: ReadS [DescribeIdentityPool]
readsPrec :: Int -> ReadS DescribeIdentityPool
$creadsPrec :: Int -> ReadS DescribeIdentityPool
Prelude.Read, Int -> DescribeIdentityPool -> ShowS
[DescribeIdentityPool] -> ShowS
DescribeIdentityPool -> String
(Int -> DescribeIdentityPool -> ShowS)
-> (DescribeIdentityPool -> String)
-> ([DescribeIdentityPool] -> ShowS)
-> Show DescribeIdentityPool
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeIdentityPool] -> ShowS
$cshowList :: [DescribeIdentityPool] -> ShowS
show :: DescribeIdentityPool -> String
$cshow :: DescribeIdentityPool -> String
showsPrec :: Int -> DescribeIdentityPool -> ShowS
$cshowsPrec :: Int -> DescribeIdentityPool -> ShowS
Prelude.Show, (forall x. DescribeIdentityPool -> Rep DescribeIdentityPool x)
-> (forall x. Rep DescribeIdentityPool x -> DescribeIdentityPool)
-> Generic DescribeIdentityPool
forall x. Rep DescribeIdentityPool x -> DescribeIdentityPool
forall x. DescribeIdentityPool -> Rep DescribeIdentityPool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeIdentityPool x -> DescribeIdentityPool
$cfrom :: forall x. DescribeIdentityPool -> Rep DescribeIdentityPool x
Prelude.Generic)

-- |
-- Create a value of 'DescribeIdentityPool' 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:
--
-- 'identityPoolId', 'describeIdentityPool_identityPoolId' - An identity pool ID in the format REGION:GUID.
newDescribeIdentityPool ::
  -- | 'identityPoolId'
  Prelude.Text ->
  DescribeIdentityPool
newDescribeIdentityPool :: Text -> DescribeIdentityPool
newDescribeIdentityPool Text
pIdentityPoolId_ =
  DescribeIdentityPool' :: Text -> DescribeIdentityPool
DescribeIdentityPool'
    { $sel:identityPoolId:DescribeIdentityPool' :: Text
identityPoolId =
        Text
pIdentityPoolId_
    }

-- | An identity pool ID in the format REGION:GUID.
describeIdentityPool_identityPoolId :: Lens.Lens' DescribeIdentityPool Prelude.Text
describeIdentityPool_identityPoolId :: (Text -> f Text) -> DescribeIdentityPool -> f DescribeIdentityPool
describeIdentityPool_identityPoolId = (DescribeIdentityPool -> Text)
-> (DescribeIdentityPool -> Text -> DescribeIdentityPool)
-> Lens DescribeIdentityPool DescribeIdentityPool Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIdentityPool' {Text
identityPoolId :: Text
$sel:identityPoolId:DescribeIdentityPool' :: DescribeIdentityPool -> Text
identityPoolId} -> Text
identityPoolId) (\s :: DescribeIdentityPool
s@DescribeIdentityPool' {} Text
a -> DescribeIdentityPool
s {$sel:identityPoolId:DescribeIdentityPool' :: Text
identityPoolId = Text
a} :: DescribeIdentityPool)

instance Core.AWSRequest DescribeIdentityPool where
  type AWSResponse DescribeIdentityPool = IdentityPool
  request :: DescribeIdentityPool -> Request DescribeIdentityPool
request = Service -> DescribeIdentityPool -> Request DescribeIdentityPool
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeIdentityPool
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeIdentityPool)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeIdentityPool))
-> Logger
-> Service
-> Proxy DescribeIdentityPool
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeIdentityPool)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String IdentityPool
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable DescribeIdentityPool

instance Prelude.NFData DescribeIdentityPool

instance Core.ToHeaders DescribeIdentityPool where
  toHeaders :: DescribeIdentityPool -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeIdentityPool -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSCognitoIdentityService.DescribeIdentityPool" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeIdentityPool where
  toJSON :: DescribeIdentityPool -> Value
toJSON DescribeIdentityPool' {Text
identityPoolId :: Text
$sel:identityPoolId:DescribeIdentityPool' :: DescribeIdentityPool -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"IdentityPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
identityPoolId)
          ]
      )

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

instance Core.ToQuery DescribeIdentityPool where
  toQuery :: DescribeIdentityPool -> QueryString
toQuery = QueryString -> DescribeIdentityPool -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty