{-# 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.RAM.Types.Principal
-- 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.RAM.Types.Principal 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

-- | Describes a principal for use with Resource Access Manager.
--
-- /See:/ 'newPrincipal' smart constructor.
data Principal = Principal'
  { -- | The date and time when the principal was associated with the resource
    -- share.
    Principal -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | Indicates whether the principal belongs to the same organization in
    -- Organizations as the Amazon Web Services account that owns the resource
    -- share.
    Principal -> Maybe Bool
external :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the principal.
    Principal -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The date and time when the association was last updated.
    Principal -> Maybe POSIX
lastUpdatedTime :: Prelude.Maybe Data.POSIX,
    -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>
    -- of a resource share the principal is associated with.
    Principal -> Maybe Text
resourceShareArn :: Prelude.Maybe Prelude.Text
  }
  deriving (Principal -> Principal -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Principal -> Principal -> Bool
$c/= :: Principal -> Principal -> Bool
== :: Principal -> Principal -> Bool
$c== :: Principal -> Principal -> Bool
Prelude.Eq, ReadPrec [Principal]
ReadPrec Principal
Int -> ReadS Principal
ReadS [Principal]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Principal]
$creadListPrec :: ReadPrec [Principal]
readPrec :: ReadPrec Principal
$creadPrec :: ReadPrec Principal
readList :: ReadS [Principal]
$creadList :: ReadS [Principal]
readsPrec :: Int -> ReadS Principal
$creadsPrec :: Int -> ReadS Principal
Prelude.Read, Int -> Principal -> ShowS
[Principal] -> ShowS
Principal -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Principal] -> ShowS
$cshowList :: [Principal] -> ShowS
show :: Principal -> String
$cshow :: Principal -> String
showsPrec :: Int -> Principal -> ShowS
$cshowsPrec :: Int -> Principal -> ShowS
Prelude.Show, forall x. Rep Principal x -> Principal
forall x. Principal -> Rep Principal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Principal x -> Principal
$cfrom :: forall x. Principal -> Rep Principal x
Prelude.Generic)

-- |
-- Create a value of 'Principal' 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:
--
-- 'creationTime', 'principal_creationTime' - The date and time when the principal was associated with the resource
-- share.
--
-- 'external', 'principal_external' - Indicates whether the principal belongs to the same organization in
-- Organizations as the Amazon Web Services account that owns the resource
-- share.
--
-- 'id', 'principal_id' - The ID of the principal.
--
-- 'lastUpdatedTime', 'principal_lastUpdatedTime' - The date and time when the association was last updated.
--
-- 'resourceShareArn', 'principal_resourceShareArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>
-- of a resource share the principal is associated with.
newPrincipal ::
  Principal
newPrincipal :: Principal
newPrincipal =
  Principal'
    { $sel:creationTime:Principal' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:external:Principal' :: Maybe Bool
external = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Principal' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedTime:Principal' :: Maybe POSIX
lastUpdatedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceShareArn:Principal' :: Maybe Text
resourceShareArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time when the principal was associated with the resource
-- share.
principal_creationTime :: Lens.Lens' Principal (Prelude.Maybe Prelude.UTCTime)
principal_creationTime :: Lens' Principal (Maybe UTCTime)
principal_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Principal' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:Principal' :: Principal -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: Principal
s@Principal' {} Maybe POSIX
a -> Principal
s {$sel:creationTime:Principal' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: Principal) 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

-- | Indicates whether the principal belongs to the same organization in
-- Organizations as the Amazon Web Services account that owns the resource
-- share.
principal_external :: Lens.Lens' Principal (Prelude.Maybe Prelude.Bool)
principal_external :: Lens' Principal (Maybe Bool)
principal_external = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Principal' {Maybe Bool
external :: Maybe Bool
$sel:external:Principal' :: Principal -> Maybe Bool
external} -> Maybe Bool
external) (\s :: Principal
s@Principal' {} Maybe Bool
a -> Principal
s {$sel:external:Principal' :: Maybe Bool
external = Maybe Bool
a} :: Principal)

-- | The ID of the principal.
principal_id :: Lens.Lens' Principal (Prelude.Maybe Prelude.Text)
principal_id :: Lens' Principal (Maybe Text)
principal_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Principal' {Maybe Text
id :: Maybe Text
$sel:id:Principal' :: Principal -> Maybe Text
id} -> Maybe Text
id) (\s :: Principal
s@Principal' {} Maybe Text
a -> Principal
s {$sel:id:Principal' :: Maybe Text
id = Maybe Text
a} :: Principal)

-- | The date and time when the association was last updated.
principal_lastUpdatedTime :: Lens.Lens' Principal (Prelude.Maybe Prelude.UTCTime)
principal_lastUpdatedTime :: Lens' Principal (Maybe UTCTime)
principal_lastUpdatedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Principal' {Maybe POSIX
lastUpdatedTime :: Maybe POSIX
$sel:lastUpdatedTime:Principal' :: Principal -> Maybe POSIX
lastUpdatedTime} -> Maybe POSIX
lastUpdatedTime) (\s :: Principal
s@Principal' {} Maybe POSIX
a -> Principal
s {$sel:lastUpdatedTime:Principal' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
a} :: Principal) 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
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resoure Name (ARN)>
-- of a resource share the principal is associated with.
principal_resourceShareArn :: Lens.Lens' Principal (Prelude.Maybe Prelude.Text)
principal_resourceShareArn :: Lens' Principal (Maybe Text)
principal_resourceShareArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Principal' {Maybe Text
resourceShareArn :: Maybe Text
$sel:resourceShareArn:Principal' :: Principal -> Maybe Text
resourceShareArn} -> Maybe Text
resourceShareArn) (\s :: Principal
s@Principal' {} Maybe Text
a -> Principal
s {$sel:resourceShareArn:Principal' :: Maybe Text
resourceShareArn = Maybe Text
a} :: Principal)

instance Data.FromJSON Principal where
  parseJSON :: Value -> Parser Principal
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Principal"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Bool
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Principal
Principal'
            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
"creationTime")
            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
"external")
            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
"id")
            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
"lastUpdatedTime")
            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
"resourceShareArn")
      )

instance Prelude.Hashable Principal where
  hashWithSalt :: Int -> Principal -> Int
hashWithSalt Int
_salt Principal' {Maybe Bool
Maybe Text
Maybe POSIX
resourceShareArn :: Maybe Text
lastUpdatedTime :: Maybe POSIX
id :: Maybe Text
external :: Maybe Bool
creationTime :: Maybe POSIX
$sel:resourceShareArn:Principal' :: Principal -> Maybe Text
$sel:lastUpdatedTime:Principal' :: Principal -> Maybe POSIX
$sel:id:Principal' :: Principal -> Maybe Text
$sel:external:Principal' :: Principal -> Maybe Bool
$sel:creationTime:Principal' :: Principal -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
external
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastUpdatedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceShareArn

instance Prelude.NFData Principal where
  rnf :: Principal -> ()
rnf Principal' {Maybe Bool
Maybe Text
Maybe POSIX
resourceShareArn :: Maybe Text
lastUpdatedTime :: Maybe POSIX
id :: Maybe Text
external :: Maybe Bool
creationTime :: Maybe POSIX
$sel:resourceShareArn:Principal' :: Principal -> Maybe Text
$sel:lastUpdatedTime:Principal' :: Principal -> Maybe POSIX
$sel:id:Principal' :: Principal -> Maybe Text
$sel:external:Principal' :: Principal -> Maybe Bool
$sel:creationTime:Principal' :: Principal -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
external
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastUpdatedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceShareArn