{-# 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.CognitoIdentityProvider.DescribeUserPool
-- 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 the configuration information and metadata of the specified user
-- pool.
module Amazonka.CognitoIdentityProvider.DescribeUserPool
  ( -- * Creating a Request
    DescribeUserPool (..),
    newDescribeUserPool,

    -- * Request Lenses
    describeUserPool_userPoolId,

    -- * Destructuring the Response
    DescribeUserPoolResponse (..),
    newDescribeUserPoolResponse,

    -- * Response Lenses
    describeUserPoolResponse_userPool,
    describeUserPoolResponse_httpStatus,
  )
where

import Amazonka.CognitoIdentityProvider.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

-- | Represents the request to describe the user pool.
--
-- /See:/ 'newDescribeUserPool' smart constructor.
data DescribeUserPool = DescribeUserPool'
  { -- | The user pool ID for the user pool you want to describe.
    DescribeUserPool -> Text
userPoolId :: Prelude.Text
  }
  deriving (DescribeUserPool -> DescribeUserPool -> Bool
(DescribeUserPool -> DescribeUserPool -> Bool)
-> (DescribeUserPool -> DescribeUserPool -> Bool)
-> Eq DescribeUserPool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUserPool -> DescribeUserPool -> Bool
$c/= :: DescribeUserPool -> DescribeUserPool -> Bool
== :: DescribeUserPool -> DescribeUserPool -> Bool
$c== :: DescribeUserPool -> DescribeUserPool -> Bool
Prelude.Eq, ReadPrec [DescribeUserPool]
ReadPrec DescribeUserPool
Int -> ReadS DescribeUserPool
ReadS [DescribeUserPool]
(Int -> ReadS DescribeUserPool)
-> ReadS [DescribeUserPool]
-> ReadPrec DescribeUserPool
-> ReadPrec [DescribeUserPool]
-> Read DescribeUserPool
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeUserPool]
$creadListPrec :: ReadPrec [DescribeUserPool]
readPrec :: ReadPrec DescribeUserPool
$creadPrec :: ReadPrec DescribeUserPool
readList :: ReadS [DescribeUserPool]
$creadList :: ReadS [DescribeUserPool]
readsPrec :: Int -> ReadS DescribeUserPool
$creadsPrec :: Int -> ReadS DescribeUserPool
Prelude.Read, Int -> DescribeUserPool -> ShowS
[DescribeUserPool] -> ShowS
DescribeUserPool -> String
(Int -> DescribeUserPool -> ShowS)
-> (DescribeUserPool -> String)
-> ([DescribeUserPool] -> ShowS)
-> Show DescribeUserPool
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUserPool] -> ShowS
$cshowList :: [DescribeUserPool] -> ShowS
show :: DescribeUserPool -> String
$cshow :: DescribeUserPool -> String
showsPrec :: Int -> DescribeUserPool -> ShowS
$cshowsPrec :: Int -> DescribeUserPool -> ShowS
Prelude.Show, (forall x. DescribeUserPool -> Rep DescribeUserPool x)
-> (forall x. Rep DescribeUserPool x -> DescribeUserPool)
-> Generic DescribeUserPool
forall x. Rep DescribeUserPool x -> DescribeUserPool
forall x. DescribeUserPool -> Rep DescribeUserPool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeUserPool x -> DescribeUserPool
$cfrom :: forall x. DescribeUserPool -> Rep DescribeUserPool x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUserPool' 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:
--
-- 'userPoolId', 'describeUserPool_userPoolId' - The user pool ID for the user pool you want to describe.
newDescribeUserPool ::
  -- | 'userPoolId'
  Prelude.Text ->
  DescribeUserPool
newDescribeUserPool :: Text -> DescribeUserPool
newDescribeUserPool Text
pUserPoolId_ =
  DescribeUserPool' :: Text -> DescribeUserPool
DescribeUserPool' {$sel:userPoolId:DescribeUserPool' :: Text
userPoolId = Text
pUserPoolId_}

-- | The user pool ID for the user pool you want to describe.
describeUserPool_userPoolId :: Lens.Lens' DescribeUserPool Prelude.Text
describeUserPool_userPoolId :: (Text -> f Text) -> DescribeUserPool -> f DescribeUserPool
describeUserPool_userPoolId = (DescribeUserPool -> Text)
-> (DescribeUserPool -> Text -> DescribeUserPool)
-> Lens DescribeUserPool DescribeUserPool Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserPool' {Text
userPoolId :: Text
$sel:userPoolId:DescribeUserPool' :: DescribeUserPool -> Text
userPoolId} -> Text
userPoolId) (\s :: DescribeUserPool
s@DescribeUserPool' {} Text
a -> DescribeUserPool
s {$sel:userPoolId:DescribeUserPool' :: Text
userPoolId = Text
a} :: DescribeUserPool)

instance Core.AWSRequest DescribeUserPool where
  type
    AWSResponse DescribeUserPool =
      DescribeUserPoolResponse
  request :: DescribeUserPool -> Request DescribeUserPool
request = Service -> DescribeUserPool -> Request DescribeUserPool
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeUserPool
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeUserPool)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeUserPool))
-> Logger
-> Service
-> Proxy DescribeUserPool
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeUserPool)))
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 ->
          Maybe UserPoolType -> Int -> DescribeUserPoolResponse
DescribeUserPoolResponse'
            (Maybe UserPoolType -> Int -> DescribeUserPoolResponse)
-> Either String (Maybe UserPoolType)
-> Either String (Int -> DescribeUserPoolResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe UserPoolType)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"UserPool")
            Either String (Int -> DescribeUserPoolResponse)
-> Either String Int -> Either String DescribeUserPoolResponse
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 DescribeUserPool

instance Prelude.NFData DescribeUserPool

instance Core.ToHeaders DescribeUserPool where
  toHeaders :: DescribeUserPool -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeUserPool -> 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
"AWSCognitoIdentityProviderService.DescribeUserPool" ::
                          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 DescribeUserPool where
  toJSON :: DescribeUserPool -> Value
toJSON DescribeUserPool' {Text
userPoolId :: Text
$sel:userPoolId:DescribeUserPool' :: DescribeUserPool -> 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
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId)]
      )

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

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

-- | Represents the response to describe the user pool.
--
-- /See:/ 'newDescribeUserPoolResponse' smart constructor.
data DescribeUserPoolResponse = DescribeUserPoolResponse'
  { -- | The container of metadata returned by the server to describe the pool.
    DescribeUserPoolResponse -> Maybe UserPoolType
userPool :: Prelude.Maybe UserPoolType,
    -- | The response's http status code.
    DescribeUserPoolResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeUserPoolResponse -> DescribeUserPoolResponse -> Bool
(DescribeUserPoolResponse -> DescribeUserPoolResponse -> Bool)
-> (DescribeUserPoolResponse -> DescribeUserPoolResponse -> Bool)
-> Eq DescribeUserPoolResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUserPoolResponse -> DescribeUserPoolResponse -> Bool
$c/= :: DescribeUserPoolResponse -> DescribeUserPoolResponse -> Bool
== :: DescribeUserPoolResponse -> DescribeUserPoolResponse -> Bool
$c== :: DescribeUserPoolResponse -> DescribeUserPoolResponse -> Bool
Prelude.Eq, ReadPrec [DescribeUserPoolResponse]
ReadPrec DescribeUserPoolResponse
Int -> ReadS DescribeUserPoolResponse
ReadS [DescribeUserPoolResponse]
(Int -> ReadS DescribeUserPoolResponse)
-> ReadS [DescribeUserPoolResponse]
-> ReadPrec DescribeUserPoolResponse
-> ReadPrec [DescribeUserPoolResponse]
-> Read DescribeUserPoolResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeUserPoolResponse]
$creadListPrec :: ReadPrec [DescribeUserPoolResponse]
readPrec :: ReadPrec DescribeUserPoolResponse
$creadPrec :: ReadPrec DescribeUserPoolResponse
readList :: ReadS [DescribeUserPoolResponse]
$creadList :: ReadS [DescribeUserPoolResponse]
readsPrec :: Int -> ReadS DescribeUserPoolResponse
$creadsPrec :: Int -> ReadS DescribeUserPoolResponse
Prelude.Read, Int -> DescribeUserPoolResponse -> ShowS
[DescribeUserPoolResponse] -> ShowS
DescribeUserPoolResponse -> String
(Int -> DescribeUserPoolResponse -> ShowS)
-> (DescribeUserPoolResponse -> String)
-> ([DescribeUserPoolResponse] -> ShowS)
-> Show DescribeUserPoolResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUserPoolResponse] -> ShowS
$cshowList :: [DescribeUserPoolResponse] -> ShowS
show :: DescribeUserPoolResponse -> String
$cshow :: DescribeUserPoolResponse -> String
showsPrec :: Int -> DescribeUserPoolResponse -> ShowS
$cshowsPrec :: Int -> DescribeUserPoolResponse -> ShowS
Prelude.Show, (forall x.
 DescribeUserPoolResponse -> Rep DescribeUserPoolResponse x)
-> (forall x.
    Rep DescribeUserPoolResponse x -> DescribeUserPoolResponse)
-> Generic DescribeUserPoolResponse
forall x.
Rep DescribeUserPoolResponse x -> DescribeUserPoolResponse
forall x.
DescribeUserPoolResponse -> Rep DescribeUserPoolResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeUserPoolResponse x -> DescribeUserPoolResponse
$cfrom :: forall x.
DescribeUserPoolResponse -> Rep DescribeUserPoolResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUserPoolResponse' 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:
--
-- 'userPool', 'describeUserPoolResponse_userPool' - The container of metadata returned by the server to describe the pool.
--
-- 'httpStatus', 'describeUserPoolResponse_httpStatus' - The response's http status code.
newDescribeUserPoolResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeUserPoolResponse
newDescribeUserPoolResponse :: Int -> DescribeUserPoolResponse
newDescribeUserPoolResponse Int
pHttpStatus_ =
  DescribeUserPoolResponse' :: Maybe UserPoolType -> Int -> DescribeUserPoolResponse
DescribeUserPoolResponse'
    { $sel:userPool:DescribeUserPoolResponse' :: Maybe UserPoolType
userPool =
        Maybe UserPoolType
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeUserPoolResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The container of metadata returned by the server to describe the pool.
describeUserPoolResponse_userPool :: Lens.Lens' DescribeUserPoolResponse (Prelude.Maybe UserPoolType)
describeUserPoolResponse_userPool :: (Maybe UserPoolType -> f (Maybe UserPoolType))
-> DescribeUserPoolResponse -> f DescribeUserPoolResponse
describeUserPoolResponse_userPool = (DescribeUserPoolResponse -> Maybe UserPoolType)
-> (DescribeUserPoolResponse
    -> Maybe UserPoolType -> DescribeUserPoolResponse)
-> Lens
     DescribeUserPoolResponse
     DescribeUserPoolResponse
     (Maybe UserPoolType)
     (Maybe UserPoolType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserPoolResponse' {Maybe UserPoolType
userPool :: Maybe UserPoolType
$sel:userPool:DescribeUserPoolResponse' :: DescribeUserPoolResponse -> Maybe UserPoolType
userPool} -> Maybe UserPoolType
userPool) (\s :: DescribeUserPoolResponse
s@DescribeUserPoolResponse' {} Maybe UserPoolType
a -> DescribeUserPoolResponse
s {$sel:userPool:DescribeUserPoolResponse' :: Maybe UserPoolType
userPool = Maybe UserPoolType
a} :: DescribeUserPoolResponse)

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

instance Prelude.NFData DescribeUserPoolResponse