{-# 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.DynamoDBStreams.Types.Identity
-- 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.DynamoDBStreams.Types.Identity where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains details about the type of identity that made the request.
--
-- /See:/ 'newIdentity' smart constructor.
data Identity = Identity'
  { -- | A unique identifier for the entity that made the call. For Time To Live,
    -- the principalId is \"dynamodb.amazonaws.com\".
    Identity -> Maybe Text
principalId :: Prelude.Maybe Prelude.Text,
    -- | The type of the identity. For Time To Live, the type is \"Service\".
    Identity -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (Identity -> Identity -> Bool
(Identity -> Identity -> Bool)
-> (Identity -> Identity -> Bool) -> Eq Identity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Identity -> Identity -> Bool
$c/= :: Identity -> Identity -> Bool
== :: Identity -> Identity -> Bool
$c== :: Identity -> Identity -> Bool
Prelude.Eq, ReadPrec [Identity]
ReadPrec Identity
Int -> ReadS Identity
ReadS [Identity]
(Int -> ReadS Identity)
-> ReadS [Identity]
-> ReadPrec Identity
-> ReadPrec [Identity]
-> Read Identity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Identity]
$creadListPrec :: ReadPrec [Identity]
readPrec :: ReadPrec Identity
$creadPrec :: ReadPrec Identity
readList :: ReadS [Identity]
$creadList :: ReadS [Identity]
readsPrec :: Int -> ReadS Identity
$creadsPrec :: Int -> ReadS Identity
Prelude.Read, Int -> Identity -> ShowS
[Identity] -> ShowS
Identity -> String
(Int -> Identity -> ShowS)
-> (Identity -> String) -> ([Identity] -> ShowS) -> Show Identity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Identity] -> ShowS
$cshowList :: [Identity] -> ShowS
show :: Identity -> String
$cshow :: Identity -> String
showsPrec :: Int -> Identity -> ShowS
$cshowsPrec :: Int -> Identity -> ShowS
Prelude.Show, (forall x. Identity -> Rep Identity x)
-> (forall x. Rep Identity x -> Identity) -> Generic Identity
forall x. Rep Identity x -> Identity
forall x. Identity -> Rep Identity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Identity x -> Identity
$cfrom :: forall x. Identity -> Rep Identity x
Prelude.Generic)

-- |
-- Create a value of 'Identity' 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:
--
-- 'principalId', 'identity_principalId' - A unique identifier for the entity that made the call. For Time To Live,
-- the principalId is \"dynamodb.amazonaws.com\".
--
-- 'type'', 'identity_type' - The type of the identity. For Time To Live, the type is \"Service\".
newIdentity ::
  Identity
newIdentity :: Identity
newIdentity =
  Identity' :: Maybe Text -> Maybe Text -> Identity
Identity'
    { $sel:principalId:Identity' :: Maybe Text
principalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Identity' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A unique identifier for the entity that made the call. For Time To Live,
-- the principalId is \"dynamodb.amazonaws.com\".
identity_principalId :: Lens.Lens' Identity (Prelude.Maybe Prelude.Text)
identity_principalId :: (Maybe Text -> f (Maybe Text)) -> Identity -> f Identity
identity_principalId = (Identity -> Maybe Text)
-> (Identity -> Maybe Text -> Identity)
-> Lens Identity Identity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Identity' {Maybe Text
principalId :: Maybe Text
$sel:principalId:Identity' :: Identity -> Maybe Text
principalId} -> Maybe Text
principalId) (\s :: Identity
s@Identity' {} Maybe Text
a -> Identity
s {$sel:principalId:Identity' :: Maybe Text
principalId = Maybe Text
a} :: Identity)

-- | The type of the identity. For Time To Live, the type is \"Service\".
identity_type :: Lens.Lens' Identity (Prelude.Maybe Prelude.Text)
identity_type :: (Maybe Text -> f (Maybe Text)) -> Identity -> f Identity
identity_type = (Identity -> Maybe Text)
-> (Identity -> Maybe Text -> Identity)
-> Lens Identity Identity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Identity' {Maybe Text
type' :: Maybe Text
$sel:type':Identity' :: Identity -> Maybe Text
type'} -> Maybe Text
type') (\s :: Identity
s@Identity' {} Maybe Text
a -> Identity
s {$sel:type':Identity' :: Maybe Text
type' = Maybe Text
a} :: Identity)

instance Core.FromJSON Identity where
  parseJSON :: Value -> Parser Identity
parseJSON =
    String -> (Object -> Parser Identity) -> Value -> Parser Identity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Identity"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Identity
Identity'
            (Maybe Text -> Maybe Text -> Identity)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Identity)
forall (f :: * -> *) a b. Functor 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
"PrincipalId")
            Parser (Maybe Text -> Identity)
-> Parser (Maybe Text) -> Parser Identity
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
"Type")
      )

instance Prelude.Hashable Identity

instance Prelude.NFData Identity