{-# 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.Organizations.Types.Account
-- 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.Organizations.Types.Account where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types.AccountJoinedMethod
import Amazonka.Organizations.Types.AccountStatus
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an AWS account that is a member of an
-- organization.
--
-- /See:/ 'newAccount' smart constructor.
data Account = Account'
  { -- | The status of the account in the organization.
    Account -> Maybe AccountStatus
status :: Prelude.Maybe AccountStatus,
    -- | The method by which the account joined the organization.
    Account -> Maybe AccountJoinedMethod
joinedMethod :: Prelude.Maybe AccountJoinedMethod,
    -- | The email address associated with the AWS account.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for this parameter
    -- is a string of characters that represents a standard internet email
    -- address.
    Account -> Maybe (Sensitive Text)
email :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The Amazon Resource Name (ARN) of the account.
    --
    -- For more information about ARNs in Organizations, see
    -- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsorganizations.html#awsorganizations-resources-for-iam-policies ARN Formats Supported by Organizations>
    -- in the /AWS Service Authorization Reference/.
    Account -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The date the account became a part of the organization.
    Account -> Maybe POSIX
joinedTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The friendly name of the account.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> that is used to
    -- validate this parameter is a string of any of the characters in the
    -- ASCII character range.
    Account -> Maybe (Sensitive Text)
name :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The unique identifier (ID) of the account.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for an account ID
    -- string requires exactly 12 digits.
    Account -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (Account -> Account -> Bool
(Account -> Account -> Bool)
-> (Account -> Account -> Bool) -> Eq Account
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Account -> Account -> Bool
$c/= :: Account -> Account -> Bool
== :: Account -> Account -> Bool
$c== :: Account -> Account -> Bool
Prelude.Eq, Int -> Account -> ShowS
[Account] -> ShowS
Account -> String
(Int -> Account -> ShowS)
-> (Account -> String) -> ([Account] -> ShowS) -> Show Account
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Account] -> ShowS
$cshowList :: [Account] -> ShowS
show :: Account -> String
$cshow :: Account -> String
showsPrec :: Int -> Account -> ShowS
$cshowsPrec :: Int -> Account -> ShowS
Prelude.Show, (forall x. Account -> Rep Account x)
-> (forall x. Rep Account x -> Account) -> Generic Account
forall x. Rep Account x -> Account
forall x. Account -> Rep Account x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Account x -> Account
$cfrom :: forall x. Account -> Rep Account x
Prelude.Generic)

-- |
-- Create a value of 'Account' 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:
--
-- 'status', 'account_status' - The status of the account in the organization.
--
-- 'joinedMethod', 'account_joinedMethod' - The method by which the account joined the organization.
--
-- 'email', 'account_email' - The email address associated with the AWS account.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for this parameter
-- is a string of characters that represents a standard internet email
-- address.
--
-- 'arn', 'account_arn' - The Amazon Resource Name (ARN) of the account.
--
-- For more information about ARNs in Organizations, see
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsorganizations.html#awsorganizations-resources-for-iam-policies ARN Formats Supported by Organizations>
-- in the /AWS Service Authorization Reference/.
--
-- 'joinedTimestamp', 'account_joinedTimestamp' - The date the account became a part of the organization.
--
-- 'name', 'account_name' - The friendly name of the account.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> that is used to
-- validate this parameter is a string of any of the characters in the
-- ASCII character range.
--
-- 'id', 'account_id' - The unique identifier (ID) of the account.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for an account ID
-- string requires exactly 12 digits.
newAccount ::
  Account
newAccount :: Account
newAccount =
  Account' :: Maybe AccountStatus
-> Maybe AccountJoinedMethod
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe POSIX
-> Maybe (Sensitive Text)
-> Maybe Text
-> Account
Account'
    { $sel:status:Account' :: Maybe AccountStatus
status = Maybe AccountStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:joinedMethod:Account' :: Maybe AccountJoinedMethod
joinedMethod = Maybe AccountJoinedMethod
forall a. Maybe a
Prelude.Nothing,
      $sel:email:Account' :: Maybe (Sensitive Text)
email = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:Account' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:joinedTimestamp:Account' :: Maybe POSIX
joinedTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Account' :: Maybe (Sensitive Text)
name = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Account' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the account in the organization.
account_status :: Lens.Lens' Account (Prelude.Maybe AccountStatus)
account_status :: (Maybe AccountStatus -> f (Maybe AccountStatus))
-> Account -> f Account
account_status = (Account -> Maybe AccountStatus)
-> (Account -> Maybe AccountStatus -> Account)
-> Lens Account Account (Maybe AccountStatus) (Maybe AccountStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe AccountStatus
status :: Maybe AccountStatus
$sel:status:Account' :: Account -> Maybe AccountStatus
status} -> Maybe AccountStatus
status) (\s :: Account
s@Account' {} Maybe AccountStatus
a -> Account
s {$sel:status:Account' :: Maybe AccountStatus
status = Maybe AccountStatus
a} :: Account)

-- | The method by which the account joined the organization.
account_joinedMethod :: Lens.Lens' Account (Prelude.Maybe AccountJoinedMethod)
account_joinedMethod :: (Maybe AccountJoinedMethod -> f (Maybe AccountJoinedMethod))
-> Account -> f Account
account_joinedMethod = (Account -> Maybe AccountJoinedMethod)
-> (Account -> Maybe AccountJoinedMethod -> Account)
-> Lens
     Account
     Account
     (Maybe AccountJoinedMethod)
     (Maybe AccountJoinedMethod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe AccountJoinedMethod
joinedMethod :: Maybe AccountJoinedMethod
$sel:joinedMethod:Account' :: Account -> Maybe AccountJoinedMethod
joinedMethod} -> Maybe AccountJoinedMethod
joinedMethod) (\s :: Account
s@Account' {} Maybe AccountJoinedMethod
a -> Account
s {$sel:joinedMethod:Account' :: Maybe AccountJoinedMethod
joinedMethod = Maybe AccountJoinedMethod
a} :: Account)

-- | The email address associated with the AWS account.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for this parameter
-- is a string of characters that represents a standard internet email
-- address.
account_email :: Lens.Lens' Account (Prelude.Maybe Prelude.Text)
account_email :: (Maybe Text -> f (Maybe Text)) -> Account -> f Account
account_email = (Account -> Maybe (Sensitive Text))
-> (Account -> Maybe (Sensitive Text) -> Account)
-> Lens
     Account Account (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe (Sensitive Text)
email :: Maybe (Sensitive Text)
$sel:email:Account' :: Account -> Maybe (Sensitive Text)
email} -> Maybe (Sensitive Text)
email) (\s :: Account
s@Account' {} Maybe (Sensitive Text)
a -> Account
s {$sel:email:Account' :: Maybe (Sensitive Text)
email = Maybe (Sensitive Text)
a} :: Account) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> Account -> f Account)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> Account
-> f Account
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The Amazon Resource Name (ARN) of the account.
--
-- For more information about ARNs in Organizations, see
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsorganizations.html#awsorganizations-resources-for-iam-policies ARN Formats Supported by Organizations>
-- in the /AWS Service Authorization Reference/.
account_arn :: Lens.Lens' Account (Prelude.Maybe Prelude.Text)
account_arn :: (Maybe Text -> f (Maybe Text)) -> Account -> f Account
account_arn = (Account -> Maybe Text)
-> (Account -> Maybe Text -> Account)
-> Lens Account Account (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe Text
arn :: Maybe Text
$sel:arn:Account' :: Account -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Account
s@Account' {} Maybe Text
a -> Account
s {$sel:arn:Account' :: Maybe Text
arn = Maybe Text
a} :: Account)

-- | The date the account became a part of the organization.
account_joinedTimestamp :: Lens.Lens' Account (Prelude.Maybe Prelude.UTCTime)
account_joinedTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Account -> f Account
account_joinedTimestamp = (Account -> Maybe POSIX)
-> (Account -> Maybe POSIX -> Account)
-> Lens Account Account (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe POSIX
joinedTimestamp :: Maybe POSIX
$sel:joinedTimestamp:Account' :: Account -> Maybe POSIX
joinedTimestamp} -> Maybe POSIX
joinedTimestamp) (\s :: Account
s@Account' {} Maybe POSIX
a -> Account
s {$sel:joinedTimestamp:Account' :: Maybe POSIX
joinedTimestamp = Maybe POSIX
a} :: Account) ((Maybe POSIX -> f (Maybe POSIX)) -> Account -> f Account)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Account
-> f Account
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 friendly name of the account.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> that is used to
-- validate this parameter is a string of any of the characters in the
-- ASCII character range.
account_name :: Lens.Lens' Account (Prelude.Maybe Prelude.Text)
account_name :: (Maybe Text -> f (Maybe Text)) -> Account -> f Account
account_name = (Account -> Maybe (Sensitive Text))
-> (Account -> Maybe (Sensitive Text) -> Account)
-> Lens
     Account Account (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe (Sensitive Text)
name :: Maybe (Sensitive Text)
$sel:name:Account' :: Account -> Maybe (Sensitive Text)
name} -> Maybe (Sensitive Text)
name) (\s :: Account
s@Account' {} Maybe (Sensitive Text)
a -> Account
s {$sel:name:Account' :: Maybe (Sensitive Text)
name = Maybe (Sensitive Text)
a} :: Account) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> Account -> f Account)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> Account
-> f Account
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The unique identifier (ID) of the account.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for an account ID
-- string requires exactly 12 digits.
account_id :: Lens.Lens' Account (Prelude.Maybe Prelude.Text)
account_id :: (Maybe Text -> f (Maybe Text)) -> Account -> f Account
account_id = (Account -> Maybe Text)
-> (Account -> Maybe Text -> Account)
-> Lens Account Account (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Account' {Maybe Text
id :: Maybe Text
$sel:id:Account' :: Account -> Maybe Text
id} -> Maybe Text
id) (\s :: Account
s@Account' {} Maybe Text
a -> Account
s {$sel:id:Account' :: Maybe Text
id = Maybe Text
a} :: Account)

instance Core.FromJSON Account where
  parseJSON :: Value -> Parser Account
parseJSON =
    String -> (Object -> Parser Account) -> Value -> Parser Account
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Account"
      ( \Object
x ->
          Maybe AccountStatus
-> Maybe AccountJoinedMethod
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe POSIX
-> Maybe (Sensitive Text)
-> Maybe Text
-> Account
Account'
            (Maybe AccountStatus
 -> Maybe AccountJoinedMethod
 -> Maybe (Sensitive Text)
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe (Sensitive Text)
 -> Maybe Text
 -> Account)
-> Parser (Maybe AccountStatus)
-> Parser
     (Maybe AccountJoinedMethod
      -> Maybe (Sensitive Text)
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe (Sensitive Text)
      -> Maybe Text
      -> Account)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AccountStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe AccountJoinedMethod
   -> Maybe (Sensitive Text)
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe (Sensitive Text)
   -> Maybe Text
   -> Account)
-> Parser (Maybe AccountJoinedMethod)
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe (Sensitive Text)
      -> Maybe Text
      -> Account)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AccountJoinedMethod)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"JoinedMethod")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe (Sensitive Text)
   -> Maybe Text
   -> Account)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe Text
      -> Maybe POSIX -> Maybe (Sensitive Text) -> Maybe Text -> Account)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Email")
            Parser
  (Maybe Text
   -> Maybe POSIX -> Maybe (Sensitive Text) -> Maybe Text -> Account)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX -> Maybe (Sensitive Text) -> Maybe Text -> Account)
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
"Arn")
            Parser
  (Maybe POSIX -> Maybe (Sensitive Text) -> Maybe Text -> Account)
-> Parser (Maybe POSIX)
-> Parser (Maybe (Sensitive Text) -> Maybe Text -> Account)
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
"JoinedTimestamp")
            Parser (Maybe (Sensitive Text) -> Maybe Text -> Account)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe Text -> Account)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser (Maybe Text -> Account)
-> Parser (Maybe Text) -> Parser Account
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
"Id")
      )

instance Prelude.Hashable Account

instance Prelude.NFData Account