{-# 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.WorkMail.Types.ImpersonationRole
-- 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.WorkMail.Types.ImpersonationRole 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
import Amazonka.WorkMail.Types.ImpersonationRoleType

-- | An impersonation role for the given WorkMail organization.
--
-- /See:/ 'newImpersonationRole' smart constructor.
data ImpersonationRole = ImpersonationRole'
  { -- | The date when the impersonation role was created.
    ImpersonationRole -> Maybe POSIX
dateCreated :: Prelude.Maybe Data.POSIX,
    -- | The date when the impersonation role was last modified.
    ImpersonationRole -> Maybe POSIX
dateModified :: Prelude.Maybe Data.POSIX,
    -- | The identifier of the impersonation role.
    ImpersonationRole -> Maybe Text
impersonationRoleId :: Prelude.Maybe Prelude.Text,
    -- | The impersonation role name.
    ImpersonationRole -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The impersonation role type.
    ImpersonationRole -> Maybe ImpersonationRoleType
type' :: Prelude.Maybe ImpersonationRoleType
  }
  deriving (ImpersonationRole -> ImpersonationRole -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImpersonationRole -> ImpersonationRole -> Bool
$c/= :: ImpersonationRole -> ImpersonationRole -> Bool
== :: ImpersonationRole -> ImpersonationRole -> Bool
$c== :: ImpersonationRole -> ImpersonationRole -> Bool
Prelude.Eq, ReadPrec [ImpersonationRole]
ReadPrec ImpersonationRole
Int -> ReadS ImpersonationRole
ReadS [ImpersonationRole]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImpersonationRole]
$creadListPrec :: ReadPrec [ImpersonationRole]
readPrec :: ReadPrec ImpersonationRole
$creadPrec :: ReadPrec ImpersonationRole
readList :: ReadS [ImpersonationRole]
$creadList :: ReadS [ImpersonationRole]
readsPrec :: Int -> ReadS ImpersonationRole
$creadsPrec :: Int -> ReadS ImpersonationRole
Prelude.Read, Int -> ImpersonationRole -> ShowS
[ImpersonationRole] -> ShowS
ImpersonationRole -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImpersonationRole] -> ShowS
$cshowList :: [ImpersonationRole] -> ShowS
show :: ImpersonationRole -> String
$cshow :: ImpersonationRole -> String
showsPrec :: Int -> ImpersonationRole -> ShowS
$cshowsPrec :: Int -> ImpersonationRole -> ShowS
Prelude.Show, forall x. Rep ImpersonationRole x -> ImpersonationRole
forall x. ImpersonationRole -> Rep ImpersonationRole x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImpersonationRole x -> ImpersonationRole
$cfrom :: forall x. ImpersonationRole -> Rep ImpersonationRole x
Prelude.Generic)

-- |
-- Create a value of 'ImpersonationRole' 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:
--
-- 'dateCreated', 'impersonationRole_dateCreated' - The date when the impersonation role was created.
--
-- 'dateModified', 'impersonationRole_dateModified' - The date when the impersonation role was last modified.
--
-- 'impersonationRoleId', 'impersonationRole_impersonationRoleId' - The identifier of the impersonation role.
--
-- 'name', 'impersonationRole_name' - The impersonation role name.
--
-- 'type'', 'impersonationRole_type' - The impersonation role type.
newImpersonationRole ::
  ImpersonationRole
newImpersonationRole :: ImpersonationRole
newImpersonationRole =
  ImpersonationRole'
    { $sel:dateCreated:ImpersonationRole' :: Maybe POSIX
dateCreated = forall a. Maybe a
Prelude.Nothing,
      $sel:dateModified:ImpersonationRole' :: Maybe POSIX
dateModified = forall a. Maybe a
Prelude.Nothing,
      $sel:impersonationRoleId:ImpersonationRole' :: Maybe Text
impersonationRoleId = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ImpersonationRole' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ImpersonationRole' :: Maybe ImpersonationRoleType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The date when the impersonation role was created.
impersonationRole_dateCreated :: Lens.Lens' ImpersonationRole (Prelude.Maybe Prelude.UTCTime)
impersonationRole_dateCreated :: Lens' ImpersonationRole (Maybe UTCTime)
impersonationRole_dateCreated = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRole' {Maybe POSIX
dateCreated :: Maybe POSIX
$sel:dateCreated:ImpersonationRole' :: ImpersonationRole -> Maybe POSIX
dateCreated} -> Maybe POSIX
dateCreated) (\s :: ImpersonationRole
s@ImpersonationRole' {} Maybe POSIX
a -> ImpersonationRole
s {$sel:dateCreated:ImpersonationRole' :: Maybe POSIX
dateCreated = Maybe POSIX
a} :: ImpersonationRole) 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 date when the impersonation role was last modified.
impersonationRole_dateModified :: Lens.Lens' ImpersonationRole (Prelude.Maybe Prelude.UTCTime)
impersonationRole_dateModified :: Lens' ImpersonationRole (Maybe UTCTime)
impersonationRole_dateModified = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRole' {Maybe POSIX
dateModified :: Maybe POSIX
$sel:dateModified:ImpersonationRole' :: ImpersonationRole -> Maybe POSIX
dateModified} -> Maybe POSIX
dateModified) (\s :: ImpersonationRole
s@ImpersonationRole' {} Maybe POSIX
a -> ImpersonationRole
s {$sel:dateModified:ImpersonationRole' :: Maybe POSIX
dateModified = Maybe POSIX
a} :: ImpersonationRole) 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 identifier of the impersonation role.
impersonationRole_impersonationRoleId :: Lens.Lens' ImpersonationRole (Prelude.Maybe Prelude.Text)
impersonationRole_impersonationRoleId :: Lens' ImpersonationRole (Maybe Text)
impersonationRole_impersonationRoleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRole' {Maybe Text
impersonationRoleId :: Maybe Text
$sel:impersonationRoleId:ImpersonationRole' :: ImpersonationRole -> Maybe Text
impersonationRoleId} -> Maybe Text
impersonationRoleId) (\s :: ImpersonationRole
s@ImpersonationRole' {} Maybe Text
a -> ImpersonationRole
s {$sel:impersonationRoleId:ImpersonationRole' :: Maybe Text
impersonationRoleId = Maybe Text
a} :: ImpersonationRole)

-- | The impersonation role name.
impersonationRole_name :: Lens.Lens' ImpersonationRole (Prelude.Maybe Prelude.Text)
impersonationRole_name :: Lens' ImpersonationRole (Maybe Text)
impersonationRole_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRole' {Maybe Text
name :: Maybe Text
$sel:name:ImpersonationRole' :: ImpersonationRole -> Maybe Text
name} -> Maybe Text
name) (\s :: ImpersonationRole
s@ImpersonationRole' {} Maybe Text
a -> ImpersonationRole
s {$sel:name:ImpersonationRole' :: Maybe Text
name = Maybe Text
a} :: ImpersonationRole)

-- | The impersonation role type.
impersonationRole_type :: Lens.Lens' ImpersonationRole (Prelude.Maybe ImpersonationRoleType)
impersonationRole_type :: Lens' ImpersonationRole (Maybe ImpersonationRoleType)
impersonationRole_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImpersonationRole' {Maybe ImpersonationRoleType
type' :: Maybe ImpersonationRoleType
$sel:type':ImpersonationRole' :: ImpersonationRole -> Maybe ImpersonationRoleType
type'} -> Maybe ImpersonationRoleType
type') (\s :: ImpersonationRole
s@ImpersonationRole' {} Maybe ImpersonationRoleType
a -> ImpersonationRole
s {$sel:type':ImpersonationRole' :: Maybe ImpersonationRoleType
type' = Maybe ImpersonationRoleType
a} :: ImpersonationRole)

instance Data.FromJSON ImpersonationRole where
  parseJSON :: Value -> Parser ImpersonationRole
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ImpersonationRole"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe ImpersonationRoleType
-> ImpersonationRole
ImpersonationRole'
            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
"DateCreated")
            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
"DateModified")
            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
"ImpersonationRoleId")
            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
"Name")
            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
"Type")
      )

instance Prelude.Hashable ImpersonationRole where
  hashWithSalt :: Int -> ImpersonationRole -> Int
hashWithSalt Int
_salt ImpersonationRole' {Maybe Text
Maybe POSIX
Maybe ImpersonationRoleType
type' :: Maybe ImpersonationRoleType
name :: Maybe Text
impersonationRoleId :: Maybe Text
dateModified :: Maybe POSIX
dateCreated :: Maybe POSIX
$sel:type':ImpersonationRole' :: ImpersonationRole -> Maybe ImpersonationRoleType
$sel:name:ImpersonationRole' :: ImpersonationRole -> Maybe Text
$sel:impersonationRoleId:ImpersonationRole' :: ImpersonationRole -> Maybe Text
$sel:dateModified:ImpersonationRole' :: ImpersonationRole -> Maybe POSIX
$sel:dateCreated:ImpersonationRole' :: ImpersonationRole -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
dateCreated
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
dateModified
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
impersonationRoleId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ImpersonationRoleType
type'

instance Prelude.NFData ImpersonationRole where
  rnf :: ImpersonationRole -> ()
rnf ImpersonationRole' {Maybe Text
Maybe POSIX
Maybe ImpersonationRoleType
type' :: Maybe ImpersonationRoleType
name :: Maybe Text
impersonationRoleId :: Maybe Text
dateModified :: Maybe POSIX
dateCreated :: Maybe POSIX
$sel:type':ImpersonationRole' :: ImpersonationRole -> Maybe ImpersonationRoleType
$sel:name:ImpersonationRole' :: ImpersonationRole -> Maybe Text
$sel:impersonationRoleId:ImpersonationRole' :: ImpersonationRole -> Maybe Text
$sel:dateModified:ImpersonationRole' :: ImpersonationRole -> Maybe POSIX
$sel:dateCreated:ImpersonationRole' :: ImpersonationRole -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
dateCreated
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
dateModified
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
impersonationRoleId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ImpersonationRoleType
type'