{-# 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-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.CognitoIdentity.Types.IdentityDescription where

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

-- | A description of the identity.
--
-- /See:/ 'newIdentityDescription' smart constructor.
data IdentityDescription = IdentityDescription'
  { -- | Date on which the identity was last modified.
    IdentityDescription -> Maybe POSIX
lastModifiedDate :: Prelude.Maybe Core.POSIX,
    -- | Date on which the identity was created.
    IdentityDescription -> Maybe POSIX
creationDate :: Prelude.Maybe Core.POSIX,
    -- | The provider names.
    IdentityDescription -> Maybe [Text]
logins :: Prelude.Maybe [Prelude.Text],
    -- | A unique identifier in the format REGION:GUID.
    IdentityDescription -> Maybe Text
identityId :: Prelude.Maybe Prelude.Text
  }
  deriving (IdentityDescription -> IdentityDescription -> Bool
(IdentityDescription -> IdentityDescription -> Bool)
-> (IdentityDescription -> IdentityDescription -> Bool)
-> Eq IdentityDescription
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]
(Int -> ReadS IdentityDescription)
-> ReadS [IdentityDescription]
-> ReadPrec IdentityDescription
-> ReadPrec [IdentityDescription]
-> Read 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
(Int -> IdentityDescription -> ShowS)
-> (IdentityDescription -> String)
-> ([IdentityDescription] -> ShowS)
-> Show IdentityDescription
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. IdentityDescription -> Rep IdentityDescription x)
-> (forall x. Rep IdentityDescription x -> IdentityDescription)
-> Generic IdentityDescription
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:
--
-- 'lastModifiedDate', 'identityDescription_lastModifiedDate' - Date on which the identity was last modified.
--
-- 'creationDate', 'identityDescription_creationDate' - Date on which the identity was created.
--
-- 'logins', 'identityDescription_logins' - The provider names.
--
-- 'identityId', 'identityDescription_identityId' - A unique identifier in the format REGION:GUID.
newIdentityDescription ::
  IdentityDescription
newIdentityDescription :: IdentityDescription
newIdentityDescription =
  IdentityDescription' :: Maybe POSIX
-> Maybe POSIX -> Maybe [Text] -> Maybe Text -> IdentityDescription
IdentityDescription'
    { $sel:lastModifiedDate:IdentityDescription' :: Maybe POSIX
lastModifiedDate =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:IdentityDescription' :: Maybe POSIX
creationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:logins:IdentityDescription' :: Maybe [Text]
logins = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:identityId:IdentityDescription' :: Maybe Text
identityId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Date on which the identity was last modified.
identityDescription_lastModifiedDate :: Lens.Lens' IdentityDescription (Prelude.Maybe Prelude.UTCTime)
identityDescription_lastModifiedDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> IdentityDescription -> f IdentityDescription
identityDescription_lastModifiedDate = (IdentityDescription -> Maybe POSIX)
-> (IdentityDescription -> Maybe POSIX -> IdentityDescription)
-> Lens
     IdentityDescription IdentityDescription (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> IdentityDescription -> f IdentityDescription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> IdentityDescription
-> f IdentityDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Date on which the identity was created.
identityDescription_creationDate :: Lens.Lens' IdentityDescription (Prelude.Maybe Prelude.UTCTime)
identityDescription_creationDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> IdentityDescription -> f IdentityDescription
identityDescription_creationDate = (IdentityDescription -> Maybe POSIX)
-> (IdentityDescription -> Maybe POSIX -> IdentityDescription)
-> Lens
     IdentityDescription IdentityDescription (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> IdentityDescription -> f IdentityDescription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> IdentityDescription
-> f IdentityDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The provider names.
identityDescription_logins :: Lens.Lens' IdentityDescription (Prelude.Maybe [Prelude.Text])
identityDescription_logins :: (Maybe [Text] -> f (Maybe [Text]))
-> IdentityDescription -> f IdentityDescription
identityDescription_logins = (IdentityDescription -> Maybe [Text])
-> (IdentityDescription -> Maybe [Text] -> IdentityDescription)
-> Lens
     IdentityDescription
     IdentityDescription
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> IdentityDescription -> f IdentityDescription)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> IdentityDescription
-> f IdentityDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A unique identifier in the format REGION:GUID.
identityDescription_identityId :: Lens.Lens' IdentityDescription (Prelude.Maybe Prelude.Text)
identityDescription_identityId :: (Maybe Text -> f (Maybe Text))
-> IdentityDescription -> f IdentityDescription
identityDescription_identityId = (IdentityDescription -> Maybe Text)
-> (IdentityDescription -> Maybe Text -> IdentityDescription)
-> Lens
     IdentityDescription IdentityDescription (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable IdentityDescription

instance Prelude.NFData IdentityDescription