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

import Amazonka.CloudDirectory.Types.ObjectReference
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

-- | 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
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]
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
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. 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'
      { $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 :: Lens' BatchAttachPolicy ObjectReference
batchAttachPolicy_policyReference = 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 :: Lens' BatchAttachPolicy ObjectReference
batchAttachPolicy_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 where
  hashWithSalt :: Int -> BatchAttachPolicy -> Int
hashWithSalt Int
_salt BatchAttachPolicy' {ObjectReference
objectReference :: ObjectReference
policyReference :: ObjectReference
$sel:objectReference:BatchAttachPolicy' :: BatchAttachPolicy -> ObjectReference
$sel:policyReference:BatchAttachPolicy' :: BatchAttachPolicy -> ObjectReference
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ObjectReference
policyReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ObjectReference
objectReference

instance Prelude.NFData BatchAttachPolicy where
  rnf :: BatchAttachPolicy -> ()
rnf BatchAttachPolicy' {ObjectReference
objectReference :: ObjectReference
policyReference :: ObjectReference
$sel:objectReference:BatchAttachPolicy' :: BatchAttachPolicy -> ObjectReference
$sel:policyReference:BatchAttachPolicy' :: BatchAttachPolicy -> ObjectReference
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ObjectReference
policyReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ObjectReference
objectReference

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"PolicyReference" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ObjectReference
policyReference),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ObjectReference" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ObjectReference
objectReference)
          ]
      )