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

-- | Contains information about a root, OU, or account that a policy is
-- attached to.
--
-- /See:/ 'newPolicyTargetSummary' smart constructor.
data PolicyTargetSummary = PolicyTargetSummary'
  { -- | The Amazon Resource Name (ARN) of the policy target.
    --
    -- 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/.
    PolicyTargetSummary -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The friendly name of the policy target.
    --
    -- 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.
    PolicyTargetSummary -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier (ID) of the policy target.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for a target ID
    -- string requires one of the following:
    --
    -- -   __Root__ - A string that begins with \"r-\" followed by from 4 to 32
    --     lowercase letters or digits.
    --
    -- -   __Account__ - A string that consists of exactly 12 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.
    PolicyTargetSummary -> Maybe Text
targetId :: Prelude.Maybe Prelude.Text,
    -- | The type of the policy target.
    PolicyTargetSummary -> Maybe TargetType
type' :: Prelude.Maybe TargetType
  }
  deriving (PolicyTargetSummary -> PolicyTargetSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyTargetSummary -> PolicyTargetSummary -> Bool
$c/= :: PolicyTargetSummary -> PolicyTargetSummary -> Bool
== :: PolicyTargetSummary -> PolicyTargetSummary -> Bool
$c== :: PolicyTargetSummary -> PolicyTargetSummary -> Bool
Prelude.Eq, ReadPrec [PolicyTargetSummary]
ReadPrec PolicyTargetSummary
Int -> ReadS PolicyTargetSummary
ReadS [PolicyTargetSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyTargetSummary]
$creadListPrec :: ReadPrec [PolicyTargetSummary]
readPrec :: ReadPrec PolicyTargetSummary
$creadPrec :: ReadPrec PolicyTargetSummary
readList :: ReadS [PolicyTargetSummary]
$creadList :: ReadS [PolicyTargetSummary]
readsPrec :: Int -> ReadS PolicyTargetSummary
$creadsPrec :: Int -> ReadS PolicyTargetSummary
Prelude.Read, Int -> PolicyTargetSummary -> ShowS
[PolicyTargetSummary] -> ShowS
PolicyTargetSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyTargetSummary] -> ShowS
$cshowList :: [PolicyTargetSummary] -> ShowS
show :: PolicyTargetSummary -> String
$cshow :: PolicyTargetSummary -> String
showsPrec :: Int -> PolicyTargetSummary -> ShowS
$cshowsPrec :: Int -> PolicyTargetSummary -> ShowS
Prelude.Show, forall x. Rep PolicyTargetSummary x -> PolicyTargetSummary
forall x. PolicyTargetSummary -> Rep PolicyTargetSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyTargetSummary x -> PolicyTargetSummary
$cfrom :: forall x. PolicyTargetSummary -> Rep PolicyTargetSummary x
Prelude.Generic)

-- |
-- Create a value of 'PolicyTargetSummary' 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', 'policyTargetSummary_arn' - The Amazon Resource Name (ARN) of the policy target.
--
-- 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/.
--
-- 'name', 'policyTargetSummary_name' - The friendly name of the policy target.
--
-- 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.
--
-- 'targetId', 'policyTargetSummary_targetId' - The unique identifier (ID) of the policy target.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a target ID
-- string requires one of the following:
--
-- -   __Root__ - A string that begins with \"r-\" followed by from 4 to 32
--     lowercase letters or digits.
--
-- -   __Account__ - A string that consists of exactly 12 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'', 'policyTargetSummary_type' - The type of the policy target.
newPolicyTargetSummary ::
  PolicyTargetSummary
newPolicyTargetSummary :: PolicyTargetSummary
newPolicyTargetSummary =
  PolicyTargetSummary'
    { $sel:arn:PolicyTargetSummary' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:name:PolicyTargetSummary' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:targetId:PolicyTargetSummary' :: Maybe Text
targetId = forall a. Maybe a
Prelude.Nothing,
      $sel:type':PolicyTargetSummary' :: Maybe TargetType
type' = forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | The unique identifier (ID) of the policy target.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a target ID
-- string requires one of the following:
--
-- -   __Root__ - A string that begins with \"r-\" followed by from 4 to 32
--     lowercase letters or digits.
--
-- -   __Account__ - A string that consists of exactly 12 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.
policyTargetSummary_targetId :: Lens.Lens' PolicyTargetSummary (Prelude.Maybe Prelude.Text)
policyTargetSummary_targetId :: Lens' PolicyTargetSummary (Maybe Text)
policyTargetSummary_targetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyTargetSummary' {Maybe Text
targetId :: Maybe Text
$sel:targetId:PolicyTargetSummary' :: PolicyTargetSummary -> Maybe Text
targetId} -> Maybe Text
targetId) (\s :: PolicyTargetSummary
s@PolicyTargetSummary' {} Maybe Text
a -> PolicyTargetSummary
s {$sel:targetId:PolicyTargetSummary' :: Maybe Text
targetId = Maybe Text
a} :: PolicyTargetSummary)

-- | The type of the policy target.
policyTargetSummary_type :: Lens.Lens' PolicyTargetSummary (Prelude.Maybe TargetType)
policyTargetSummary_type :: Lens' PolicyTargetSummary (Maybe TargetType)
policyTargetSummary_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyTargetSummary' {Maybe TargetType
type' :: Maybe TargetType
$sel:type':PolicyTargetSummary' :: PolicyTargetSummary -> Maybe TargetType
type'} -> Maybe TargetType
type') (\s :: PolicyTargetSummary
s@PolicyTargetSummary' {} Maybe TargetType
a -> PolicyTargetSummary
s {$sel:type':PolicyTargetSummary' :: Maybe TargetType
type' = Maybe TargetType
a} :: PolicyTargetSummary)

instance Data.FromJSON PolicyTargetSummary where
  parseJSON :: Value -> Parser PolicyTargetSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PolicyTargetSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe TargetType
-> PolicyTargetSummary
PolicyTargetSummary'
            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
"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
"TargetId")
            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 PolicyTargetSummary where
  hashWithSalt :: Int -> PolicyTargetSummary -> Int
hashWithSalt Int
_salt PolicyTargetSummary' {Maybe Text
Maybe TargetType
type' :: Maybe TargetType
targetId :: Maybe Text
name :: Maybe Text
arn :: Maybe Text
$sel:type':PolicyTargetSummary' :: PolicyTargetSummary -> Maybe TargetType
$sel:targetId:PolicyTargetSummary' :: PolicyTargetSummary -> Maybe Text
$sel:name:PolicyTargetSummary' :: PolicyTargetSummary -> Maybe Text
$sel:arn:PolicyTargetSummary' :: PolicyTargetSummary -> 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 Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TargetType
type'

instance Prelude.NFData PolicyTargetSummary where
  rnf :: PolicyTargetSummary -> ()
rnf PolicyTargetSummary' {Maybe Text
Maybe TargetType
type' :: Maybe TargetType
targetId :: Maybe Text
name :: Maybe Text
arn :: Maybe Text
$sel:type':PolicyTargetSummary' :: PolicyTargetSummary -> Maybe TargetType
$sel:targetId:PolicyTargetSummary' :: PolicyTargetSummary -> Maybe Text
$sel:name:PolicyTargetSummary' :: PolicyTargetSummary -> Maybe Text
$sel:arn:PolicyTargetSummary' :: PolicyTargetSummary -> 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 Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TargetType
type'