{-# 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.CloudDirectory.Types.PolicyAttachment
-- 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.CloudDirectory.Types.PolicyAttachment 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

-- | Contains the @PolicyType@, @PolicyId@, and the @ObjectIdentifier@ to
-- which it is attached. For more information, see
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/key_concepts_directory.html#key_concepts_policies Policies>.
--
-- /See:/ 'newPolicyAttachment' smart constructor.
data PolicyAttachment = PolicyAttachment'
  { -- | The @ObjectIdentifier@ that is associated with @PolicyAttachment@.
    PolicyAttachment -> Maybe Text
objectIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The ID of @PolicyAttachment@.
    PolicyAttachment -> Maybe Text
policyId :: Prelude.Maybe Prelude.Text,
    -- | The type of policy that can be associated with @PolicyAttachment@.
    PolicyAttachment -> Maybe Text
policyType :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyAttachment -> PolicyAttachment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyAttachment -> PolicyAttachment -> Bool
$c/= :: PolicyAttachment -> PolicyAttachment -> Bool
== :: PolicyAttachment -> PolicyAttachment -> Bool
$c== :: PolicyAttachment -> PolicyAttachment -> Bool
Prelude.Eq, ReadPrec [PolicyAttachment]
ReadPrec PolicyAttachment
Int -> ReadS PolicyAttachment
ReadS [PolicyAttachment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyAttachment]
$creadListPrec :: ReadPrec [PolicyAttachment]
readPrec :: ReadPrec PolicyAttachment
$creadPrec :: ReadPrec PolicyAttachment
readList :: ReadS [PolicyAttachment]
$creadList :: ReadS [PolicyAttachment]
readsPrec :: Int -> ReadS PolicyAttachment
$creadsPrec :: Int -> ReadS PolicyAttachment
Prelude.Read, Int -> PolicyAttachment -> ShowS
[PolicyAttachment] -> ShowS
PolicyAttachment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyAttachment] -> ShowS
$cshowList :: [PolicyAttachment] -> ShowS
show :: PolicyAttachment -> String
$cshow :: PolicyAttachment -> String
showsPrec :: Int -> PolicyAttachment -> ShowS
$cshowsPrec :: Int -> PolicyAttachment -> ShowS
Prelude.Show, forall x. Rep PolicyAttachment x -> PolicyAttachment
forall x. PolicyAttachment -> Rep PolicyAttachment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyAttachment x -> PolicyAttachment
$cfrom :: forall x. PolicyAttachment -> Rep PolicyAttachment x
Prelude.Generic)

-- |
-- Create a value of 'PolicyAttachment' 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:
--
-- 'objectIdentifier', 'policyAttachment_objectIdentifier' - The @ObjectIdentifier@ that is associated with @PolicyAttachment@.
--
-- 'policyId', 'policyAttachment_policyId' - The ID of @PolicyAttachment@.
--
-- 'policyType', 'policyAttachment_policyType' - The type of policy that can be associated with @PolicyAttachment@.
newPolicyAttachment ::
  PolicyAttachment
newPolicyAttachment :: PolicyAttachment
newPolicyAttachment =
  PolicyAttachment'
    { $sel:objectIdentifier:PolicyAttachment' :: Maybe Text
objectIdentifier =
        forall a. Maybe a
Prelude.Nothing,
      $sel:policyId:PolicyAttachment' :: Maybe Text
policyId = forall a. Maybe a
Prelude.Nothing,
      $sel:policyType:PolicyAttachment' :: Maybe Text
policyType = forall a. Maybe a
Prelude.Nothing
    }

-- | The @ObjectIdentifier@ that is associated with @PolicyAttachment@.
policyAttachment_objectIdentifier :: Lens.Lens' PolicyAttachment (Prelude.Maybe Prelude.Text)
policyAttachment_objectIdentifier :: Lens' PolicyAttachment (Maybe Text)
policyAttachment_objectIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyAttachment' {Maybe Text
objectIdentifier :: Maybe Text
$sel:objectIdentifier:PolicyAttachment' :: PolicyAttachment -> Maybe Text
objectIdentifier} -> Maybe Text
objectIdentifier) (\s :: PolicyAttachment
s@PolicyAttachment' {} Maybe Text
a -> PolicyAttachment
s {$sel:objectIdentifier:PolicyAttachment' :: Maybe Text
objectIdentifier = Maybe Text
a} :: PolicyAttachment)

-- | The ID of @PolicyAttachment@.
policyAttachment_policyId :: Lens.Lens' PolicyAttachment (Prelude.Maybe Prelude.Text)
policyAttachment_policyId :: Lens' PolicyAttachment (Maybe Text)
policyAttachment_policyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyAttachment' {Maybe Text
policyId :: Maybe Text
$sel:policyId:PolicyAttachment' :: PolicyAttachment -> Maybe Text
policyId} -> Maybe Text
policyId) (\s :: PolicyAttachment
s@PolicyAttachment' {} Maybe Text
a -> PolicyAttachment
s {$sel:policyId:PolicyAttachment' :: Maybe Text
policyId = Maybe Text
a} :: PolicyAttachment)

-- | The type of policy that can be associated with @PolicyAttachment@.
policyAttachment_policyType :: Lens.Lens' PolicyAttachment (Prelude.Maybe Prelude.Text)
policyAttachment_policyType :: Lens' PolicyAttachment (Maybe Text)
policyAttachment_policyType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyAttachment' {Maybe Text
policyType :: Maybe Text
$sel:policyType:PolicyAttachment' :: PolicyAttachment -> Maybe Text
policyType} -> Maybe Text
policyType) (\s :: PolicyAttachment
s@PolicyAttachment' {} Maybe Text
a -> PolicyAttachment
s {$sel:policyType:PolicyAttachment' :: Maybe Text
policyType = Maybe Text
a} :: PolicyAttachment)

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

instance Prelude.Hashable PolicyAttachment where
  hashWithSalt :: Int -> PolicyAttachment -> Int
hashWithSalt Int
_salt PolicyAttachment' {Maybe Text
policyType :: Maybe Text
policyId :: Maybe Text
objectIdentifier :: Maybe Text
$sel:policyType:PolicyAttachment' :: PolicyAttachment -> Maybe Text
$sel:policyId:PolicyAttachment' :: PolicyAttachment -> Maybe Text
$sel:objectIdentifier:PolicyAttachment' :: PolicyAttachment -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
objectIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policyType

instance Prelude.NFData PolicyAttachment where
  rnf :: PolicyAttachment -> ()
rnf PolicyAttachment' {Maybe Text
policyType :: Maybe Text
policyId :: Maybe Text
objectIdentifier :: Maybe Text
$sel:policyType:PolicyAttachment' :: PolicyAttachment -> Maybe Text
$sel:policyId:PolicyAttachment' :: PolicyAttachment -> Maybe Text
$sel:objectIdentifier:PolicyAttachment' :: PolicyAttachment -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
objectIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyType