{-# 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.GetUICustomization
-- 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 the user interface (UI) Customization information for a particular
-- app client\'s app UI, if any such information exists for the client. If
-- nothing is set for the particular client, but there is an existing pool
-- level customization (the app @clientId@ is @ALL@), then that information
-- is returned. If nothing is present, then an empty shape is returned.
module Amazonka.CognitoIdentityProvider.GetUICustomization
  ( -- * Creating a Request
    GetUICustomization (..),
    newGetUICustomization,

    -- * Request Lenses
    getUICustomization_clientId,
    getUICustomization_userPoolId,

    -- * Destructuring the Response
    GetUICustomizationResponse (..),
    newGetUICustomizationResponse,

    -- * Response Lenses
    getUICustomizationResponse_httpStatus,
    getUICustomizationResponse_uICustomization,
  )
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:/ 'newGetUICustomization' smart constructor.
data GetUICustomization = GetUICustomization'
  { -- | The client ID for the client app.
    GetUICustomization -> Maybe (Sensitive Text)
clientId :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The user pool ID for the user pool.
    GetUICustomization -> Text
userPoolId :: Prelude.Text
  }
  deriving (GetUICustomization -> GetUICustomization -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUICustomization -> GetUICustomization -> Bool
$c/= :: GetUICustomization -> GetUICustomization -> Bool
== :: GetUICustomization -> GetUICustomization -> Bool
$c== :: GetUICustomization -> GetUICustomization -> Bool
Prelude.Eq, Int -> GetUICustomization -> ShowS
[GetUICustomization] -> ShowS
GetUICustomization -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUICustomization] -> ShowS
$cshowList :: [GetUICustomization] -> ShowS
show :: GetUICustomization -> String
$cshow :: GetUICustomization -> String
showsPrec :: Int -> GetUICustomization -> ShowS
$cshowsPrec :: Int -> GetUICustomization -> ShowS
Prelude.Show, forall x. Rep GetUICustomization x -> GetUICustomization
forall x. GetUICustomization -> Rep GetUICustomization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUICustomization x -> GetUICustomization
$cfrom :: forall x. GetUICustomization -> Rep GetUICustomization x
Prelude.Generic)

-- |
-- Create a value of 'GetUICustomization' 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:
--
-- 'clientId', 'getUICustomization_clientId' - The client ID for the client app.
--
-- 'userPoolId', 'getUICustomization_userPoolId' - The user pool ID for the user pool.
newGetUICustomization ::
  -- | 'userPoolId'
  Prelude.Text ->
  GetUICustomization
newGetUICustomization :: Text -> GetUICustomization
newGetUICustomization Text
pUserPoolId_ =
  GetUICustomization'
    { $sel:clientId:GetUICustomization' :: Maybe (Sensitive Text)
clientId = forall a. Maybe a
Prelude.Nothing,
      $sel:userPoolId:GetUICustomization' :: Text
userPoolId = Text
pUserPoolId_
    }

-- | The client ID for the client app.
getUICustomization_clientId :: Lens.Lens' GetUICustomization (Prelude.Maybe Prelude.Text)
getUICustomization_clientId :: Lens' GetUICustomization (Maybe Text)
getUICustomization_clientId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUICustomization' {Maybe (Sensitive Text)
clientId :: Maybe (Sensitive Text)
$sel:clientId:GetUICustomization' :: GetUICustomization -> Maybe (Sensitive Text)
clientId} -> Maybe (Sensitive Text)
clientId) (\s :: GetUICustomization
s@GetUICustomization' {} Maybe (Sensitive Text)
a -> GetUICustomization
s {$sel:clientId:GetUICustomization' :: Maybe (Sensitive Text)
clientId = Maybe (Sensitive Text)
a} :: GetUICustomization) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The user pool ID for the user pool.
getUICustomization_userPoolId :: Lens.Lens' GetUICustomization Prelude.Text
getUICustomization_userPoolId :: Lens' GetUICustomization Text
getUICustomization_userPoolId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUICustomization' {Text
userPoolId :: Text
$sel:userPoolId:GetUICustomization' :: GetUICustomization -> Text
userPoolId} -> Text
userPoolId) (\s :: GetUICustomization
s@GetUICustomization' {} Text
a -> GetUICustomization
s {$sel:userPoolId:GetUICustomization' :: Text
userPoolId = Text
a} :: GetUICustomization)

instance Core.AWSRequest GetUICustomization where
  type
    AWSResponse GetUICustomization =
      GetUICustomizationResponse
  request :: (Service -> Service)
-> GetUICustomization -> Request GetUICustomization
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 GetUICustomization
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetUICustomization)))
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 ->
          Int -> UICustomizationType -> GetUICustomizationResponse
GetUICustomizationResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"UICustomization")
      )

instance Prelude.Hashable GetUICustomization where
  hashWithSalt :: Int -> GetUICustomization -> Int
hashWithSalt Int
_salt GetUICustomization' {Maybe (Sensitive Text)
Text
userPoolId :: Text
clientId :: Maybe (Sensitive Text)
$sel:userPoolId:GetUICustomization' :: GetUICustomization -> Text
$sel:clientId:GetUICustomization' :: GetUICustomization -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
clientId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userPoolId

instance Prelude.NFData GetUICustomization where
  rnf :: GetUICustomization -> ()
rnf GetUICustomization' {Maybe (Sensitive Text)
Text
userPoolId :: Text
clientId :: Maybe (Sensitive Text)
$sel:userPoolId:GetUICustomization' :: GetUICustomization -> Text
$sel:clientId:GetUICustomization' :: GetUICustomization -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
clientId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userPoolId

instance Data.ToHeaders GetUICustomization where
  toHeaders :: GetUICustomization -> 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.GetUICustomization" ::
                          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 GetUICustomization where
  toJSON :: GetUICustomization -> Value
toJSON GetUICustomization' {Maybe (Sensitive Text)
Text
userPoolId :: Text
clientId :: Maybe (Sensitive Text)
$sel:userPoolId:GetUICustomization' :: GetUICustomization -> Text
$sel:clientId:GetUICustomization' :: GetUICustomization -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ClientId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
clientId,
            forall a. a -> Maybe a
Prelude.Just (Key
"UserPoolId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userPoolId)
          ]
      )

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

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

-- | /See:/ 'newGetUICustomizationResponse' smart constructor.
data GetUICustomizationResponse = GetUICustomizationResponse'
  { -- | The response's http status code.
    GetUICustomizationResponse -> Int
httpStatus :: Prelude.Int,
    -- | The UI customization information.
    GetUICustomizationResponse -> UICustomizationType
uICustomization :: UICustomizationType
  }
  deriving (GetUICustomizationResponse -> GetUICustomizationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUICustomizationResponse -> GetUICustomizationResponse -> Bool
$c/= :: GetUICustomizationResponse -> GetUICustomizationResponse -> Bool
== :: GetUICustomizationResponse -> GetUICustomizationResponse -> Bool
$c== :: GetUICustomizationResponse -> GetUICustomizationResponse -> Bool
Prelude.Eq, Int -> GetUICustomizationResponse -> ShowS
[GetUICustomizationResponse] -> ShowS
GetUICustomizationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUICustomizationResponse] -> ShowS
$cshowList :: [GetUICustomizationResponse] -> ShowS
show :: GetUICustomizationResponse -> String
$cshow :: GetUICustomizationResponse -> String
showsPrec :: Int -> GetUICustomizationResponse -> ShowS
$cshowsPrec :: Int -> GetUICustomizationResponse -> ShowS
Prelude.Show, forall x.
Rep GetUICustomizationResponse x -> GetUICustomizationResponse
forall x.
GetUICustomizationResponse -> Rep GetUICustomizationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetUICustomizationResponse x -> GetUICustomizationResponse
$cfrom :: forall x.
GetUICustomizationResponse -> Rep GetUICustomizationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetUICustomizationResponse' 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:
--
-- 'httpStatus', 'getUICustomizationResponse_httpStatus' - The response's http status code.
--
-- 'uICustomization', 'getUICustomizationResponse_uICustomization' - The UI customization information.
newGetUICustomizationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'uICustomization'
  UICustomizationType ->
  GetUICustomizationResponse
newGetUICustomizationResponse :: Int -> UICustomizationType -> GetUICustomizationResponse
newGetUICustomizationResponse
  Int
pHttpStatus_
  UICustomizationType
pUICustomization_ =
    GetUICustomizationResponse'
      { $sel:httpStatus:GetUICustomizationResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:uICustomization:GetUICustomizationResponse' :: UICustomizationType
uICustomization = UICustomizationType
pUICustomization_
      }

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

-- | The UI customization information.
getUICustomizationResponse_uICustomization :: Lens.Lens' GetUICustomizationResponse UICustomizationType
getUICustomizationResponse_uICustomization :: Lens' GetUICustomizationResponse UICustomizationType
getUICustomizationResponse_uICustomization = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUICustomizationResponse' {UICustomizationType
uICustomization :: UICustomizationType
$sel:uICustomization:GetUICustomizationResponse' :: GetUICustomizationResponse -> UICustomizationType
uICustomization} -> UICustomizationType
uICustomization) (\s :: GetUICustomizationResponse
s@GetUICustomizationResponse' {} UICustomizationType
a -> GetUICustomizationResponse
s {$sel:uICustomization:GetUICustomizationResponse' :: UICustomizationType
uICustomization = UICustomizationType
a} :: GetUICustomizationResponse)

instance Prelude.NFData GetUICustomizationResponse where
  rnf :: GetUICustomizationResponse -> ()
rnf GetUICustomizationResponse' {Int
UICustomizationType
uICustomization :: UICustomizationType
httpStatus :: Int
$sel:uICustomization:GetUICustomizationResponse' :: GetUICustomizationResponse -> UICustomizationType
$sel:httpStatus:GetUICustomizationResponse' :: GetUICustomizationResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf UICustomizationType
uICustomization