{-# 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.DescribeRiskConfiguration
-- 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)
--
-- Describes the risk configuration.
module Amazonka.CognitoIdentityProvider.DescribeRiskConfiguration
  ( -- * Creating a Request
    DescribeRiskConfiguration (..),
    newDescribeRiskConfiguration,

    -- * Request Lenses
    describeRiskConfiguration_clientId,
    describeRiskConfiguration_userPoolId,

    -- * Destructuring the Response
    DescribeRiskConfigurationResponse (..),
    newDescribeRiskConfigurationResponse,

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

-- |
-- Create a value of 'DescribeRiskConfiguration' 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', 'describeRiskConfiguration_clientId' - The app client ID.
--
-- 'userPoolId', 'describeRiskConfiguration_userPoolId' - The user pool ID.
newDescribeRiskConfiguration ::
  -- | 'userPoolId'
  Prelude.Text ->
  DescribeRiskConfiguration
newDescribeRiskConfiguration :: Text -> DescribeRiskConfiguration
newDescribeRiskConfiguration Text
pUserPoolId_ =
  DescribeRiskConfiguration' :: Maybe (Sensitive Text) -> Text -> DescribeRiskConfiguration
DescribeRiskConfiguration'
    { $sel:clientId:DescribeRiskConfiguration' :: Maybe (Sensitive Text)
clientId =
        Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:userPoolId:DescribeRiskConfiguration' :: Text
userPoolId = Text
pUserPoolId_
    }

-- | The app client ID.
describeRiskConfiguration_clientId :: Lens.Lens' DescribeRiskConfiguration (Prelude.Maybe Prelude.Text)
describeRiskConfiguration_clientId :: (Maybe Text -> f (Maybe Text))
-> DescribeRiskConfiguration -> f DescribeRiskConfiguration
describeRiskConfiguration_clientId = (DescribeRiskConfiguration -> Maybe (Sensitive Text))
-> (DescribeRiskConfiguration
    -> Maybe (Sensitive Text) -> DescribeRiskConfiguration)
-> Lens
     DescribeRiskConfiguration
     DescribeRiskConfiguration
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRiskConfiguration' {Maybe (Sensitive Text)
clientId :: Maybe (Sensitive Text)
$sel:clientId:DescribeRiskConfiguration' :: DescribeRiskConfiguration -> Maybe (Sensitive Text)
clientId} -> Maybe (Sensitive Text)
clientId) (\s :: DescribeRiskConfiguration
s@DescribeRiskConfiguration' {} Maybe (Sensitive Text)
a -> DescribeRiskConfiguration
s {$sel:clientId:DescribeRiskConfiguration' :: Maybe (Sensitive Text)
clientId = Maybe (Sensitive Text)
a} :: DescribeRiskConfiguration) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DescribeRiskConfiguration -> f DescribeRiskConfiguration)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DescribeRiskConfiguration
-> f DescribeRiskConfiguration
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.
describeRiskConfiguration_userPoolId :: Lens.Lens' DescribeRiskConfiguration Prelude.Text
describeRiskConfiguration_userPoolId :: (Text -> f Text)
-> DescribeRiskConfiguration -> f DescribeRiskConfiguration
describeRiskConfiguration_userPoolId = (DescribeRiskConfiguration -> Text)
-> (DescribeRiskConfiguration -> Text -> DescribeRiskConfiguration)
-> Lens
     DescribeRiskConfiguration DescribeRiskConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRiskConfiguration' {Text
userPoolId :: Text
$sel:userPoolId:DescribeRiskConfiguration' :: DescribeRiskConfiguration -> Text
userPoolId} -> Text
userPoolId) (\s :: DescribeRiskConfiguration
s@DescribeRiskConfiguration' {} Text
a -> DescribeRiskConfiguration
s {$sel:userPoolId:DescribeRiskConfiguration' :: Text
userPoolId = Text
a} :: DescribeRiskConfiguration)

instance Core.AWSRequest DescribeRiskConfiguration where
  type
    AWSResponse DescribeRiskConfiguration =
      DescribeRiskConfigurationResponse
  request :: DescribeRiskConfiguration -> Request DescribeRiskConfiguration
request = Service
-> DescribeRiskConfiguration -> Request DescribeRiskConfiguration
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeRiskConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRiskConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeRiskConfiguration))
-> Logger
-> Service
-> Proxy DescribeRiskConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeRiskConfiguration)))
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 -> RiskConfigurationType -> DescribeRiskConfigurationResponse
DescribeRiskConfigurationResponse'
            (Int -> RiskConfigurationType -> DescribeRiskConfigurationResponse)
-> Either String Int
-> Either
     String (RiskConfigurationType -> DescribeRiskConfigurationResponse)
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 (RiskConfigurationType -> DescribeRiskConfigurationResponse)
-> Either String RiskConfigurationType
-> Either String DescribeRiskConfigurationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String RiskConfigurationType
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"RiskConfiguration")
      )

instance Prelude.Hashable DescribeRiskConfiguration

instance Prelude.NFData DescribeRiskConfiguration

instance Core.ToHeaders DescribeRiskConfiguration where
  toHeaders :: DescribeRiskConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeRiskConfiguration -> 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.DescribeRiskConfiguration" ::
                          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 DescribeRiskConfiguration where
  toJSON :: DescribeRiskConfiguration -> Value
toJSON DescribeRiskConfiguration' {Maybe (Sensitive Text)
Text
userPoolId :: Text
clientId :: Maybe (Sensitive Text)
$sel:userPoolId:DescribeRiskConfiguration' :: DescribeRiskConfiguration -> Text
$sel:clientId:DescribeRiskConfiguration' :: DescribeRiskConfiguration -> 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 DescribeRiskConfiguration where
  toPath :: DescribeRiskConfiguration -> ByteString
toPath = ByteString -> DescribeRiskConfiguration -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeRiskConfigurationResponse' smart constructor.
data DescribeRiskConfigurationResponse = DescribeRiskConfigurationResponse'
  { -- | The response's http status code.
    DescribeRiskConfigurationResponse -> Int
httpStatus :: Prelude.Int,
    -- | The risk configuration.
    DescribeRiskConfigurationResponse -> RiskConfigurationType
riskConfiguration :: RiskConfigurationType
  }
  deriving (DescribeRiskConfigurationResponse
-> DescribeRiskConfigurationResponse -> Bool
(DescribeRiskConfigurationResponse
 -> DescribeRiskConfigurationResponse -> Bool)
-> (DescribeRiskConfigurationResponse
    -> DescribeRiskConfigurationResponse -> Bool)
-> Eq DescribeRiskConfigurationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRiskConfigurationResponse
-> DescribeRiskConfigurationResponse -> Bool
$c/= :: DescribeRiskConfigurationResponse
-> DescribeRiskConfigurationResponse -> Bool
== :: DescribeRiskConfigurationResponse
-> DescribeRiskConfigurationResponse -> Bool
$c== :: DescribeRiskConfigurationResponse
-> DescribeRiskConfigurationResponse -> Bool
Prelude.Eq, Int -> DescribeRiskConfigurationResponse -> ShowS
[DescribeRiskConfigurationResponse] -> ShowS
DescribeRiskConfigurationResponse -> String
(Int -> DescribeRiskConfigurationResponse -> ShowS)
-> (DescribeRiskConfigurationResponse -> String)
-> ([DescribeRiskConfigurationResponse] -> ShowS)
-> Show DescribeRiskConfigurationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRiskConfigurationResponse] -> ShowS
$cshowList :: [DescribeRiskConfigurationResponse] -> ShowS
show :: DescribeRiskConfigurationResponse -> String
$cshow :: DescribeRiskConfigurationResponse -> String
showsPrec :: Int -> DescribeRiskConfigurationResponse -> ShowS
$cshowsPrec :: Int -> DescribeRiskConfigurationResponse -> ShowS
Prelude.Show, (forall x.
 DescribeRiskConfigurationResponse
 -> Rep DescribeRiskConfigurationResponse x)
-> (forall x.
    Rep DescribeRiskConfigurationResponse x
    -> DescribeRiskConfigurationResponse)
-> Generic DescribeRiskConfigurationResponse
forall x.
Rep DescribeRiskConfigurationResponse x
-> DescribeRiskConfigurationResponse
forall x.
DescribeRiskConfigurationResponse
-> Rep DescribeRiskConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeRiskConfigurationResponse x
-> DescribeRiskConfigurationResponse
$cfrom :: forall x.
DescribeRiskConfigurationResponse
-> Rep DescribeRiskConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRiskConfigurationResponse' 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', 'describeRiskConfigurationResponse_httpStatus' - The response's http status code.
--
-- 'riskConfiguration', 'describeRiskConfigurationResponse_riskConfiguration' - The risk configuration.
newDescribeRiskConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'riskConfiguration'
  RiskConfigurationType ->
  DescribeRiskConfigurationResponse
newDescribeRiskConfigurationResponse :: Int -> RiskConfigurationType -> DescribeRiskConfigurationResponse
newDescribeRiskConfigurationResponse
  Int
pHttpStatus_
  RiskConfigurationType
pRiskConfiguration_ =
    DescribeRiskConfigurationResponse' :: Int -> RiskConfigurationType -> DescribeRiskConfigurationResponse
DescribeRiskConfigurationResponse'
      { $sel:httpStatus:DescribeRiskConfigurationResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:riskConfiguration:DescribeRiskConfigurationResponse' :: RiskConfigurationType
riskConfiguration = RiskConfigurationType
pRiskConfiguration_
      }

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

-- | The risk configuration.
describeRiskConfigurationResponse_riskConfiguration :: Lens.Lens' DescribeRiskConfigurationResponse RiskConfigurationType
describeRiskConfigurationResponse_riskConfiguration :: (RiskConfigurationType -> f RiskConfigurationType)
-> DescribeRiskConfigurationResponse
-> f DescribeRiskConfigurationResponse
describeRiskConfigurationResponse_riskConfiguration = (DescribeRiskConfigurationResponse -> RiskConfigurationType)
-> (DescribeRiskConfigurationResponse
    -> RiskConfigurationType -> DescribeRiskConfigurationResponse)
-> Lens
     DescribeRiskConfigurationResponse
     DescribeRiskConfigurationResponse
     RiskConfigurationType
     RiskConfigurationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRiskConfigurationResponse' {RiskConfigurationType
riskConfiguration :: RiskConfigurationType
$sel:riskConfiguration:DescribeRiskConfigurationResponse' :: DescribeRiskConfigurationResponse -> RiskConfigurationType
riskConfiguration} -> RiskConfigurationType
riskConfiguration) (\s :: DescribeRiskConfigurationResponse
s@DescribeRiskConfigurationResponse' {} RiskConfigurationType
a -> DescribeRiskConfigurationResponse
s {$sel:riskConfiguration:DescribeRiskConfigurationResponse' :: RiskConfigurationType
riskConfiguration = RiskConfigurationType
a} :: DescribeRiskConfigurationResponse)

instance
  Prelude.NFData
    DescribeRiskConfigurationResponse