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

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

-- | Contains information about an Amazon Web Services account that is a
-- member of an organization.
--
-- /See:/ 'newAccount' smart constructor.
data Account = Account'
  { -- | 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 /Amazon Web Services Service Authorization Reference/.
    Account -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The email address associated with the Amazon Web Services 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 (Data.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,
    -- | The method by which the account joined the organization.
    Account -> Maybe AccountJoinedMethod
joinedMethod :: Prelude.Maybe AccountJoinedMethod,
    -- | The date the account became a part of the organization.
    Account -> Maybe POSIX
joinedTimestamp :: Prelude.Maybe Data.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 (Data.Sensitive Prelude.Text),
    -- | The status of the account in the organization.
    Account -> Maybe AccountStatus
status :: Prelude.Maybe AccountStatus
  }
  deriving (Account -> Account -> Bool
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
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. 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:
--
-- '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 /Amazon Web Services Service Authorization Reference/.
--
-- 'email', 'account_email' - The email address associated with the Amazon Web Services account.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for this parameter
-- is a string of characters that represents a standard internet email
-- address.
--
-- '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.
--
-- 'joinedMethod', 'account_joinedMethod' - The method by which the account joined the organization.
--
-- '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.
--
-- 'status', 'account_status' - The status of the account in the organization.
newAccount ::
  Account
newAccount :: Account
newAccount =
  Account'
    { $sel:arn:Account' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:email:Account' :: Maybe (Sensitive Text)
email = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Account' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:joinedMethod:Account' :: Maybe AccountJoinedMethod
joinedMethod = forall a. Maybe a
Prelude.Nothing,
      $sel:joinedTimestamp:Account' :: Maybe POSIX
joinedTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Account' :: Maybe (Sensitive Text)
name = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Account' :: Maybe AccountStatus
status = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 /Amazon Web Services Service Authorization Reference/.
account_arn :: Lens.Lens' Account (Prelude.Maybe Prelude.Text)
account_arn :: Lens' Account (Maybe Text)
account_arn = 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 email address associated with the Amazon Web Services 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 :: Lens' Account (Maybe Text)
account_email = 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) 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. Iso' (Sensitive a) a
Data._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 :: Lens' Account (Maybe Text)
account_id = 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)

-- | The method by which the account joined the organization.
account_joinedMethod :: Lens.Lens' Account (Prelude.Maybe AccountJoinedMethod)
account_joinedMethod :: Lens' Account (Maybe AccountJoinedMethod)
account_joinedMethod = 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 date the account became a part of the organization.
account_joinedTimestamp :: Lens.Lens' Account (Prelude.Maybe Prelude.UTCTime)
account_joinedTimestamp :: Lens' Account (Maybe UTCTime)
account_joinedTimestamp = 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) 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 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 :: Lens' Account (Maybe Text)
account_name = 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) 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. Iso' (Sensitive a) a
Data._Sensitive

-- | The status of the account in the organization.
account_status :: Lens.Lens' Account (Prelude.Maybe AccountStatus)
account_status :: Lens' Account (Maybe AccountStatus)
account_status = 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)

instance Data.FromJSON Account where
  parseJSON :: Value -> Parser Account
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Account"
      ( \Object
x ->
          Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe AccountJoinedMethod
-> Maybe POSIX
-> Maybe (Sensitive Text)
-> Maybe AccountStatus
-> Account
Account'
            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
"Arn")
            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
"Email")
            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
"JoinedMethod")
            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
"JoinedTimestamp")
            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
"Status")
      )

instance Prelude.Hashable Account where
  hashWithSalt :: Int -> Account -> Int
hashWithSalt Int
_salt Account' {Maybe Text
Maybe (Sensitive Text)
Maybe POSIX
Maybe AccountJoinedMethod
Maybe AccountStatus
status :: Maybe AccountStatus
name :: Maybe (Sensitive Text)
joinedTimestamp :: Maybe POSIX
joinedMethod :: Maybe AccountJoinedMethod
id :: Maybe Text
email :: Maybe (Sensitive Text)
arn :: Maybe Text
$sel:status:Account' :: Account -> Maybe AccountStatus
$sel:name:Account' :: Account -> Maybe (Sensitive Text)
$sel:joinedTimestamp:Account' :: Account -> Maybe POSIX
$sel:joinedMethod:Account' :: Account -> Maybe AccountJoinedMethod
$sel:id:Account' :: Account -> Maybe Text
$sel:email:Account' :: Account -> Maybe (Sensitive Text)
$sel:arn:Account' :: Account -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
email
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AccountJoinedMethod
joinedMethod
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
joinedTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AccountStatus
status

instance Prelude.NFData Account where
  rnf :: Account -> ()
rnf Account' {Maybe Text
Maybe (Sensitive Text)
Maybe POSIX
Maybe AccountJoinedMethod
Maybe AccountStatus
status :: Maybe AccountStatus
name :: Maybe (Sensitive Text)
joinedTimestamp :: Maybe POSIX
joinedMethod :: Maybe AccountJoinedMethod
id :: Maybe Text
email :: Maybe (Sensitive Text)
arn :: Maybe Text
$sel:status:Account' :: Account -> Maybe AccountStatus
$sel:name:Account' :: Account -> Maybe (Sensitive Text)
$sel:joinedTimestamp:Account' :: Account -> Maybe POSIX
$sel:joinedMethod:Account' :: Account -> Maybe AccountJoinedMethod
$sel:id:Account' :: Account -> Maybe Text
$sel:email:Account' :: Account -> Maybe (Sensitive Text)
$sel:arn:Account' :: Account -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
email
      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 AccountJoinedMethod
joinedMethod
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
joinedTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AccountStatus
status