{-# 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.AuthenticationResultType
-- 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.AuthenticationResultType where

import Amazonka.CognitoIdentityProvider.Types.NewDeviceMetadataType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The authentication result.
--
-- /See:/ 'newAuthenticationResultType' smart constructor.
data AuthenticationResultType = AuthenticationResultType'
  { -- | The access token.
    AuthenticationResultType -> Maybe (Sensitive Text)
accessToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The refresh token.
    AuthenticationResultType -> Maybe (Sensitive Text)
refreshToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The new device metadata from an authentication result.
    AuthenticationResultType -> Maybe NewDeviceMetadataType
newDeviceMetadata' :: Prelude.Maybe NewDeviceMetadataType,
    -- | The expiration period of the authentication result in seconds.
    AuthenticationResultType -> Maybe Int
expiresIn :: Prelude.Maybe Prelude.Int,
    -- | The token type.
    AuthenticationResultType -> Maybe Text
tokenType :: Prelude.Maybe Prelude.Text,
    -- | The ID token.
    AuthenticationResultType -> Maybe (Sensitive Text)
idToken :: Prelude.Maybe (Core.Sensitive Prelude.Text)
  }
  deriving (AuthenticationResultType -> AuthenticationResultType -> Bool
(AuthenticationResultType -> AuthenticationResultType -> Bool)
-> (AuthenticationResultType -> AuthenticationResultType -> Bool)
-> Eq AuthenticationResultType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthenticationResultType -> AuthenticationResultType -> Bool
$c/= :: AuthenticationResultType -> AuthenticationResultType -> Bool
== :: AuthenticationResultType -> AuthenticationResultType -> Bool
$c== :: AuthenticationResultType -> AuthenticationResultType -> Bool
Prelude.Eq, Int -> AuthenticationResultType -> ShowS
[AuthenticationResultType] -> ShowS
AuthenticationResultType -> String
(Int -> AuthenticationResultType -> ShowS)
-> (AuthenticationResultType -> String)
-> ([AuthenticationResultType] -> ShowS)
-> Show AuthenticationResultType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuthenticationResultType] -> ShowS
$cshowList :: [AuthenticationResultType] -> ShowS
show :: AuthenticationResultType -> String
$cshow :: AuthenticationResultType -> String
showsPrec :: Int -> AuthenticationResultType -> ShowS
$cshowsPrec :: Int -> AuthenticationResultType -> ShowS
Prelude.Show, (forall x.
 AuthenticationResultType -> Rep AuthenticationResultType x)
-> (forall x.
    Rep AuthenticationResultType x -> AuthenticationResultType)
-> Generic AuthenticationResultType
forall x.
Rep AuthenticationResultType x -> AuthenticationResultType
forall x.
AuthenticationResultType -> Rep AuthenticationResultType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AuthenticationResultType x -> AuthenticationResultType
$cfrom :: forall x.
AuthenticationResultType -> Rep AuthenticationResultType x
Prelude.Generic)

-- |
-- Create a value of 'AuthenticationResultType' 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:
--
-- 'accessToken', 'authenticationResultType_accessToken' - The access token.
--
-- 'refreshToken', 'authenticationResultType_refreshToken' - The refresh token.
--
-- 'newDeviceMetadata'', 'authenticationResultType_newDeviceMetadata' - The new device metadata from an authentication result.
--
-- 'expiresIn', 'authenticationResultType_expiresIn' - The expiration period of the authentication result in seconds.
--
-- 'tokenType', 'authenticationResultType_tokenType' - The token type.
--
-- 'idToken', 'authenticationResultType_idToken' - The ID token.
newAuthenticationResultType ::
  AuthenticationResultType
newAuthenticationResultType :: AuthenticationResultType
newAuthenticationResultType =
  AuthenticationResultType' :: Maybe (Sensitive Text)
-> Maybe (Sensitive Text)
-> Maybe NewDeviceMetadataType
-> Maybe Int
-> Maybe Text
-> Maybe (Sensitive Text)
-> AuthenticationResultType
AuthenticationResultType'
    { $sel:accessToken:AuthenticationResultType' :: Maybe (Sensitive Text)
accessToken =
        Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:refreshToken:AuthenticationResultType' :: Maybe (Sensitive Text)
refreshToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:newDeviceMetadata':AuthenticationResultType' :: Maybe NewDeviceMetadataType
newDeviceMetadata' = Maybe NewDeviceMetadataType
forall a. Maybe a
Prelude.Nothing,
      $sel:expiresIn:AuthenticationResultType' :: Maybe Int
expiresIn = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:tokenType:AuthenticationResultType' :: Maybe Text
tokenType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:idToken:AuthenticationResultType' :: Maybe (Sensitive Text)
idToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The access token.
authenticationResultType_accessToken :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Text)
authenticationResultType_accessToken :: (Maybe Text -> f (Maybe Text))
-> AuthenticationResultType -> f AuthenticationResultType
authenticationResultType_accessToken = (AuthenticationResultType -> Maybe (Sensitive Text))
-> (AuthenticationResultType
    -> Maybe (Sensitive Text) -> AuthenticationResultType)
-> Lens
     AuthenticationResultType
     AuthenticationResultType
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe (Sensitive Text)
accessToken :: Maybe (Sensitive Text)
$sel:accessToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
accessToken} -> Maybe (Sensitive Text)
accessToken) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe (Sensitive Text)
a -> AuthenticationResultType
s {$sel:accessToken:AuthenticationResultType' :: Maybe (Sensitive Text)
accessToken = Maybe (Sensitive Text)
a} :: AuthenticationResultType) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> AuthenticationResultType -> f AuthenticationResultType)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> AuthenticationResultType
-> f AuthenticationResultType
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 refresh token.
authenticationResultType_refreshToken :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Text)
authenticationResultType_refreshToken :: (Maybe Text -> f (Maybe Text))
-> AuthenticationResultType -> f AuthenticationResultType
authenticationResultType_refreshToken = (AuthenticationResultType -> Maybe (Sensitive Text))
-> (AuthenticationResultType
    -> Maybe (Sensitive Text) -> AuthenticationResultType)
-> Lens
     AuthenticationResultType
     AuthenticationResultType
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe (Sensitive Text)
refreshToken :: Maybe (Sensitive Text)
$sel:refreshToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
refreshToken} -> Maybe (Sensitive Text)
refreshToken) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe (Sensitive Text)
a -> AuthenticationResultType
s {$sel:refreshToken:AuthenticationResultType' :: Maybe (Sensitive Text)
refreshToken = Maybe (Sensitive Text)
a} :: AuthenticationResultType) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> AuthenticationResultType -> f AuthenticationResultType)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> AuthenticationResultType
-> f AuthenticationResultType
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 new device metadata from an authentication result.
authenticationResultType_newDeviceMetadata :: Lens.Lens' AuthenticationResultType (Prelude.Maybe NewDeviceMetadataType)
authenticationResultType_newDeviceMetadata :: (Maybe NewDeviceMetadataType -> f (Maybe NewDeviceMetadataType))
-> AuthenticationResultType -> f AuthenticationResultType
authenticationResultType_newDeviceMetadata = (AuthenticationResultType -> Maybe NewDeviceMetadataType)
-> (AuthenticationResultType
    -> Maybe NewDeviceMetadataType -> AuthenticationResultType)
-> Lens
     AuthenticationResultType
     AuthenticationResultType
     (Maybe NewDeviceMetadataType)
     (Maybe NewDeviceMetadataType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe NewDeviceMetadataType
newDeviceMetadata' :: Maybe NewDeviceMetadataType
$sel:newDeviceMetadata':AuthenticationResultType' :: AuthenticationResultType -> Maybe NewDeviceMetadataType
newDeviceMetadata'} -> Maybe NewDeviceMetadataType
newDeviceMetadata') (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe NewDeviceMetadataType
a -> AuthenticationResultType
s {$sel:newDeviceMetadata':AuthenticationResultType' :: Maybe NewDeviceMetadataType
newDeviceMetadata' = Maybe NewDeviceMetadataType
a} :: AuthenticationResultType)

-- | The expiration period of the authentication result in seconds.
authenticationResultType_expiresIn :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Int)
authenticationResultType_expiresIn :: (Maybe Int -> f (Maybe Int))
-> AuthenticationResultType -> f AuthenticationResultType
authenticationResultType_expiresIn = (AuthenticationResultType -> Maybe Int)
-> (AuthenticationResultType
    -> Maybe Int -> AuthenticationResultType)
-> Lens
     AuthenticationResultType
     AuthenticationResultType
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe Int
expiresIn :: Maybe Int
$sel:expiresIn:AuthenticationResultType' :: AuthenticationResultType -> Maybe Int
expiresIn} -> Maybe Int
expiresIn) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe Int
a -> AuthenticationResultType
s {$sel:expiresIn:AuthenticationResultType' :: Maybe Int
expiresIn = Maybe Int
a} :: AuthenticationResultType)

-- | The token type.
authenticationResultType_tokenType :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Text)
authenticationResultType_tokenType :: (Maybe Text -> f (Maybe Text))
-> AuthenticationResultType -> f AuthenticationResultType
authenticationResultType_tokenType = (AuthenticationResultType -> Maybe Text)
-> (AuthenticationResultType
    -> Maybe Text -> AuthenticationResultType)
-> Lens
     AuthenticationResultType
     AuthenticationResultType
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe Text
tokenType :: Maybe Text
$sel:tokenType:AuthenticationResultType' :: AuthenticationResultType -> Maybe Text
tokenType} -> Maybe Text
tokenType) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe Text
a -> AuthenticationResultType
s {$sel:tokenType:AuthenticationResultType' :: Maybe Text
tokenType = Maybe Text
a} :: AuthenticationResultType)

-- | The ID token.
authenticationResultType_idToken :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Text)
authenticationResultType_idToken :: (Maybe Text -> f (Maybe Text))
-> AuthenticationResultType -> f AuthenticationResultType
authenticationResultType_idToken = (AuthenticationResultType -> Maybe (Sensitive Text))
-> (AuthenticationResultType
    -> Maybe (Sensitive Text) -> AuthenticationResultType)
-> Lens
     AuthenticationResultType
     AuthenticationResultType
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe (Sensitive Text)
idToken :: Maybe (Sensitive Text)
$sel:idToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
idToken} -> Maybe (Sensitive Text)
idToken) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe (Sensitive Text)
a -> AuthenticationResultType
s {$sel:idToken:AuthenticationResultType' :: Maybe (Sensitive Text)
idToken = Maybe (Sensitive Text)
a} :: AuthenticationResultType) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> AuthenticationResultType -> f AuthenticationResultType)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> AuthenticationResultType
-> f AuthenticationResultType
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

instance Core.FromJSON AuthenticationResultType where
  parseJSON :: Value -> Parser AuthenticationResultType
parseJSON =
    String
-> (Object -> Parser AuthenticationResultType)
-> Value
-> Parser AuthenticationResultType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AuthenticationResultType"
      ( \Object
x ->
          Maybe (Sensitive Text)
-> Maybe (Sensitive Text)
-> Maybe NewDeviceMetadataType
-> Maybe Int
-> Maybe Text
-> Maybe (Sensitive Text)
-> AuthenticationResultType
AuthenticationResultType'
            (Maybe (Sensitive Text)
 -> Maybe (Sensitive Text)
 -> Maybe NewDeviceMetadataType
 -> Maybe Int
 -> Maybe Text
 -> Maybe (Sensitive Text)
 -> AuthenticationResultType)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe NewDeviceMetadataType
      -> Maybe Int
      -> Maybe Text
      -> Maybe (Sensitive Text)
      -> AuthenticationResultType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AccessToken")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe NewDeviceMetadataType
   -> Maybe Int
   -> Maybe Text
   -> Maybe (Sensitive Text)
   -> AuthenticationResultType)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe NewDeviceMetadataType
      -> Maybe Int
      -> Maybe Text
      -> Maybe (Sensitive Text)
      -> AuthenticationResultType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RefreshToken")
            Parser
  (Maybe NewDeviceMetadataType
   -> Maybe Int
   -> Maybe Text
   -> Maybe (Sensitive Text)
   -> AuthenticationResultType)
-> Parser (Maybe NewDeviceMetadataType)
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe (Sensitive Text)
      -> AuthenticationResultType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NewDeviceMetadataType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NewDeviceMetadata")
            Parser
  (Maybe Int
   -> Maybe Text
   -> Maybe (Sensitive Text)
   -> AuthenticationResultType)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text -> Maybe (Sensitive Text) -> AuthenticationResultType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ExpiresIn")
            Parser
  (Maybe Text -> Maybe (Sensitive Text) -> AuthenticationResultType)
-> Parser (Maybe Text)
-> Parser (Maybe (Sensitive Text) -> AuthenticationResultType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TokenType")
            Parser (Maybe (Sensitive Text) -> AuthenticationResultType)
-> Parser (Maybe (Sensitive Text))
-> Parser AuthenticationResultType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IdToken")
      )

instance Prelude.Hashable AuthenticationResultType

instance Prelude.NFData AuthenticationResultType