{-# 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.DescribeUserPoolDomain
-- 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 information about a domain.
module Amazonka.CognitoIdentityProvider.DescribeUserPoolDomain
  ( -- * Creating a Request
    DescribeUserPoolDomain (..),
    newDescribeUserPoolDomain,

    -- * Request Lenses
    describeUserPoolDomain_domain,

    -- * Destructuring the Response
    DescribeUserPoolDomainResponse (..),
    newDescribeUserPoolDomainResponse,

    -- * Response Lenses
    describeUserPoolDomainResponse_domainDescription,
    describeUserPoolDomainResponse_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

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

-- |
-- Create a value of 'DescribeUserPoolDomain' 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:
--
-- 'domain', 'describeUserPoolDomain_domain' - The domain string.
newDescribeUserPoolDomain ::
  -- | 'domain'
  Prelude.Text ->
  DescribeUserPoolDomain
newDescribeUserPoolDomain :: Text -> DescribeUserPoolDomain
newDescribeUserPoolDomain Text
pDomain_ =
  DescribeUserPoolDomain' :: Text -> DescribeUserPoolDomain
DescribeUserPoolDomain' {$sel:domain:DescribeUserPoolDomain' :: Text
domain = Text
pDomain_}

-- | The domain string.
describeUserPoolDomain_domain :: Lens.Lens' DescribeUserPoolDomain Prelude.Text
describeUserPoolDomain_domain :: (Text -> f Text)
-> DescribeUserPoolDomain -> f DescribeUserPoolDomain
describeUserPoolDomain_domain = (DescribeUserPoolDomain -> Text)
-> (DescribeUserPoolDomain -> Text -> DescribeUserPoolDomain)
-> Lens DescribeUserPoolDomain DescribeUserPoolDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserPoolDomain' {Text
domain :: Text
$sel:domain:DescribeUserPoolDomain' :: DescribeUserPoolDomain -> Text
domain} -> Text
domain) (\s :: DescribeUserPoolDomain
s@DescribeUserPoolDomain' {} Text
a -> DescribeUserPoolDomain
s {$sel:domain:DescribeUserPoolDomain' :: Text
domain = Text
a} :: DescribeUserPoolDomain)

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

instance Prelude.NFData DescribeUserPoolDomain

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

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

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

-- | /See:/ 'newDescribeUserPoolDomainResponse' smart constructor.
data DescribeUserPoolDomainResponse = DescribeUserPoolDomainResponse'
  { -- | A domain description object containing information about the domain.
    DescribeUserPoolDomainResponse -> Maybe DomainDescriptionType
domainDescription :: Prelude.Maybe DomainDescriptionType,
    -- | The response's http status code.
    DescribeUserPoolDomainResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeUserPoolDomainResponse
-> DescribeUserPoolDomainResponse -> Bool
(DescribeUserPoolDomainResponse
 -> DescribeUserPoolDomainResponse -> Bool)
-> (DescribeUserPoolDomainResponse
    -> DescribeUserPoolDomainResponse -> Bool)
-> Eq DescribeUserPoolDomainResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUserPoolDomainResponse
-> DescribeUserPoolDomainResponse -> Bool
$c/= :: DescribeUserPoolDomainResponse
-> DescribeUserPoolDomainResponse -> Bool
== :: DescribeUserPoolDomainResponse
-> DescribeUserPoolDomainResponse -> Bool
$c== :: DescribeUserPoolDomainResponse
-> DescribeUserPoolDomainResponse -> Bool
Prelude.Eq, ReadPrec [DescribeUserPoolDomainResponse]
ReadPrec DescribeUserPoolDomainResponse
Int -> ReadS DescribeUserPoolDomainResponse
ReadS [DescribeUserPoolDomainResponse]
(Int -> ReadS DescribeUserPoolDomainResponse)
-> ReadS [DescribeUserPoolDomainResponse]
-> ReadPrec DescribeUserPoolDomainResponse
-> ReadPrec [DescribeUserPoolDomainResponse]
-> Read DescribeUserPoolDomainResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeUserPoolDomainResponse]
$creadListPrec :: ReadPrec [DescribeUserPoolDomainResponse]
readPrec :: ReadPrec DescribeUserPoolDomainResponse
$creadPrec :: ReadPrec DescribeUserPoolDomainResponse
readList :: ReadS [DescribeUserPoolDomainResponse]
$creadList :: ReadS [DescribeUserPoolDomainResponse]
readsPrec :: Int -> ReadS DescribeUserPoolDomainResponse
$creadsPrec :: Int -> ReadS DescribeUserPoolDomainResponse
Prelude.Read, Int -> DescribeUserPoolDomainResponse -> ShowS
[DescribeUserPoolDomainResponse] -> ShowS
DescribeUserPoolDomainResponse -> String
(Int -> DescribeUserPoolDomainResponse -> ShowS)
-> (DescribeUserPoolDomainResponse -> String)
-> ([DescribeUserPoolDomainResponse] -> ShowS)
-> Show DescribeUserPoolDomainResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUserPoolDomainResponse] -> ShowS
$cshowList :: [DescribeUserPoolDomainResponse] -> ShowS
show :: DescribeUserPoolDomainResponse -> String
$cshow :: DescribeUserPoolDomainResponse -> String
showsPrec :: Int -> DescribeUserPoolDomainResponse -> ShowS
$cshowsPrec :: Int -> DescribeUserPoolDomainResponse -> ShowS
Prelude.Show, (forall x.
 DescribeUserPoolDomainResponse
 -> Rep DescribeUserPoolDomainResponse x)
-> (forall x.
    Rep DescribeUserPoolDomainResponse x
    -> DescribeUserPoolDomainResponse)
-> Generic DescribeUserPoolDomainResponse
forall x.
Rep DescribeUserPoolDomainResponse x
-> DescribeUserPoolDomainResponse
forall x.
DescribeUserPoolDomainResponse
-> Rep DescribeUserPoolDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeUserPoolDomainResponse x
-> DescribeUserPoolDomainResponse
$cfrom :: forall x.
DescribeUserPoolDomainResponse
-> Rep DescribeUserPoolDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUserPoolDomainResponse' 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:
--
-- 'domainDescription', 'describeUserPoolDomainResponse_domainDescription' - A domain description object containing information about the domain.
--
-- 'httpStatus', 'describeUserPoolDomainResponse_httpStatus' - The response's http status code.
newDescribeUserPoolDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeUserPoolDomainResponse
newDescribeUserPoolDomainResponse :: Int -> DescribeUserPoolDomainResponse
newDescribeUserPoolDomainResponse Int
pHttpStatus_ =
  DescribeUserPoolDomainResponse' :: Maybe DomainDescriptionType
-> Int -> DescribeUserPoolDomainResponse
DescribeUserPoolDomainResponse'
    { $sel:domainDescription:DescribeUserPoolDomainResponse' :: Maybe DomainDescriptionType
domainDescription =
        Maybe DomainDescriptionType
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeUserPoolDomainResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A domain description object containing information about the domain.
describeUserPoolDomainResponse_domainDescription :: Lens.Lens' DescribeUserPoolDomainResponse (Prelude.Maybe DomainDescriptionType)
describeUserPoolDomainResponse_domainDescription :: (Maybe DomainDescriptionType -> f (Maybe DomainDescriptionType))
-> DescribeUserPoolDomainResponse
-> f DescribeUserPoolDomainResponse
describeUserPoolDomainResponse_domainDescription = (DescribeUserPoolDomainResponse -> Maybe DomainDescriptionType)
-> (DescribeUserPoolDomainResponse
    -> Maybe DomainDescriptionType -> DescribeUserPoolDomainResponse)
-> Lens
     DescribeUserPoolDomainResponse
     DescribeUserPoolDomainResponse
     (Maybe DomainDescriptionType)
     (Maybe DomainDescriptionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserPoolDomainResponse' {Maybe DomainDescriptionType
domainDescription :: Maybe DomainDescriptionType
$sel:domainDescription:DescribeUserPoolDomainResponse' :: DescribeUserPoolDomainResponse -> Maybe DomainDescriptionType
domainDescription} -> Maybe DomainDescriptionType
domainDescription) (\s :: DescribeUserPoolDomainResponse
s@DescribeUserPoolDomainResponse' {} Maybe DomainDescriptionType
a -> DescribeUserPoolDomainResponse
s {$sel:domainDescription:DescribeUserPoolDomainResponse' :: Maybe DomainDescriptionType
domainDescription = Maybe DomainDescriptionType
a} :: DescribeUserPoolDomainResponse)

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

instance
  Prelude.NFData
    DescribeUserPoolDomainResponse