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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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 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 /AWS 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 type of the policy target.
    PolicyTargetSummary -> Maybe TargetType
type' :: Prelude.Maybe TargetType
  }
  deriving (PolicyTargetSummary -> PolicyTargetSummary -> Bool
(PolicyTargetSummary -> PolicyTargetSummary -> Bool)
-> (PolicyTargetSummary -> PolicyTargetSummary -> Bool)
-> Eq PolicyTargetSummary
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]
(Int -> ReadS PolicyTargetSummary)
-> ReadS [PolicyTargetSummary]
-> ReadPrec PolicyTargetSummary
-> ReadPrec [PolicyTargetSummary]
-> Read 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
(Int -> PolicyTargetSummary -> ShowS)
-> (PolicyTargetSummary -> String)
-> ([PolicyTargetSummary] -> ShowS)
-> Show PolicyTargetSummary
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. PolicyTargetSummary -> Rep PolicyTargetSummary x)
-> (forall x. Rep PolicyTargetSummary x -> PolicyTargetSummary)
-> Generic PolicyTargetSummary
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:
--
-- '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.
--
-- '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 /AWS 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.
--
-- 'type'', 'policyTargetSummary_type' - The type of the policy target.
newPolicyTargetSummary ::
  PolicyTargetSummary
newPolicyTargetSummary :: PolicyTargetSummary
newPolicyTargetSummary =
  PolicyTargetSummary' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe TargetType
-> PolicyTargetSummary
PolicyTargetSummary'
    { $sel:targetId:PolicyTargetSummary' :: Maybe Text
targetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:PolicyTargetSummary' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:PolicyTargetSummary' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':PolicyTargetSummary' :: Maybe TargetType
type' = Maybe TargetType
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> PolicyTargetSummary -> f PolicyTargetSummary
policyTargetSummary_targetId = (PolicyTargetSummary -> Maybe Text)
-> (PolicyTargetSummary -> Maybe Text -> PolicyTargetSummary)
-> Lens
     PolicyTargetSummary PolicyTargetSummary (Maybe Text) (Maybe Text)
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 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 /AWS Service Authorization Reference/.
policyTargetSummary_arn :: Lens.Lens' PolicyTargetSummary (Prelude.Maybe Prelude.Text)
policyTargetSummary_arn :: (Maybe Text -> f (Maybe Text))
-> PolicyTargetSummary -> f PolicyTargetSummary
policyTargetSummary_arn = (PolicyTargetSummary -> Maybe Text)
-> (PolicyTargetSummary -> Maybe Text -> PolicyTargetSummary)
-> Lens
     PolicyTargetSummary PolicyTargetSummary (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> PolicyTargetSummary -> f PolicyTargetSummary
policyTargetSummary_name = (PolicyTargetSummary -> Maybe Text)
-> (PolicyTargetSummary -> Maybe Text -> PolicyTargetSummary)
-> Lens
     PolicyTargetSummary PolicyTargetSummary (Maybe Text) (Maybe Text)
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 type of the policy target.
policyTargetSummary_type :: Lens.Lens' PolicyTargetSummary (Prelude.Maybe TargetType)
policyTargetSummary_type :: (Maybe TargetType -> f (Maybe TargetType))
-> PolicyTargetSummary -> f PolicyTargetSummary
policyTargetSummary_type = (PolicyTargetSummary -> Maybe TargetType)
-> (PolicyTargetSummary -> Maybe TargetType -> PolicyTargetSummary)
-> Lens
     PolicyTargetSummary
     PolicyTargetSummary
     (Maybe TargetType)
     (Maybe TargetType)
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 Core.FromJSON PolicyTargetSummary where
  parseJSON :: Value -> Parser PolicyTargetSummary
parseJSON =
    String
-> (Object -> Parser PolicyTargetSummary)
-> Value
-> Parser PolicyTargetSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PolicyTargetSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe TargetType
-> PolicyTargetSummary
PolicyTargetSummary'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe TargetType
 -> PolicyTargetSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe TargetType -> PolicyTargetSummary)
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
"TargetId")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe TargetType -> PolicyTargetSummary)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe TargetType -> PolicyTargetSummary)
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
"Arn")
            Parser (Maybe Text -> Maybe TargetType -> PolicyTargetSummary)
-> Parser (Maybe Text)
-> Parser (Maybe TargetType -> PolicyTargetSummary)
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 TargetType -> PolicyTargetSummary)
-> Parser (Maybe TargetType) -> Parser PolicyTargetSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TargetType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable PolicyTargetSummary

instance Prelude.NFData PolicyTargetSummary