{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.ChallengeResponseType
-- 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)
module Amazonka.CognitoIdentityProvider.Types.ChallengeResponseType where

import Amazonka.CognitoIdentityProvider.Types.ChallengeName
import Amazonka.CognitoIdentityProvider.Types.ChallengeResponse
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The challenge response type.
--
-- /See:/ 'newChallengeResponseType' smart constructor.
data ChallengeResponseType = ChallengeResponseType'
  { -- | The challenge name
    ChallengeResponseType -> Maybe ChallengeName
challengeName :: Prelude.Maybe ChallengeName,
    -- | The challenge response.
    ChallengeResponseType -> Maybe ChallengeResponse
challengeResponse :: Prelude.Maybe ChallengeResponse
  }
  deriving (ChallengeResponseType -> ChallengeResponseType -> Bool
(ChallengeResponseType -> ChallengeResponseType -> Bool)
-> (ChallengeResponseType -> ChallengeResponseType -> Bool)
-> Eq ChallengeResponseType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChallengeResponseType -> ChallengeResponseType -> Bool
$c/= :: ChallengeResponseType -> ChallengeResponseType -> Bool
== :: ChallengeResponseType -> ChallengeResponseType -> Bool
$c== :: ChallengeResponseType -> ChallengeResponseType -> Bool
Prelude.Eq, ReadPrec [ChallengeResponseType]
ReadPrec ChallengeResponseType
Int -> ReadS ChallengeResponseType
ReadS [ChallengeResponseType]
(Int -> ReadS ChallengeResponseType)
-> ReadS [ChallengeResponseType]
-> ReadPrec ChallengeResponseType
-> ReadPrec [ChallengeResponseType]
-> Read ChallengeResponseType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChallengeResponseType]
$creadListPrec :: ReadPrec [ChallengeResponseType]
readPrec :: ReadPrec ChallengeResponseType
$creadPrec :: ReadPrec ChallengeResponseType
readList :: ReadS [ChallengeResponseType]
$creadList :: ReadS [ChallengeResponseType]
readsPrec :: Int -> ReadS ChallengeResponseType
$creadsPrec :: Int -> ReadS ChallengeResponseType
Prelude.Read, Int -> ChallengeResponseType -> ShowS
[ChallengeResponseType] -> ShowS
ChallengeResponseType -> String
(Int -> ChallengeResponseType -> ShowS)
-> (ChallengeResponseType -> String)
-> ([ChallengeResponseType] -> ShowS)
-> Show ChallengeResponseType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChallengeResponseType] -> ShowS
$cshowList :: [ChallengeResponseType] -> ShowS
show :: ChallengeResponseType -> String
$cshow :: ChallengeResponseType -> String
showsPrec :: Int -> ChallengeResponseType -> ShowS
$cshowsPrec :: Int -> ChallengeResponseType -> ShowS
Prelude.Show, (forall x. ChallengeResponseType -> Rep ChallengeResponseType x)
-> (forall x. Rep ChallengeResponseType x -> ChallengeResponseType)
-> Generic ChallengeResponseType
forall x. Rep ChallengeResponseType x -> ChallengeResponseType
forall x. ChallengeResponseType -> Rep ChallengeResponseType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChallengeResponseType x -> ChallengeResponseType
$cfrom :: forall x. ChallengeResponseType -> Rep ChallengeResponseType x
Prelude.Generic)

-- |
-- Create a value of 'ChallengeResponseType' 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:
--
-- 'challengeName', 'challengeResponseType_challengeName' - The challenge name
--
-- 'challengeResponse', 'challengeResponseType_challengeResponse' - The challenge response.
newChallengeResponseType ::
  ChallengeResponseType
newChallengeResponseType :: ChallengeResponseType
newChallengeResponseType =
  ChallengeResponseType' :: Maybe ChallengeName
-> Maybe ChallengeResponse -> ChallengeResponseType
ChallengeResponseType'
    { $sel:challengeName:ChallengeResponseType' :: Maybe ChallengeName
challengeName =
        Maybe ChallengeName
forall a. Maybe a
Prelude.Nothing,
      $sel:challengeResponse:ChallengeResponseType' :: Maybe ChallengeResponse
challengeResponse = Maybe ChallengeResponse
forall a. Maybe a
Prelude.Nothing
    }

-- | The challenge name
challengeResponseType_challengeName :: Lens.Lens' ChallengeResponseType (Prelude.Maybe ChallengeName)
challengeResponseType_challengeName :: (Maybe ChallengeName -> f (Maybe ChallengeName))
-> ChallengeResponseType -> f ChallengeResponseType
challengeResponseType_challengeName = (ChallengeResponseType -> Maybe ChallengeName)
-> (ChallengeResponseType
    -> Maybe ChallengeName -> ChallengeResponseType)
-> Lens
     ChallengeResponseType
     ChallengeResponseType
     (Maybe ChallengeName)
     (Maybe ChallengeName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChallengeResponseType' {Maybe ChallengeName
challengeName :: Maybe ChallengeName
$sel:challengeName:ChallengeResponseType' :: ChallengeResponseType -> Maybe ChallengeName
challengeName} -> Maybe ChallengeName
challengeName) (\s :: ChallengeResponseType
s@ChallengeResponseType' {} Maybe ChallengeName
a -> ChallengeResponseType
s {$sel:challengeName:ChallengeResponseType' :: Maybe ChallengeName
challengeName = Maybe ChallengeName
a} :: ChallengeResponseType)

-- | The challenge response.
challengeResponseType_challengeResponse :: Lens.Lens' ChallengeResponseType (Prelude.Maybe ChallengeResponse)
challengeResponseType_challengeResponse :: (Maybe ChallengeResponse -> f (Maybe ChallengeResponse))
-> ChallengeResponseType -> f ChallengeResponseType
challengeResponseType_challengeResponse = (ChallengeResponseType -> Maybe ChallengeResponse)
-> (ChallengeResponseType
    -> Maybe ChallengeResponse -> ChallengeResponseType)
-> Lens
     ChallengeResponseType
     ChallengeResponseType
     (Maybe ChallengeResponse)
     (Maybe ChallengeResponse)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChallengeResponseType' {Maybe ChallengeResponse
challengeResponse :: Maybe ChallengeResponse
$sel:challengeResponse:ChallengeResponseType' :: ChallengeResponseType -> Maybe ChallengeResponse
challengeResponse} -> Maybe ChallengeResponse
challengeResponse) (\s :: ChallengeResponseType
s@ChallengeResponseType' {} Maybe ChallengeResponse
a -> ChallengeResponseType
s {$sel:challengeResponse:ChallengeResponseType' :: Maybe ChallengeResponse
challengeResponse = Maybe ChallengeResponse
a} :: ChallengeResponseType)

instance Core.FromJSON ChallengeResponseType where
  parseJSON :: Value -> Parser ChallengeResponseType
parseJSON =
    String
-> (Object -> Parser ChallengeResponseType)
-> Value
-> Parser ChallengeResponseType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ChallengeResponseType"
      ( \Object
x ->
          Maybe ChallengeName
-> Maybe ChallengeResponse -> ChallengeResponseType
ChallengeResponseType'
            (Maybe ChallengeName
 -> Maybe ChallengeResponse -> ChallengeResponseType)
-> Parser (Maybe ChallengeName)
-> Parser (Maybe ChallengeResponse -> ChallengeResponseType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ChallengeName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ChallengeName")
            Parser (Maybe ChallengeResponse -> ChallengeResponseType)
-> Parser (Maybe ChallengeResponse) -> Parser ChallengeResponseType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ChallengeResponse)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ChallengeResponse")
      )

instance Prelude.Hashable ChallengeResponseType

instance Prelude.NFData ChallengeResponseType