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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains details about an organizational unit (OU). An OU is a container
-- of AWS accounts within a root of an organization. Policies that are
-- attached to an OU apply to all accounts contained in that OU and in any
-- child OUs.
--
-- /See:/ 'newOrganizationalUnit' smart constructor.
data OrganizationalUnit = OrganizationalUnit'
  { -- | The Amazon Resource Name (ARN) of this OU.
    --
    -- 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/.
    OrganizationalUnit -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The friendly name of this OU.
    --
    -- 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.
    OrganizationalUnit -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier (ID) associated with this OU.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for an
    -- organizational unit ID string requires \"ou-\" followed by from 4 to 32
    -- lowercase letters or digits (the ID of the root that contains the OU).
    -- This string is followed by a second \"-\" dash and from 8 to 32
    -- additional lowercase letters or digits.
    OrganizationalUnit -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (OrganizationalUnit -> OrganizationalUnit -> Bool
(OrganizationalUnit -> OrganizationalUnit -> Bool)
-> (OrganizationalUnit -> OrganizationalUnit -> Bool)
-> Eq OrganizationalUnit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OrganizationalUnit -> OrganizationalUnit -> Bool
$c/= :: OrganizationalUnit -> OrganizationalUnit -> Bool
== :: OrganizationalUnit -> OrganizationalUnit -> Bool
$c== :: OrganizationalUnit -> OrganizationalUnit -> Bool
Prelude.Eq, ReadPrec [OrganizationalUnit]
ReadPrec OrganizationalUnit
Int -> ReadS OrganizationalUnit
ReadS [OrganizationalUnit]
(Int -> ReadS OrganizationalUnit)
-> ReadS [OrganizationalUnit]
-> ReadPrec OrganizationalUnit
-> ReadPrec [OrganizationalUnit]
-> Read OrganizationalUnit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OrganizationalUnit]
$creadListPrec :: ReadPrec [OrganizationalUnit]
readPrec :: ReadPrec OrganizationalUnit
$creadPrec :: ReadPrec OrganizationalUnit
readList :: ReadS [OrganizationalUnit]
$creadList :: ReadS [OrganizationalUnit]
readsPrec :: Int -> ReadS OrganizationalUnit
$creadsPrec :: Int -> ReadS OrganizationalUnit
Prelude.Read, Int -> OrganizationalUnit -> ShowS
[OrganizationalUnit] -> ShowS
OrganizationalUnit -> String
(Int -> OrganizationalUnit -> ShowS)
-> (OrganizationalUnit -> String)
-> ([OrganizationalUnit] -> ShowS)
-> Show OrganizationalUnit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OrganizationalUnit] -> ShowS
$cshowList :: [OrganizationalUnit] -> ShowS
show :: OrganizationalUnit -> String
$cshow :: OrganizationalUnit -> String
showsPrec :: Int -> OrganizationalUnit -> ShowS
$cshowsPrec :: Int -> OrganizationalUnit -> ShowS
Prelude.Show, (forall x. OrganizationalUnit -> Rep OrganizationalUnit x)
-> (forall x. Rep OrganizationalUnit x -> OrganizationalUnit)
-> Generic OrganizationalUnit
forall x. Rep OrganizationalUnit x -> OrganizationalUnit
forall x. OrganizationalUnit -> Rep OrganizationalUnit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OrganizationalUnit x -> OrganizationalUnit
$cfrom :: forall x. OrganizationalUnit -> Rep OrganizationalUnit x
Prelude.Generic)

-- |
-- Create a value of 'OrganizationalUnit' 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', 'organizationalUnit_arn' - The Amazon Resource Name (ARN) of this OU.
--
-- 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', 'organizationalUnit_name' - The friendly name of this OU.
--
-- 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', 'organizationalUnit_id' - The unique identifier (ID) associated with this OU.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for an
-- organizational unit ID string requires \"ou-\" followed by from 4 to 32
-- lowercase letters or digits (the ID of the root that contains the OU).
-- This string is followed by a second \"-\" dash and from 8 to 32
-- additional lowercase letters or digits.
newOrganizationalUnit ::
  OrganizationalUnit
newOrganizationalUnit :: OrganizationalUnit
newOrganizationalUnit =
  OrganizationalUnit' :: Maybe Text -> Maybe Text -> Maybe Text -> OrganizationalUnit
OrganizationalUnit'
    { $sel:arn:OrganizationalUnit' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:OrganizationalUnit' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:OrganizationalUnit' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | The unique identifier (ID) associated with this OU.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for an
-- organizational unit ID string requires \"ou-\" followed by from 4 to 32
-- lowercase letters or digits (the ID of the root that contains the OU).
-- This string is followed by a second \"-\" dash and from 8 to 32
-- additional lowercase letters or digits.
organizationalUnit_id :: Lens.Lens' OrganizationalUnit (Prelude.Maybe Prelude.Text)
organizationalUnit_id :: (Maybe Text -> f (Maybe Text))
-> OrganizationalUnit -> f OrganizationalUnit
organizationalUnit_id = (OrganizationalUnit -> Maybe Text)
-> (OrganizationalUnit -> Maybe Text -> OrganizationalUnit)
-> Lens
     OrganizationalUnit OrganizationalUnit (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrganizationalUnit' {Maybe Text
id :: Maybe Text
$sel:id:OrganizationalUnit' :: OrganizationalUnit -> Maybe Text
id} -> Maybe Text
id) (\s :: OrganizationalUnit
s@OrganizationalUnit' {} Maybe Text
a -> OrganizationalUnit
s {$sel:id:OrganizationalUnit' :: Maybe Text
id = Maybe Text
a} :: OrganizationalUnit)

instance Core.FromJSON OrganizationalUnit where
  parseJSON :: Value -> Parser OrganizationalUnit
parseJSON =
    String
-> (Object -> Parser OrganizationalUnit)
-> Value
-> Parser OrganizationalUnit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OrganizationalUnit"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> OrganizationalUnit
OrganizationalUnit'
            (Maybe Text -> Maybe Text -> Maybe Text -> OrganizationalUnit)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> OrganizationalUnit)
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 -> OrganizationalUnit)
-> Parser (Maybe Text) -> Parser (Maybe Text -> OrganizationalUnit)
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 -> OrganizationalUnit)
-> Parser (Maybe Text) -> Parser OrganizationalUnit
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 OrganizationalUnit

instance Prelude.NFData OrganizationalUnit