{-# 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.CognitoIdentity.Types.IdentityDescription
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CognitoIdentity.Types.IdentityDescription where

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

-- | A description of the identity.
--
-- /See:/ 'newIdentityDescription' smart constructor.
data IdentityDescription = IdentityDescription'
  { -- | Date on which the identity was created.
    IdentityDescription -> Maybe POSIX
creationDate :: Prelude.Maybe Data.POSIX,
    -- | A unique identifier in the format REGION:GUID.
    IdentityDescription -> Maybe Text
identityId :: Prelude.Maybe Prelude.Text,
    -- | Date on which the identity was last modified.
    IdentityDescription -> Maybe POSIX
lastModifiedDate :: Prelude.Maybe Data.POSIX,
    -- | The provider names.
    IdentityDescription -> Maybe [Text]
logins :: Prelude.Maybe [Prelude.Text]
  }
  deriving (IdentityDescription -> IdentityDescription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IdentityDescription -> IdentityDescription -> Bool
$c/= :: IdentityDescription -> IdentityDescription -> Bool
== :: IdentityDescription -> IdentityDescription -> Bool
$c== :: IdentityDescription -> IdentityDescription -> Bool
Prelude.Eq, ReadPrec [IdentityDescription]
ReadPrec IdentityDescription
Int -> ReadS IdentityDescription
ReadS [IdentityDescription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IdentityDescription]
$creadListPrec :: ReadPrec [IdentityDescription]
readPrec :: ReadPrec IdentityDescription
$creadPrec :: ReadPrec IdentityDescription
readList :: ReadS [IdentityDescription]
$creadList :: ReadS [IdentityDescription]
readsPrec :: Int -> ReadS IdentityDescription
$creadsPrec :: Int -> ReadS IdentityDescription
Prelude.Read, Int -> IdentityDescription -> ShowS
[IdentityDescription] -> ShowS
IdentityDescription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdentityDescription] -> ShowS
$cshowList :: [IdentityDescription] -> ShowS
show :: IdentityDescription -> String
$cshow :: IdentityDescription -> String
showsPrec :: Int -> IdentityDescription -> ShowS
$cshowsPrec :: Int -> IdentityDescription -> ShowS
Prelude.Show, forall x. Rep IdentityDescription x -> IdentityDescription
forall x. IdentityDescription -> Rep IdentityDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IdentityDescription x -> IdentityDescription
$cfrom :: forall x. IdentityDescription -> Rep IdentityDescription x
Prelude.Generic)

-- |
-- Create a value of 'IdentityDescription' 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:
--
-- 'creationDate', 'identityDescription_creationDate' - Date on which the identity was created.
--
-- 'identityId', 'identityDescription_identityId' - A unique identifier in the format REGION:GUID.
--
-- 'lastModifiedDate', 'identityDescription_lastModifiedDate' - Date on which the identity was last modified.
--
-- 'logins', 'identityDescription_logins' - The provider names.
newIdentityDescription ::
  IdentityDescription
newIdentityDescription :: IdentityDescription
newIdentityDescription =
  IdentityDescription'
    { $sel:creationDate:IdentityDescription' :: Maybe POSIX
creationDate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:identityId:IdentityDescription' :: Maybe Text
identityId = forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedDate:IdentityDescription' :: Maybe POSIX
lastModifiedDate = forall a. Maybe a
Prelude.Nothing,
      $sel:logins:IdentityDescription' :: Maybe [Text]
logins = forall a. Maybe a
Prelude.Nothing
    }

-- | Date on which the identity was created.
identityDescription_creationDate :: Lens.Lens' IdentityDescription (Prelude.Maybe Prelude.UTCTime)
identityDescription_creationDate :: Lens' IdentityDescription (Maybe UTCTime)
identityDescription_creationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDescription' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:IdentityDescription' :: IdentityDescription -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: IdentityDescription
s@IdentityDescription' {} Maybe POSIX
a -> IdentityDescription
s {$sel:creationDate:IdentityDescription' :: Maybe POSIX
creationDate = Maybe POSIX
a} :: IdentityDescription) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A unique identifier in the format REGION:GUID.
identityDescription_identityId :: Lens.Lens' IdentityDescription (Prelude.Maybe Prelude.Text)
identityDescription_identityId :: Lens' IdentityDescription (Maybe Text)
identityDescription_identityId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDescription' {Maybe Text
identityId :: Maybe Text
$sel:identityId:IdentityDescription' :: IdentityDescription -> Maybe Text
identityId} -> Maybe Text
identityId) (\s :: IdentityDescription
s@IdentityDescription' {} Maybe Text
a -> IdentityDescription
s {$sel:identityId:IdentityDescription' :: Maybe Text
identityId = Maybe Text
a} :: IdentityDescription)

-- | Date on which the identity was last modified.
identityDescription_lastModifiedDate :: Lens.Lens' IdentityDescription (Prelude.Maybe Prelude.UTCTime)
identityDescription_lastModifiedDate :: Lens' IdentityDescription (Maybe UTCTime)
identityDescription_lastModifiedDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDescription' {Maybe POSIX
lastModifiedDate :: Maybe POSIX
$sel:lastModifiedDate:IdentityDescription' :: IdentityDescription -> Maybe POSIX
lastModifiedDate} -> Maybe POSIX
lastModifiedDate) (\s :: IdentityDescription
s@IdentityDescription' {} Maybe POSIX
a -> IdentityDescription
s {$sel:lastModifiedDate:IdentityDescription' :: Maybe POSIX
lastModifiedDate = Maybe POSIX
a} :: IdentityDescription) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The provider names.
identityDescription_logins :: Lens.Lens' IdentityDescription (Prelude.Maybe [Prelude.Text])
identityDescription_logins :: Lens' IdentityDescription (Maybe [Text])
identityDescription_logins = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityDescription' {Maybe [Text]
logins :: Maybe [Text]
$sel:logins:IdentityDescription' :: IdentityDescription -> Maybe [Text]
logins} -> Maybe [Text]
logins) (\s :: IdentityDescription
s@IdentityDescription' {} Maybe [Text]
a -> IdentityDescription
s {$sel:logins:IdentityDescription' :: Maybe [Text]
logins = Maybe [Text]
a} :: IdentityDescription) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON IdentityDescription where
  parseJSON :: Value -> Parser IdentityDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IdentityDescription"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text -> Maybe POSIX -> Maybe [Text] -> IdentityDescription
IdentityDescription'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreationDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IdentityId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LastModifiedDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Logins" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable IdentityDescription where
  hashWithSalt :: Int -> IdentityDescription -> Int
hashWithSalt Int
_salt IdentityDescription' {Maybe [Text]
Maybe Text
Maybe POSIX
logins :: Maybe [Text]
lastModifiedDate :: Maybe POSIX
identityId :: Maybe Text
creationDate :: Maybe POSIX
$sel:logins:IdentityDescription' :: IdentityDescription -> Maybe [Text]
$sel:lastModifiedDate:IdentityDescription' :: IdentityDescription -> Maybe POSIX
$sel:identityId:IdentityDescription' :: IdentityDescription -> Maybe Text
$sel:creationDate:IdentityDescription' :: IdentityDescription -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
identityId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastModifiedDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
logins

instance Prelude.NFData IdentityDescription where
  rnf :: IdentityDescription -> ()
rnf IdentityDescription' {Maybe [Text]
Maybe Text
Maybe POSIX
logins :: Maybe [Text]
lastModifiedDate :: Maybe POSIX
identityId :: Maybe Text
creationDate :: Maybe POSIX
$sel:logins:IdentityDescription' :: IdentityDescription -> Maybe [Text]
$sel:lastModifiedDate:IdentityDescription' :: IdentityDescription -> Maybe POSIX
$sel:identityId:IdentityDescription' :: IdentityDescription -> Maybe Text
$sel:creationDate:IdentityDescription' :: IdentityDescription -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
identityId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastModifiedDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
logins