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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | The @ObjectIdentifier@ that is associated with @PolicyAttachment@.
    PolicyAttachment -> Maybe Text
objectIdentifier :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyAttachment -> PolicyAttachment -> Bool
(PolicyAttachment -> PolicyAttachment -> Bool)
-> (PolicyAttachment -> PolicyAttachment -> Bool)
-> Eq PolicyAttachment
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]
(Int -> ReadS PolicyAttachment)
-> ReadS [PolicyAttachment]
-> ReadPrec PolicyAttachment
-> ReadPrec [PolicyAttachment]
-> Read 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
(Int -> PolicyAttachment -> ShowS)
-> (PolicyAttachment -> String)
-> ([PolicyAttachment] -> ShowS)
-> Show PolicyAttachment
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. PolicyAttachment -> Rep PolicyAttachment x)
-> (forall x. Rep PolicyAttachment x -> PolicyAttachment)
-> Generic PolicyAttachment
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:
--
-- 'policyId', 'policyAttachment_policyId' - The ID of @PolicyAttachment@.
--
-- 'policyType', 'policyAttachment_policyType' - The type of policy that can be associated with @PolicyAttachment@.
--
-- 'objectIdentifier', 'policyAttachment_objectIdentifier' - The @ObjectIdentifier@ that is associated with @PolicyAttachment@.
newPolicyAttachment ::
  PolicyAttachment
newPolicyAttachment :: PolicyAttachment
newPolicyAttachment =
  PolicyAttachment' :: Maybe Text -> Maybe Text -> Maybe Text -> PolicyAttachment
PolicyAttachment'
    { $sel:policyId:PolicyAttachment' :: Maybe Text
policyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policyType:PolicyAttachment' :: Maybe Text
policyType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:objectIdentifier:PolicyAttachment' :: Maybe Text
objectIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of @PolicyAttachment@.
policyAttachment_policyId :: Lens.Lens' PolicyAttachment (Prelude.Maybe Prelude.Text)
policyAttachment_policyId :: (Maybe Text -> f (Maybe Text))
-> PolicyAttachment -> f PolicyAttachment
policyAttachment_policyId = (PolicyAttachment -> Maybe Text)
-> (PolicyAttachment -> Maybe Text -> PolicyAttachment)
-> Lens PolicyAttachment PolicyAttachment (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> PolicyAttachment -> f PolicyAttachment
policyAttachment_policyType = (PolicyAttachment -> Maybe Text)
-> (PolicyAttachment -> Maybe Text -> PolicyAttachment)
-> Lens PolicyAttachment PolicyAttachment (Maybe Text) (Maybe Text)
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)

-- | The @ObjectIdentifier@ that is associated with @PolicyAttachment@.
policyAttachment_objectIdentifier :: Lens.Lens' PolicyAttachment (Prelude.Maybe Prelude.Text)
policyAttachment_objectIdentifier :: (Maybe Text -> f (Maybe Text))
-> PolicyAttachment -> f PolicyAttachment
policyAttachment_objectIdentifier = (PolicyAttachment -> Maybe Text)
-> (PolicyAttachment -> Maybe Text -> PolicyAttachment)
-> Lens PolicyAttachment PolicyAttachment (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable PolicyAttachment

instance Prelude.NFData PolicyAttachment