{-# 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.Parent
-- 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.Parent 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.ParentType
import qualified Amazonka.Prelude as Prelude

-- | Contains information about either a root or an organizational unit (OU)
-- that can contain OUs or accounts in an organization.
--
-- /See:/ 'newParent' smart constructor.
data Parent = Parent'
  { -- | The unique identifier (ID) of the parent entity.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for a parent ID
    -- string requires one of the following:
    --
    -- -   __Root__ - A string that begins with \"r-\" followed by from 4 to 32
    --     lowercase letters or digits.
    --
    -- -   __Organizational unit (OU)__ - A string that begins with \"ou-\"
    --     followed by from 4 to 32 lowercase letters or digits (the ID of the
    --     root that the OU is in). This string is followed by a second \"-\"
    --     dash and from 8 to 32 additional lowercase letters or digits.
    Parent -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The type of the parent entity.
    Parent -> Maybe ParentType
type' :: Prelude.Maybe ParentType
  }
  deriving (Parent -> Parent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Parent -> Parent -> Bool
$c/= :: Parent -> Parent -> Bool
== :: Parent -> Parent -> Bool
$c== :: Parent -> Parent -> Bool
Prelude.Eq, ReadPrec [Parent]
ReadPrec Parent
Int -> ReadS Parent
ReadS [Parent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Parent]
$creadListPrec :: ReadPrec [Parent]
readPrec :: ReadPrec Parent
$creadPrec :: ReadPrec Parent
readList :: ReadS [Parent]
$creadList :: ReadS [Parent]
readsPrec :: Int -> ReadS Parent
$creadsPrec :: Int -> ReadS Parent
Prelude.Read, Int -> Parent -> ShowS
[Parent] -> ShowS
Parent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Parent] -> ShowS
$cshowList :: [Parent] -> ShowS
show :: Parent -> String
$cshow :: Parent -> String
showsPrec :: Int -> Parent -> ShowS
$cshowsPrec :: Int -> Parent -> ShowS
Prelude.Show, forall x. Rep Parent x -> Parent
forall x. Parent -> Rep Parent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Parent x -> Parent
$cfrom :: forall x. Parent -> Rep Parent x
Prelude.Generic)

-- |
-- Create a value of 'Parent' 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:
--
-- 'id', 'parent_id' - The unique identifier (ID) of the parent entity.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a parent ID
-- string requires one of the following:
--
-- -   __Root__ - A string that begins with \"r-\" followed by from 4 to 32
--     lowercase letters or digits.
--
-- -   __Organizational unit (OU)__ - A string that begins with \"ou-\"
--     followed by from 4 to 32 lowercase letters or digits (the ID of the
--     root that the OU is in). This string is followed by a second \"-\"
--     dash and from 8 to 32 additional lowercase letters or digits.
--
-- 'type'', 'parent_type' - The type of the parent entity.
newParent ::
  Parent
newParent :: Parent
newParent =
  Parent'
    { $sel:id:Parent' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Parent' :: Maybe ParentType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier (ID) of the parent entity.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a parent ID
-- string requires one of the following:
--
-- -   __Root__ - A string that begins with \"r-\" followed by from 4 to 32
--     lowercase letters or digits.
--
-- -   __Organizational unit (OU)__ - A string that begins with \"ou-\"
--     followed by from 4 to 32 lowercase letters or digits (the ID of the
--     root that the OU is in). This string is followed by a second \"-\"
--     dash and from 8 to 32 additional lowercase letters or digits.
parent_id :: Lens.Lens' Parent (Prelude.Maybe Prelude.Text)
parent_id :: Lens' Parent (Maybe Text)
parent_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Parent' {Maybe Text
id :: Maybe Text
$sel:id:Parent' :: Parent -> Maybe Text
id} -> Maybe Text
id) (\s :: Parent
s@Parent' {} Maybe Text
a -> Parent
s {$sel:id:Parent' :: Maybe Text
id = Maybe Text
a} :: Parent)

-- | The type of the parent entity.
parent_type :: Lens.Lens' Parent (Prelude.Maybe ParentType)
parent_type :: Lens' Parent (Maybe ParentType)
parent_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Parent' {Maybe ParentType
type' :: Maybe ParentType
$sel:type':Parent' :: Parent -> Maybe ParentType
type'} -> Maybe ParentType
type') (\s :: Parent
s@Parent' {} Maybe ParentType
a -> Parent
s {$sel:type':Parent' :: Maybe ParentType
type' = Maybe ParentType
a} :: Parent)

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

instance Prelude.Hashable Parent where
  hashWithSalt :: Int -> Parent -> Int
hashWithSalt Int
_salt Parent' {Maybe Text
Maybe ParentType
type' :: Maybe ParentType
id :: Maybe Text
$sel:type':Parent' :: Parent -> Maybe ParentType
$sel:id:Parent' :: Parent -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ParentType
type'

instance Prelude.NFData Parent where
  rnf :: Parent -> ()
rnf Parent' {Maybe Text
Maybe ParentType
type' :: Maybe ParentType
id :: Maybe Text
$sel:type':Parent' :: Parent -> Maybe ParentType
$sel:id:Parent' :: Parent -> Maybe Text
..} =
    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 ParentType
type'