{-# 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.Organization
-- 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.Organization 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.OrganizationFeatureSet
import Amazonka.Organizations.Types.PolicyTypeSummary
import qualified Amazonka.Prelude as Prelude

-- | Contains details about an organization. An organization is a collection
-- of accounts that are centrally managed together using consolidated
-- billing, organized hierarchically with organizational units (OUs), and
-- controlled with policies .
--
-- /See:/ 'newOrganization' smart constructor.
data Organization = Organization'
  { -- | The Amazon Resource Name (ARN) of an organization.
    --
    -- 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/.
    Organization -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | Do not use. This field is deprecated and doesn\'t provide complete
    -- information about the policies in your organization.
    --
    -- To determine the policies that are enabled and available for use in your
    -- organization, use the ListRoots operation instead.
    Organization -> Maybe [PolicyTypeSummary]
availablePolicyTypes :: Prelude.Maybe [PolicyTypeSummary],
    -- | Specifies the functionality that currently is available to the
    -- organization. If set to \"ALL\", then all features are enabled and
    -- policies can be applied to accounts in the organization. If set to
    -- \"CONSOLIDATED_BILLING\", then only consolidated billing functionality
    -- is available. For more information, see
    -- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html Enabling All Features in Your Organization>
    -- in the /Organizations User Guide/.
    Organization -> Maybe OrganizationFeatureSet
featureSet :: Prelude.Maybe OrganizationFeatureSet,
    -- | The unique identifier (ID) of an organization.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for an organization
    -- ID string requires \"o-\" followed by from 10 to 32 lowercase letters or
    -- digits.
    Organization -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the account that is designated as the
    -- management account for the organization.
    --
    -- 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/.
    Organization -> Maybe Text
masterAccountArn :: Prelude.Maybe Prelude.Text,
    -- | The email address that is associated with the Amazon Web Services
    -- account that is designated as the management account for the
    -- organization.
    Organization -> Maybe (Sensitive Text)
masterAccountEmail :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The unique identifier (ID) of the management account of an organization.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for an account ID
    -- string requires exactly 12 digits.
    Organization -> Maybe Text
masterAccountId :: Prelude.Maybe Prelude.Text
  }
  deriving (Organization -> Organization -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Organization -> Organization -> Bool
$c/= :: Organization -> Organization -> Bool
== :: Organization -> Organization -> Bool
$c== :: Organization -> Organization -> Bool
Prelude.Eq, Int -> Organization -> ShowS
[Organization] -> ShowS
Organization -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Organization] -> ShowS
$cshowList :: [Organization] -> ShowS
show :: Organization -> String
$cshow :: Organization -> String
showsPrec :: Int -> Organization -> ShowS
$cshowsPrec :: Int -> Organization -> ShowS
Prelude.Show, forall x. Rep Organization x -> Organization
forall x. Organization -> Rep Organization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Organization x -> Organization
$cfrom :: forall x. Organization -> Rep Organization x
Prelude.Generic)

-- |
-- Create a value of 'Organization' 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', 'organization_arn' - The Amazon Resource Name (ARN) of an organization.
--
-- 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/.
--
-- 'availablePolicyTypes', 'organization_availablePolicyTypes' - Do not use. This field is deprecated and doesn\'t provide complete
-- information about the policies in your organization.
--
-- To determine the policies that are enabled and available for use in your
-- organization, use the ListRoots operation instead.
--
-- 'featureSet', 'organization_featureSet' - Specifies the functionality that currently is available to the
-- organization. If set to \"ALL\", then all features are enabled and
-- policies can be applied to accounts in the organization. If set to
-- \"CONSOLIDATED_BILLING\", then only consolidated billing functionality
-- is available. For more information, see
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html Enabling All Features in Your Organization>
-- in the /Organizations User Guide/.
--
-- 'id', 'organization_id' - The unique identifier (ID) of an organization.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for an organization
-- ID string requires \"o-\" followed by from 10 to 32 lowercase letters or
-- digits.
--
-- 'masterAccountArn', 'organization_masterAccountArn' - The Amazon Resource Name (ARN) of the account that is designated as the
-- management account for the organization.
--
-- 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/.
--
-- 'masterAccountEmail', 'organization_masterAccountEmail' - The email address that is associated with the Amazon Web Services
-- account that is designated as the management account for the
-- organization.
--
-- 'masterAccountId', 'organization_masterAccountId' - The unique identifier (ID) of the management account of an organization.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for an account ID
-- string requires exactly 12 digits.
newOrganization ::
  Organization
newOrganization :: Organization
newOrganization =
  Organization'
    { $sel:arn:Organization' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:availablePolicyTypes:Organization' :: Maybe [PolicyTypeSummary]
availablePolicyTypes = forall a. Maybe a
Prelude.Nothing,
      $sel:featureSet:Organization' :: Maybe OrganizationFeatureSet
featureSet = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Organization' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:masterAccountArn:Organization' :: Maybe Text
masterAccountArn = forall a. Maybe a
Prelude.Nothing,
      $sel:masterAccountEmail:Organization' :: Maybe (Sensitive Text)
masterAccountEmail = forall a. Maybe a
Prelude.Nothing,
      $sel:masterAccountId:Organization' :: Maybe Text
masterAccountId = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of an organization.
--
-- 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/.
organization_arn :: Lens.Lens' Organization (Prelude.Maybe Prelude.Text)
organization_arn :: Lens' Organization (Maybe Text)
organization_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Organization' {Maybe Text
arn :: Maybe Text
$sel:arn:Organization' :: Organization -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Organization
s@Organization' {} Maybe Text
a -> Organization
s {$sel:arn:Organization' :: Maybe Text
arn = Maybe Text
a} :: Organization)

-- | Do not use. This field is deprecated and doesn\'t provide complete
-- information about the policies in your organization.
--
-- To determine the policies that are enabled and available for use in your
-- organization, use the ListRoots operation instead.
organization_availablePolicyTypes :: Lens.Lens' Organization (Prelude.Maybe [PolicyTypeSummary])
organization_availablePolicyTypes :: Lens' Organization (Maybe [PolicyTypeSummary])
organization_availablePolicyTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Organization' {Maybe [PolicyTypeSummary]
availablePolicyTypes :: Maybe [PolicyTypeSummary]
$sel:availablePolicyTypes:Organization' :: Organization -> Maybe [PolicyTypeSummary]
availablePolicyTypes} -> Maybe [PolicyTypeSummary]
availablePolicyTypes) (\s :: Organization
s@Organization' {} Maybe [PolicyTypeSummary]
a -> Organization
s {$sel:availablePolicyTypes:Organization' :: Maybe [PolicyTypeSummary]
availablePolicyTypes = Maybe [PolicyTypeSummary]
a} :: Organization) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the functionality that currently is available to the
-- organization. If set to \"ALL\", then all features are enabled and
-- policies can be applied to accounts in the organization. If set to
-- \"CONSOLIDATED_BILLING\", then only consolidated billing functionality
-- is available. For more information, see
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html Enabling All Features in Your Organization>
-- in the /Organizations User Guide/.
organization_featureSet :: Lens.Lens' Organization (Prelude.Maybe OrganizationFeatureSet)
organization_featureSet :: Lens' Organization (Maybe OrganizationFeatureSet)
organization_featureSet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Organization' {Maybe OrganizationFeatureSet
featureSet :: Maybe OrganizationFeatureSet
$sel:featureSet:Organization' :: Organization -> Maybe OrganizationFeatureSet
featureSet} -> Maybe OrganizationFeatureSet
featureSet) (\s :: Organization
s@Organization' {} Maybe OrganizationFeatureSet
a -> Organization
s {$sel:featureSet:Organization' :: Maybe OrganizationFeatureSet
featureSet = Maybe OrganizationFeatureSet
a} :: Organization)

-- | The unique identifier (ID) of an organization.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for an organization
-- ID string requires \"o-\" followed by from 10 to 32 lowercase letters or
-- digits.
organization_id :: Lens.Lens' Organization (Prelude.Maybe Prelude.Text)
organization_id :: Lens' Organization (Maybe Text)
organization_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Organization' {Maybe Text
id :: Maybe Text
$sel:id:Organization' :: Organization -> Maybe Text
id} -> Maybe Text
id) (\s :: Organization
s@Organization' {} Maybe Text
a -> Organization
s {$sel:id:Organization' :: Maybe Text
id = Maybe Text
a} :: Organization)

-- | The Amazon Resource Name (ARN) of the account that is designated as the
-- management account for the organization.
--
-- 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/.
organization_masterAccountArn :: Lens.Lens' Organization (Prelude.Maybe Prelude.Text)
organization_masterAccountArn :: Lens' Organization (Maybe Text)
organization_masterAccountArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Organization' {Maybe Text
masterAccountArn :: Maybe Text
$sel:masterAccountArn:Organization' :: Organization -> Maybe Text
masterAccountArn} -> Maybe Text
masterAccountArn) (\s :: Organization
s@Organization' {} Maybe Text
a -> Organization
s {$sel:masterAccountArn:Organization' :: Maybe Text
masterAccountArn = Maybe Text
a} :: Organization)

-- | The email address that is associated with the Amazon Web Services
-- account that is designated as the management account for the
-- organization.
organization_masterAccountEmail :: Lens.Lens' Organization (Prelude.Maybe Prelude.Text)
organization_masterAccountEmail :: Lens' Organization (Maybe Text)
organization_masterAccountEmail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Organization' {Maybe (Sensitive Text)
masterAccountEmail :: Maybe (Sensitive Text)
$sel:masterAccountEmail:Organization' :: Organization -> Maybe (Sensitive Text)
masterAccountEmail} -> Maybe (Sensitive Text)
masterAccountEmail) (\s :: Organization
s@Organization' {} Maybe (Sensitive Text)
a -> Organization
s {$sel:masterAccountEmail:Organization' :: Maybe (Sensitive Text)
masterAccountEmail = Maybe (Sensitive Text)
a} :: Organization) 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 management account of an organization.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for an account ID
-- string requires exactly 12 digits.
organization_masterAccountId :: Lens.Lens' Organization (Prelude.Maybe Prelude.Text)
organization_masterAccountId :: Lens' Organization (Maybe Text)
organization_masterAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Organization' {Maybe Text
masterAccountId :: Maybe Text
$sel:masterAccountId:Organization' :: Organization -> Maybe Text
masterAccountId} -> Maybe Text
masterAccountId) (\s :: Organization
s@Organization' {} Maybe Text
a -> Organization
s {$sel:masterAccountId:Organization' :: Maybe Text
masterAccountId = Maybe Text
a} :: Organization)

instance Data.FromJSON Organization where
  parseJSON :: Value -> Parser Organization
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Organization"
      ( \Object
x ->
          Maybe Text
-> Maybe [PolicyTypeSummary]
-> Maybe OrganizationFeatureSet
-> Maybe Text
-> Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Organization
Organization'
            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
"AvailablePolicyTypes"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"FeatureSet")
            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
"MasterAccountArn")
            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
"MasterAccountEmail")
            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
"MasterAccountId")
      )

instance Prelude.Hashable Organization where
  hashWithSalt :: Int -> Organization -> Int
hashWithSalt Int
_salt Organization' {Maybe [PolicyTypeSummary]
Maybe Text
Maybe (Sensitive Text)
Maybe OrganizationFeatureSet
masterAccountId :: Maybe Text
masterAccountEmail :: Maybe (Sensitive Text)
masterAccountArn :: Maybe Text
id :: Maybe Text
featureSet :: Maybe OrganizationFeatureSet
availablePolicyTypes :: Maybe [PolicyTypeSummary]
arn :: Maybe Text
$sel:masterAccountId:Organization' :: Organization -> Maybe Text
$sel:masterAccountEmail:Organization' :: Organization -> Maybe (Sensitive Text)
$sel:masterAccountArn:Organization' :: Organization -> Maybe Text
$sel:id:Organization' :: Organization -> Maybe Text
$sel:featureSet:Organization' :: Organization -> Maybe OrganizationFeatureSet
$sel:availablePolicyTypes:Organization' :: Organization -> Maybe [PolicyTypeSummary]
$sel:arn:Organization' :: Organization -> 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 [PolicyTypeSummary]
availablePolicyTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OrganizationFeatureSet
featureSet
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
masterAccountArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
masterAccountEmail
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
masterAccountId

instance Prelude.NFData Organization where
  rnf :: Organization -> ()
rnf Organization' {Maybe [PolicyTypeSummary]
Maybe Text
Maybe (Sensitive Text)
Maybe OrganizationFeatureSet
masterAccountId :: Maybe Text
masterAccountEmail :: Maybe (Sensitive Text)
masterAccountArn :: Maybe Text
id :: Maybe Text
featureSet :: Maybe OrganizationFeatureSet
availablePolicyTypes :: Maybe [PolicyTypeSummary]
arn :: Maybe Text
$sel:masterAccountId:Organization' :: Organization -> Maybe Text
$sel:masterAccountEmail:Organization' :: Organization -> Maybe (Sensitive Text)
$sel:masterAccountArn:Organization' :: Organization -> Maybe Text
$sel:id:Organization' :: Organization -> Maybe Text
$sel:featureSet:Organization' :: Organization -> Maybe OrganizationFeatureSet
$sel:availablePolicyTypes:Organization' :: Organization -> Maybe [PolicyTypeSummary]
$sel:arn:Organization' :: Organization -> 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 [PolicyTypeSummary]
availablePolicyTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OrganizationFeatureSet
featureSet
      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 Text
masterAccountArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
masterAccountEmail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
masterAccountId