{-# 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.SSOAdmin.Types.CustomerManagedPolicyReference
-- 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.SSOAdmin.Types.CustomerManagedPolicyReference where

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

-- | Specifies the name and path of a customer managed policy. You must have
-- an IAM policy that matches the name and path in each AWS account where
-- you want to deploy your permission set.
--
-- /See:/ 'newCustomerManagedPolicyReference' smart constructor.
data CustomerManagedPolicyReference = CustomerManagedPolicyReference'
  { -- | The path to the IAM policy that you have configured in each account
    -- where you want to deploy your permission set. The default is @\/@. For
    -- more information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-friendly-names Friendly names and paths>
    -- in the /IAM User Guide/.
    CustomerManagedPolicyReference -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The name of the IAM policy that you have configured in each account
    -- where you want to deploy your permission set.
    CustomerManagedPolicyReference -> Text
name :: Prelude.Text
  }
  deriving (CustomerManagedPolicyReference
-> CustomerManagedPolicyReference -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomerManagedPolicyReference
-> CustomerManagedPolicyReference -> Bool
$c/= :: CustomerManagedPolicyReference
-> CustomerManagedPolicyReference -> Bool
== :: CustomerManagedPolicyReference
-> CustomerManagedPolicyReference -> Bool
$c== :: CustomerManagedPolicyReference
-> CustomerManagedPolicyReference -> Bool
Prelude.Eq, ReadPrec [CustomerManagedPolicyReference]
ReadPrec CustomerManagedPolicyReference
Int -> ReadS CustomerManagedPolicyReference
ReadS [CustomerManagedPolicyReference]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomerManagedPolicyReference]
$creadListPrec :: ReadPrec [CustomerManagedPolicyReference]
readPrec :: ReadPrec CustomerManagedPolicyReference
$creadPrec :: ReadPrec CustomerManagedPolicyReference
readList :: ReadS [CustomerManagedPolicyReference]
$creadList :: ReadS [CustomerManagedPolicyReference]
readsPrec :: Int -> ReadS CustomerManagedPolicyReference
$creadsPrec :: Int -> ReadS CustomerManagedPolicyReference
Prelude.Read, Int -> CustomerManagedPolicyReference -> ShowS
[CustomerManagedPolicyReference] -> ShowS
CustomerManagedPolicyReference -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomerManagedPolicyReference] -> ShowS
$cshowList :: [CustomerManagedPolicyReference] -> ShowS
show :: CustomerManagedPolicyReference -> String
$cshow :: CustomerManagedPolicyReference -> String
showsPrec :: Int -> CustomerManagedPolicyReference -> ShowS
$cshowsPrec :: Int -> CustomerManagedPolicyReference -> ShowS
Prelude.Show, forall x.
Rep CustomerManagedPolicyReference x
-> CustomerManagedPolicyReference
forall x.
CustomerManagedPolicyReference
-> Rep CustomerManagedPolicyReference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomerManagedPolicyReference x
-> CustomerManagedPolicyReference
$cfrom :: forall x.
CustomerManagedPolicyReference
-> Rep CustomerManagedPolicyReference x
Prelude.Generic)

-- |
-- Create a value of 'CustomerManagedPolicyReference' 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:
--
-- 'path', 'customerManagedPolicyReference_path' - The path to the IAM policy that you have configured in each account
-- where you want to deploy your permission set. The default is @\/@. For
-- more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-friendly-names Friendly names and paths>
-- in the /IAM User Guide/.
--
-- 'name', 'customerManagedPolicyReference_name' - The name of the IAM policy that you have configured in each account
-- where you want to deploy your permission set.
newCustomerManagedPolicyReference ::
  -- | 'name'
  Prelude.Text ->
  CustomerManagedPolicyReference
newCustomerManagedPolicyReference :: Text -> CustomerManagedPolicyReference
newCustomerManagedPolicyReference Text
pName_ =
  CustomerManagedPolicyReference'
    { $sel:path:CustomerManagedPolicyReference' :: Maybe Text
path =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:CustomerManagedPolicyReference' :: Text
name = Text
pName_
    }

-- | The path to the IAM policy that you have configured in each account
-- where you want to deploy your permission set. The default is @\/@. For
-- more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-friendly-names Friendly names and paths>
-- in the /IAM User Guide/.
customerManagedPolicyReference_path :: Lens.Lens' CustomerManagedPolicyReference (Prelude.Maybe Prelude.Text)
customerManagedPolicyReference_path :: Lens' CustomerManagedPolicyReference (Maybe Text)
customerManagedPolicyReference_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerManagedPolicyReference' {Maybe Text
path :: Maybe Text
$sel:path:CustomerManagedPolicyReference' :: CustomerManagedPolicyReference -> Maybe Text
path} -> Maybe Text
path) (\s :: CustomerManagedPolicyReference
s@CustomerManagedPolicyReference' {} Maybe Text
a -> CustomerManagedPolicyReference
s {$sel:path:CustomerManagedPolicyReference' :: Maybe Text
path = Maybe Text
a} :: CustomerManagedPolicyReference)

-- | The name of the IAM policy that you have configured in each account
-- where you want to deploy your permission set.
customerManagedPolicyReference_name :: Lens.Lens' CustomerManagedPolicyReference Prelude.Text
customerManagedPolicyReference_name :: Lens' CustomerManagedPolicyReference Text
customerManagedPolicyReference_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerManagedPolicyReference' {Text
name :: Text
$sel:name:CustomerManagedPolicyReference' :: CustomerManagedPolicyReference -> Text
name} -> Text
name) (\s :: CustomerManagedPolicyReference
s@CustomerManagedPolicyReference' {} Text
a -> CustomerManagedPolicyReference
s {$sel:name:CustomerManagedPolicyReference' :: Text
name = Text
a} :: CustomerManagedPolicyReference)

instance Data.FromJSON CustomerManagedPolicyReference where
  parseJSON :: Value -> Parser CustomerManagedPolicyReference
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomerManagedPolicyReference"
      ( \Object
x ->
          Maybe Text -> Text -> CustomerManagedPolicyReference
CustomerManagedPolicyReference'
            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
"Path")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
      )

instance
  Prelude.Hashable
    CustomerManagedPolicyReference
  where
  hashWithSalt :: Int -> CustomerManagedPolicyReference -> Int
hashWithSalt
    Int
_salt
    CustomerManagedPolicyReference' {Maybe Text
Text
name :: Text
path :: Maybe Text
$sel:name:CustomerManagedPolicyReference' :: CustomerManagedPolicyReference -> Text
$sel:path:CustomerManagedPolicyReference' :: CustomerManagedPolicyReference -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance
  Prelude.NFData
    CustomerManagedPolicyReference
  where
  rnf :: CustomerManagedPolicyReference -> ()
rnf CustomerManagedPolicyReference' {Maybe Text
Text
name :: Text
path :: Maybe Text
$sel:name:CustomerManagedPolicyReference' :: CustomerManagedPolicyReference -> Text
$sel:path:CustomerManagedPolicyReference' :: CustomerManagedPolicyReference -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToJSON CustomerManagedPolicyReference where
  toJSON :: CustomerManagedPolicyReference -> Value
toJSON CustomerManagedPolicyReference' {Maybe Text
Text
name :: Text
path :: Maybe Text
$sel:name:CustomerManagedPolicyReference' :: CustomerManagedPolicyReference -> Text
$sel:path:CustomerManagedPolicyReference' :: CustomerManagedPolicyReference -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
path,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )