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

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

-- | Detaches the specified policy from the specified directory inside a
-- BatchWrite operation. For more information, see DetachPolicy and
-- BatchWriteRequest$Operations.
--
-- /See:/ 'newBatchDetachPolicy' smart constructor.
data BatchDetachPolicy = BatchDetachPolicy'
  { -- | Reference that identifies the policy object.
    BatchDetachPolicy -> ObjectReference
policyReference :: ObjectReference,
    -- | Reference that identifies the object whose policy object will be
    -- detached.
    BatchDetachPolicy -> ObjectReference
objectReference :: ObjectReference
  }
  deriving (BatchDetachPolicy -> BatchDetachPolicy -> Bool
(BatchDetachPolicy -> BatchDetachPolicy -> Bool)
-> (BatchDetachPolicy -> BatchDetachPolicy -> Bool)
-> Eq BatchDetachPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDetachPolicy -> BatchDetachPolicy -> Bool
$c/= :: BatchDetachPolicy -> BatchDetachPolicy -> Bool
== :: BatchDetachPolicy -> BatchDetachPolicy -> Bool
$c== :: BatchDetachPolicy -> BatchDetachPolicy -> Bool
Prelude.Eq, ReadPrec [BatchDetachPolicy]
ReadPrec BatchDetachPolicy
Int -> ReadS BatchDetachPolicy
ReadS [BatchDetachPolicy]
(Int -> ReadS BatchDetachPolicy)
-> ReadS [BatchDetachPolicy]
-> ReadPrec BatchDetachPolicy
-> ReadPrec [BatchDetachPolicy]
-> Read BatchDetachPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDetachPolicy]
$creadListPrec :: ReadPrec [BatchDetachPolicy]
readPrec :: ReadPrec BatchDetachPolicy
$creadPrec :: ReadPrec BatchDetachPolicy
readList :: ReadS [BatchDetachPolicy]
$creadList :: ReadS [BatchDetachPolicy]
readsPrec :: Int -> ReadS BatchDetachPolicy
$creadsPrec :: Int -> ReadS BatchDetachPolicy
Prelude.Read, Int -> BatchDetachPolicy -> ShowS
[BatchDetachPolicy] -> ShowS
BatchDetachPolicy -> String
(Int -> BatchDetachPolicy -> ShowS)
-> (BatchDetachPolicy -> String)
-> ([BatchDetachPolicy] -> ShowS)
-> Show BatchDetachPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDetachPolicy] -> ShowS
$cshowList :: [BatchDetachPolicy] -> ShowS
show :: BatchDetachPolicy -> String
$cshow :: BatchDetachPolicy -> String
showsPrec :: Int -> BatchDetachPolicy -> ShowS
$cshowsPrec :: Int -> BatchDetachPolicy -> ShowS
Prelude.Show, (forall x. BatchDetachPolicy -> Rep BatchDetachPolicy x)
-> (forall x. Rep BatchDetachPolicy x -> BatchDetachPolicy)
-> Generic BatchDetachPolicy
forall x. Rep BatchDetachPolicy x -> BatchDetachPolicy
forall x. BatchDetachPolicy -> Rep BatchDetachPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchDetachPolicy x -> BatchDetachPolicy
$cfrom :: forall x. BatchDetachPolicy -> Rep BatchDetachPolicy x
Prelude.Generic)

-- |
-- Create a value of 'BatchDetachPolicy' 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', 'batchDetachPolicy_policyReference' - Reference that identifies the policy object.
--
-- 'objectReference', 'batchDetachPolicy_objectReference' - Reference that identifies the object whose policy object will be
-- detached.
newBatchDetachPolicy ::
  -- | 'policyReference'
  ObjectReference ->
  -- | 'objectReference'
  ObjectReference ->
  BatchDetachPolicy
newBatchDetachPolicy :: ObjectReference -> ObjectReference -> BatchDetachPolicy
newBatchDetachPolicy
  ObjectReference
pPolicyReference_
  ObjectReference
pObjectReference_ =
    BatchDetachPolicy' :: ObjectReference -> ObjectReference -> BatchDetachPolicy
BatchDetachPolicy'
      { $sel:policyReference:BatchDetachPolicy' :: ObjectReference
policyReference =
          ObjectReference
pPolicyReference_,
        $sel:objectReference:BatchDetachPolicy' :: ObjectReference
objectReference = ObjectReference
pObjectReference_
      }

-- | Reference that identifies the policy object.
batchDetachPolicy_policyReference :: Lens.Lens' BatchDetachPolicy ObjectReference
batchDetachPolicy_policyReference :: (ObjectReference -> f ObjectReference)
-> BatchDetachPolicy -> f BatchDetachPolicy
batchDetachPolicy_policyReference = (BatchDetachPolicy -> ObjectReference)
-> (BatchDetachPolicy -> ObjectReference -> BatchDetachPolicy)
-> Lens
     BatchDetachPolicy BatchDetachPolicy ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetachPolicy' {ObjectReference
policyReference :: ObjectReference
$sel:policyReference:BatchDetachPolicy' :: BatchDetachPolicy -> ObjectReference
policyReference} -> ObjectReference
policyReference) (\s :: BatchDetachPolicy
s@BatchDetachPolicy' {} ObjectReference
a -> BatchDetachPolicy
s {$sel:policyReference:BatchDetachPolicy' :: ObjectReference
policyReference = ObjectReference
a} :: BatchDetachPolicy)

-- | Reference that identifies the object whose policy object will be
-- detached.
batchDetachPolicy_objectReference :: Lens.Lens' BatchDetachPolicy ObjectReference
batchDetachPolicy_objectReference :: (ObjectReference -> f ObjectReference)
-> BatchDetachPolicy -> f BatchDetachPolicy
batchDetachPolicy_objectReference = (BatchDetachPolicy -> ObjectReference)
-> (BatchDetachPolicy -> ObjectReference -> BatchDetachPolicy)
-> Lens
     BatchDetachPolicy BatchDetachPolicy ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetachPolicy' {ObjectReference
objectReference :: ObjectReference
$sel:objectReference:BatchDetachPolicy' :: BatchDetachPolicy -> ObjectReference
objectReference} -> ObjectReference
objectReference) (\s :: BatchDetachPolicy
s@BatchDetachPolicy' {} ObjectReference
a -> BatchDetachPolicy
s {$sel:objectReference:BatchDetachPolicy' :: ObjectReference
objectReference = ObjectReference
a} :: BatchDetachPolicy)

instance Prelude.Hashable BatchDetachPolicy

instance Prelude.NFData BatchDetachPolicy

instance Core.ToJSON BatchDetachPolicy where
  toJSON :: BatchDetachPolicy -> Value
toJSON BatchDetachPolicy' {ObjectReference
objectReference :: ObjectReference
policyReference :: ObjectReference
$sel:objectReference:BatchDetachPolicy' :: BatchDetachPolicy -> ObjectReference
$sel:policyReference:BatchDetachPolicy' :: BatchDetachPolicy -> 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)
          ]
      )