{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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. For custom domains, this is the fully-qualified
    -- domain name, such as @auth.example.com@. For Amazon Cognito prefix
    -- domains, this is the prefix alone, such as @auth@.
    DescribeUserPoolDomain -> Text
domain :: Prelude.Text
  }
  deriving (DescribeUserPoolDomain -> DescribeUserPoolDomain -> Bool
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]
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
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. 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. For custom domains, this is the fully-qualified
-- domain name, such as @auth.example.com@. For Amazon Cognito prefix
-- domains, this is the prefix alone, such as @auth@.
newDescribeUserPoolDomain ::
  -- | 'domain'
  Prelude.Text ->
  DescribeUserPoolDomain
newDescribeUserPoolDomain :: Text -> DescribeUserPoolDomain
newDescribeUserPoolDomain Text
pDomain_ =
  DescribeUserPoolDomain' {$sel:domain:DescribeUserPoolDomain' :: Text
domain = Text
pDomain_}

-- | The domain string. For custom domains, this is the fully-qualified
-- domain name, such as @auth.example.com@. For Amazon Cognito prefix
-- domains, this is the prefix alone, such as @auth@.
describeUserPoolDomain_domain :: Lens.Lens' DescribeUserPoolDomain Prelude.Text
describeUserPoolDomain_domain :: Lens' DescribeUserPoolDomain Text
describeUserPoolDomain_domain = 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 :: (Service -> Service)
-> DescribeUserPoolDomain -> Request DescribeUserPoolDomain
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeUserPoolDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeUserPoolDomain)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DomainDescriptionType
-> Int -> DescribeUserPoolDomainResponse
DescribeUserPoolDomainResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"DomainDescription")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeUserPoolDomain where
  hashWithSalt :: Int -> DescribeUserPoolDomain -> Int
hashWithSalt Int
_salt DescribeUserPoolDomain' {Text
domain :: Text
$sel:domain:DescribeUserPoolDomain' :: DescribeUserPoolDomain -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domain

instance Prelude.NFData DescribeUserPoolDomain where
  rnf :: DescribeUserPoolDomain -> ()
rnf DescribeUserPoolDomain' {Text
domain :: Text
$sel:domain:DescribeUserPoolDomain' :: DescribeUserPoolDomain -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
domain

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

instance Data.ToJSON DescribeUserPoolDomain where
  toJSON :: DescribeUserPoolDomain -> Value
toJSON DescribeUserPoolDomain' {Text
domain :: Text
$sel:domain:DescribeUserPoolDomain' :: DescribeUserPoolDomain -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Domain" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
domain)]
      )

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

instance Data.ToQuery DescribeUserPoolDomain where
  toQuery :: DescribeUserPoolDomain -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:domainDescription:DescribeUserPoolDomainResponse' :: Maybe DomainDescriptionType
domainDescription =
        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 :: Lens' DescribeUserPoolDomainResponse (Maybe DomainDescriptionType)
describeUserPoolDomainResponse_domainDescription = 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 :: Lens' DescribeUserPoolDomainResponse Int
describeUserPoolDomainResponse_httpStatus = 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
  where
  rnf :: DescribeUserPoolDomainResponse -> ()
rnf DescribeUserPoolDomainResponse' {Int
Maybe DomainDescriptionType
httpStatus :: Int
domainDescription :: Maybe DomainDescriptionType
$sel:httpStatus:DescribeUserPoolDomainResponse' :: DescribeUserPoolDomainResponse -> Int
$sel:domainDescription:DescribeUserPoolDomainResponse' :: DescribeUserPoolDomainResponse -> Maybe DomainDescriptionType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DomainDescriptionType
domainDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus