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

import Amazonka.CloudDirectory.Types.ObjectReference
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Attaches a policy object to a regular object inside a BatchRead
-- operation. For more information, see AttachPolicy and
-- BatchReadRequest$Operations.
--
-- /See:/ 'newBatchAttachPolicy' smart constructor.
data BatchAttachPolicy = BatchAttachPolicy'
  { -- | The reference that is associated with the policy object.
    BatchAttachPolicy -> ObjectReference
policyReference :: ObjectReference,
    -- | The reference that identifies the object to which the policy will be
    -- attached.
    BatchAttachPolicy -> ObjectReference
objectReference :: ObjectReference
  }
  deriving (BatchAttachPolicy -> BatchAttachPolicy -> Bool
(BatchAttachPolicy -> BatchAttachPolicy -> Bool)
-> (BatchAttachPolicy -> BatchAttachPolicy -> Bool)
-> Eq BatchAttachPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchAttachPolicy -> BatchAttachPolicy -> Bool
$c/= :: BatchAttachPolicy -> BatchAttachPolicy -> Bool
== :: BatchAttachPolicy -> BatchAttachPolicy -> Bool
$c== :: BatchAttachPolicy -> BatchAttachPolicy -> Bool
Prelude.Eq, ReadPrec [BatchAttachPolicy]
ReadPrec BatchAttachPolicy
Int -> ReadS BatchAttachPolicy
ReadS [BatchAttachPolicy]
(Int -> ReadS BatchAttachPolicy)
-> ReadS [BatchAttachPolicy]
-> ReadPrec BatchAttachPolicy
-> ReadPrec [BatchAttachPolicy]
-> Read BatchAttachPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchAttachPolicy]
$creadListPrec :: ReadPrec [BatchAttachPolicy]
readPrec :: ReadPrec BatchAttachPolicy
$creadPrec :: ReadPrec BatchAttachPolicy
readList :: ReadS [BatchAttachPolicy]
$creadList :: ReadS [BatchAttachPolicy]
readsPrec :: Int -> ReadS BatchAttachPolicy
$creadsPrec :: Int -> ReadS BatchAttachPolicy
Prelude.Read, Int -> BatchAttachPolicy -> ShowS
[BatchAttachPolicy] -> ShowS
BatchAttachPolicy -> String
(Int -> BatchAttachPolicy -> ShowS)
-> (BatchAttachPolicy -> String)
-> ([BatchAttachPolicy] -> ShowS)
-> Show BatchAttachPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchAttachPolicy] -> ShowS
$cshowList :: [BatchAttachPolicy] -> ShowS
show :: BatchAttachPolicy -> String
$cshow :: BatchAttachPolicy -> String
showsPrec :: Int -> BatchAttachPolicy -> ShowS
$cshowsPrec :: Int -> BatchAttachPolicy -> ShowS
Prelude.Show, (forall x. BatchAttachPolicy -> Rep BatchAttachPolicy x)
-> (forall x. Rep BatchAttachPolicy x -> BatchAttachPolicy)
-> Generic BatchAttachPolicy
forall x. Rep BatchAttachPolicy x -> BatchAttachPolicy
forall x. BatchAttachPolicy -> Rep BatchAttachPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchAttachPolicy x -> BatchAttachPolicy
$cfrom :: forall x. BatchAttachPolicy -> Rep BatchAttachPolicy x
Prelude.Generic)

-- |
-- Create a value of 'BatchAttachPolicy' 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:
--
-- 'policyReference', 'batchAttachPolicy_policyReference' - The reference that is associated with the policy object.
--
-- 'objectReference', 'batchAttachPolicy_objectReference' - The reference that identifies the object to which the policy will be
-- attached.
newBatchAttachPolicy ::
  -- | 'policyReference'
  ObjectReference ->
  -- | 'objectReference'
  ObjectReference ->
  BatchAttachPolicy
newBatchAttachPolicy :: ObjectReference -> ObjectReference -> BatchAttachPolicy
newBatchAttachPolicy
  ObjectReference
pPolicyReference_
  ObjectReference
pObjectReference_ =
    BatchAttachPolicy' :: ObjectReference -> ObjectReference -> BatchAttachPolicy
BatchAttachPolicy'
      { $sel:policyReference:BatchAttachPolicy' :: ObjectReference
policyReference =
          ObjectReference
pPolicyReference_,
        $sel:objectReference:BatchAttachPolicy' :: ObjectReference
objectReference = ObjectReference
pObjectReference_
      }

-- | The reference that is associated with the policy object.
batchAttachPolicy_policyReference :: Lens.Lens' BatchAttachPolicy ObjectReference
batchAttachPolicy_policyReference :: (ObjectReference -> f ObjectReference)
-> BatchAttachPolicy -> f BatchAttachPolicy
batchAttachPolicy_policyReference = (BatchAttachPolicy -> ObjectReference)
-> (BatchAttachPolicy -> ObjectReference -> BatchAttachPolicy)
-> Lens
     BatchAttachPolicy BatchAttachPolicy ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAttachPolicy' {ObjectReference
policyReference :: ObjectReference
$sel:policyReference:BatchAttachPolicy' :: BatchAttachPolicy -> ObjectReference
policyReference} -> ObjectReference
policyReference) (\s :: BatchAttachPolicy
s@BatchAttachPolicy' {} ObjectReference
a -> BatchAttachPolicy
s {$sel:policyReference:BatchAttachPolicy' :: ObjectReference
policyReference = ObjectReference
a} :: BatchAttachPolicy)

-- | The reference that identifies the object to which the policy will be
-- attached.
batchAttachPolicy_objectReference :: Lens.Lens' BatchAttachPolicy ObjectReference
batchAttachPolicy_objectReference :: (ObjectReference -> f ObjectReference)
-> BatchAttachPolicy -> f BatchAttachPolicy
batchAttachPolicy_objectReference = (BatchAttachPolicy -> ObjectReference)
-> (BatchAttachPolicy -> ObjectReference -> BatchAttachPolicy)
-> Lens
     BatchAttachPolicy BatchAttachPolicy ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAttachPolicy' {ObjectReference
objectReference :: ObjectReference
$sel:objectReference:BatchAttachPolicy' :: BatchAttachPolicy -> ObjectReference
objectReference} -> ObjectReference
objectReference) (\s :: BatchAttachPolicy
s@BatchAttachPolicy' {} ObjectReference
a -> BatchAttachPolicy
s {$sel:objectReference:BatchAttachPolicy' :: ObjectReference
objectReference = ObjectReference
a} :: BatchAttachPolicy)

instance Prelude.Hashable BatchAttachPolicy

instance Prelude.NFData BatchAttachPolicy

instance Core.ToJSON BatchAttachPolicy where
  toJSON :: BatchAttachPolicy -> Value
toJSON BatchAttachPolicy' {ObjectReference
objectReference :: ObjectReference
policyReference :: ObjectReference
$sel:objectReference:BatchAttachPolicy' :: BatchAttachPolicy -> ObjectReference
$sel:policyReference:BatchAttachPolicy' :: BatchAttachPolicy -> ObjectReference
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"PolicyReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
policyReference),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ObjectReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
objectReference)
          ]
      )