{-# 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-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 the UI Customization information for a particular app client\'s app
-- UI, if there is something set. If nothing is set for the particular
-- client, but there is an existing pool level customization (app
-- @clientId@ will be @ALL@), then that 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.Lens as Lens
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 (Core.Sensitive Prelude.Text),
    -- | The user pool ID for the user pool.
    GetUICustomization -> Text
userPoolId :: Prelude.Text
  }
  deriving (GetUICustomization -> GetUICustomization -> Bool
(GetUICustomization -> GetUICustomization -> Bool)
-> (GetUICustomization -> GetUICustomization -> Bool)
-> Eq GetUICustomization
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
(Int -> GetUICustomization -> ShowS)
-> (GetUICustomization -> String)
-> ([GetUICustomization] -> ShowS)
-> Show GetUICustomization
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. GetUICustomization -> Rep GetUICustomization x)
-> (forall x. Rep GetUICustomization x -> GetUICustomization)
-> Generic GetUICustomization
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' :: Maybe (Sensitive Text) -> Text -> GetUICustomization
GetUICustomization'
    { $sel:clientId:GetUICustomization' :: Maybe (Sensitive Text)
clientId = Maybe (Sensitive Text)
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 :: (Maybe Text -> f (Maybe Text))
-> GetUICustomization -> f GetUICustomization
getUICustomization_clientId = (GetUICustomization -> Maybe (Sensitive Text))
-> (GetUICustomization
    -> Maybe (Sensitive Text) -> GetUICustomization)
-> Lens
     GetUICustomization
     GetUICustomization
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
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) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> GetUICustomization -> f GetUICustomization)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> GetUICustomization
-> f GetUICustomization
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The user pool ID for the user pool.
getUICustomization_userPoolId :: Lens.Lens' GetUICustomization Prelude.Text
getUICustomization_userPoolId :: (Text -> f Text) -> GetUICustomization -> f GetUICustomization
getUICustomization_userPoolId = (GetUICustomization -> Text)
-> (GetUICustomization -> Text -> GetUICustomization)
-> Lens GetUICustomization GetUICustomization Text Text
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 :: GetUICustomization -> Request GetUICustomization
request = Service -> GetUICustomization -> Request GetUICustomization
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetUICustomization
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetUICustomization)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetUICustomization))
-> Logger
-> Service
-> Proxy GetUICustomization
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetUICustomization)))
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 ->
          Int -> UICustomizationType -> GetUICustomizationResponse
GetUICustomizationResponse'
            (Int -> UICustomizationType -> GetUICustomizationResponse)
-> Either String Int
-> Either
     String (UICustomizationType -> GetUICustomizationResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (UICustomizationType -> GetUICustomizationResponse)
-> Either String UICustomizationType
-> Either String GetUICustomizationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String UICustomizationType
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"UICustomization")
      )

instance Prelude.Hashable GetUICustomization

instance Prelude.NFData GetUICustomization

instance Core.ToHeaders GetUICustomization where
  toHeaders :: GetUICustomization -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetUICustomization -> 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.GetUICustomization" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ClientId" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
clientId,
            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 GetUICustomization where
  toPath :: GetUICustomization -> ByteString
toPath = ByteString -> GetUICustomization -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery GetUICustomization where
  toQuery :: GetUICustomization -> QueryString
toQuery = QueryString -> GetUICustomization -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetUICustomizationResponse -> GetUICustomizationResponse -> Bool)
-> (GetUICustomizationResponse
    -> GetUICustomizationResponse -> Bool)
-> Eq GetUICustomizationResponse
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
(Int -> GetUICustomizationResponse -> ShowS)
-> (GetUICustomizationResponse -> String)
-> ([GetUICustomizationResponse] -> ShowS)
-> Show GetUICustomizationResponse
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.
 GetUICustomizationResponse -> Rep GetUICustomizationResponse x)
-> (forall x.
    Rep GetUICustomizationResponse x -> GetUICustomizationResponse)
-> Generic GetUICustomizationResponse
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' :: Int -> UICustomizationType -> GetUICustomizationResponse
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 :: (Int -> f Int)
-> GetUICustomizationResponse -> f GetUICustomizationResponse
getUICustomizationResponse_httpStatus = (GetUICustomizationResponse -> Int)
-> (GetUICustomizationResponse
    -> Int -> GetUICustomizationResponse)
-> Lens
     GetUICustomizationResponse GetUICustomizationResponse Int Int
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 :: (UICustomizationType -> f UICustomizationType)
-> GetUICustomizationResponse -> f GetUICustomizationResponse
getUICustomizationResponse_uICustomization = (GetUICustomizationResponse -> UICustomizationType)
-> (GetUICustomizationResponse
    -> UICustomizationType -> GetUICustomizationResponse)
-> Lens
     GetUICustomizationResponse
     GetUICustomizationResponse
     UICustomizationType
     UICustomizationType
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