{-# 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.Root
-- 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.Root where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types.PolicyTypeSummary
import qualified Amazonka.Prelude as Prelude

-- | Contains details about a root. A root is a top-level parent node in the
-- hierarchy of an organization that can contain organizational units (OUs)
-- and accounts. The root contains every AWS account in the organization.
--
-- /See:/ 'newRoot' smart constructor.
data Root = Root'
  { -- | The Amazon Resource Name (ARN) of the root.
    --
    -- 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/.
    Root -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The friendly name of the root.
    --
    -- 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.
    Root -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier (ID) for the root.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for a root ID string
    -- requires \"r-\" followed by from 4 to 32 lowercase letters or digits.
    Root -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The types of policies that are currently enabled for the root and
    -- therefore can be attached to the root or to its OUs or accounts.
    --
    -- Even if a policy type is shown as available in the organization, you can
    -- separately enable and disable them at the root level by using
    -- EnablePolicyType and DisablePolicyType. Use DescribeOrganization to see
    -- the availability of the policy types in that organization.
    Root -> Maybe [PolicyTypeSummary]
policyTypes :: Prelude.Maybe [PolicyTypeSummary]
  }
  deriving (Root -> Root -> Bool
(Root -> Root -> Bool) -> (Root -> Root -> Bool) -> Eq Root
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Root -> Root -> Bool
$c/= :: Root -> Root -> Bool
== :: Root -> Root -> Bool
$c== :: Root -> Root -> Bool
Prelude.Eq, ReadPrec [Root]
ReadPrec Root
Int -> ReadS Root
ReadS [Root]
(Int -> ReadS Root)
-> ReadS [Root] -> ReadPrec Root -> ReadPrec [Root] -> Read Root
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Root]
$creadListPrec :: ReadPrec [Root]
readPrec :: ReadPrec Root
$creadPrec :: ReadPrec Root
readList :: ReadS [Root]
$creadList :: ReadS [Root]
readsPrec :: Int -> ReadS Root
$creadsPrec :: Int -> ReadS Root
Prelude.Read, Int -> Root -> ShowS
[Root] -> ShowS
Root -> String
(Int -> Root -> ShowS)
-> (Root -> String) -> ([Root] -> ShowS) -> Show Root
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Root] -> ShowS
$cshowList :: [Root] -> ShowS
show :: Root -> String
$cshow :: Root -> String
showsPrec :: Int -> Root -> ShowS
$cshowsPrec :: Int -> Root -> ShowS
Prelude.Show, (forall x. Root -> Rep Root x)
-> (forall x. Rep Root x -> Root) -> Generic Root
forall x. Rep Root x -> Root
forall x. Root -> Rep Root x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Root x -> Root
$cfrom :: forall x. Root -> Rep Root x
Prelude.Generic)

-- |
-- Create a value of 'Root' 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', 'root_arn' - The Amazon Resource Name (ARN) of the root.
--
-- 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/.
--
-- 'name', 'root_name' - The friendly name of the root.
--
-- 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', 'root_id' - The unique identifier (ID) for the root.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a root ID string
-- requires \"r-\" followed by from 4 to 32 lowercase letters or digits.
--
-- 'policyTypes', 'root_policyTypes' - The types of policies that are currently enabled for the root and
-- therefore can be attached to the root or to its OUs or accounts.
--
-- Even if a policy type is shown as available in the organization, you can
-- separately enable and disable them at the root level by using
-- EnablePolicyType and DisablePolicyType. Use DescribeOrganization to see
-- the availability of the policy types in that organization.
newRoot ::
  Root
newRoot :: Root
newRoot =
  Root' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe [PolicyTypeSummary] -> Root
Root'
    { $sel:arn:Root' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Root' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Root' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policyTypes:Root' :: Maybe [PolicyTypeSummary]
policyTypes = Maybe [PolicyTypeSummary]
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The friendly name of the root.
--
-- 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.
root_name :: Lens.Lens' Root (Prelude.Maybe Prelude.Text)
root_name :: (Maybe Text -> f (Maybe Text)) -> Root -> f Root
root_name = (Root -> Maybe Text)
-> (Root -> Maybe Text -> Root)
-> Lens Root Root (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Root' {Maybe Text
name :: Maybe Text
$sel:name:Root' :: Root -> Maybe Text
name} -> Maybe Text
name) (\s :: Root
s@Root' {} Maybe Text
a -> Root
s {$sel:name:Root' :: Maybe Text
name = Maybe Text
a} :: Root)

-- | The unique identifier (ID) for the root.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a root ID string
-- requires \"r-\" followed by from 4 to 32 lowercase letters or digits.
root_id :: Lens.Lens' Root (Prelude.Maybe Prelude.Text)
root_id :: (Maybe Text -> f (Maybe Text)) -> Root -> f Root
root_id = (Root -> Maybe Text)
-> (Root -> Maybe Text -> Root)
-> Lens Root Root (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Root' {Maybe Text
id :: Maybe Text
$sel:id:Root' :: Root -> Maybe Text
id} -> Maybe Text
id) (\s :: Root
s@Root' {} Maybe Text
a -> Root
s {$sel:id:Root' :: Maybe Text
id = Maybe Text
a} :: Root)

-- | The types of policies that are currently enabled for the root and
-- therefore can be attached to the root or to its OUs or accounts.
--
-- Even if a policy type is shown as available in the organization, you can
-- separately enable and disable them at the root level by using
-- EnablePolicyType and DisablePolicyType. Use DescribeOrganization to see
-- the availability of the policy types in that organization.
root_policyTypes :: Lens.Lens' Root (Prelude.Maybe [PolicyTypeSummary])
root_policyTypes :: (Maybe [PolicyTypeSummary] -> f (Maybe [PolicyTypeSummary]))
-> Root -> f Root
root_policyTypes = (Root -> Maybe [PolicyTypeSummary])
-> (Root -> Maybe [PolicyTypeSummary] -> Root)
-> Lens
     Root Root (Maybe [PolicyTypeSummary]) (Maybe [PolicyTypeSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Root' {Maybe [PolicyTypeSummary]
policyTypes :: Maybe [PolicyTypeSummary]
$sel:policyTypes:Root' :: Root -> Maybe [PolicyTypeSummary]
policyTypes} -> Maybe [PolicyTypeSummary]
policyTypes) (\s :: Root
s@Root' {} Maybe [PolicyTypeSummary]
a -> Root
s {$sel:policyTypes:Root' :: Maybe [PolicyTypeSummary]
policyTypes = Maybe [PolicyTypeSummary]
a} :: Root) ((Maybe [PolicyTypeSummary] -> f (Maybe [PolicyTypeSummary]))
 -> Root -> f Root)
-> ((Maybe [PolicyTypeSummary] -> f (Maybe [PolicyTypeSummary]))
    -> Maybe [PolicyTypeSummary] -> f (Maybe [PolicyTypeSummary]))
-> (Maybe [PolicyTypeSummary] -> f (Maybe [PolicyTypeSummary]))
-> Root
-> f Root
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PolicyTypeSummary]
  [PolicyTypeSummary]
  [PolicyTypeSummary]
  [PolicyTypeSummary]
-> Iso
     (Maybe [PolicyTypeSummary])
     (Maybe [PolicyTypeSummary])
     (Maybe [PolicyTypeSummary])
     (Maybe [PolicyTypeSummary])
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
  [PolicyTypeSummary]
  [PolicyTypeSummary]
  [PolicyTypeSummary]
  [PolicyTypeSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Root where
  parseJSON :: Value -> Parser Root
parseJSON =
    String -> (Object -> Parser Root) -> Value -> Parser Root
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Root"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe [PolicyTypeSummary] -> Root
Root'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe [PolicyTypeSummary] -> Root)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe [PolicyTypeSummary] -> Root)
forall (f :: * -> *) a b. Functor 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 Text -> Maybe Text -> Maybe [PolicyTypeSummary] -> Root)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe [PolicyTypeSummary] -> Root)
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
"Name")
            Parser (Maybe Text -> Maybe [PolicyTypeSummary] -> Root)
-> Parser (Maybe Text)
-> Parser (Maybe [PolicyTypeSummary] -> Root)
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")
            Parser (Maybe [PolicyTypeSummary] -> Root)
-> Parser (Maybe [PolicyTypeSummary]) -> Parser Root
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [PolicyTypeSummary]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PolicyTypes" Parser (Maybe (Maybe [PolicyTypeSummary]))
-> Maybe [PolicyTypeSummary] -> Parser (Maybe [PolicyTypeSummary])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [PolicyTypeSummary]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Root

instance Prelude.NFData Root