{-# 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.BatchDetachFromIndex
-- 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.BatchDetachFromIndex 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 object from the specified index inside a
-- BatchRead operation. For more information, see DetachFromIndex and
-- BatchReadRequest$Operations.
--
-- /See:/ 'newBatchDetachFromIndex' smart constructor.
data BatchDetachFromIndex = BatchDetachFromIndex'
  { -- | A reference to the index object.
    BatchDetachFromIndex -> ObjectReference
indexReference :: ObjectReference,
    -- | A reference to the object being detached from the index.
    BatchDetachFromIndex -> ObjectReference
targetReference :: ObjectReference
  }
  deriving (BatchDetachFromIndex -> BatchDetachFromIndex -> Bool
(BatchDetachFromIndex -> BatchDetachFromIndex -> Bool)
-> (BatchDetachFromIndex -> BatchDetachFromIndex -> Bool)
-> Eq BatchDetachFromIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDetachFromIndex -> BatchDetachFromIndex -> Bool
$c/= :: BatchDetachFromIndex -> BatchDetachFromIndex -> Bool
== :: BatchDetachFromIndex -> BatchDetachFromIndex -> Bool
$c== :: BatchDetachFromIndex -> BatchDetachFromIndex -> Bool
Prelude.Eq, ReadPrec [BatchDetachFromIndex]
ReadPrec BatchDetachFromIndex
Int -> ReadS BatchDetachFromIndex
ReadS [BatchDetachFromIndex]
(Int -> ReadS BatchDetachFromIndex)
-> ReadS [BatchDetachFromIndex]
-> ReadPrec BatchDetachFromIndex
-> ReadPrec [BatchDetachFromIndex]
-> Read BatchDetachFromIndex
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDetachFromIndex]
$creadListPrec :: ReadPrec [BatchDetachFromIndex]
readPrec :: ReadPrec BatchDetachFromIndex
$creadPrec :: ReadPrec BatchDetachFromIndex
readList :: ReadS [BatchDetachFromIndex]
$creadList :: ReadS [BatchDetachFromIndex]
readsPrec :: Int -> ReadS BatchDetachFromIndex
$creadsPrec :: Int -> ReadS BatchDetachFromIndex
Prelude.Read, Int -> BatchDetachFromIndex -> ShowS
[BatchDetachFromIndex] -> ShowS
BatchDetachFromIndex -> String
(Int -> BatchDetachFromIndex -> ShowS)
-> (BatchDetachFromIndex -> String)
-> ([BatchDetachFromIndex] -> ShowS)
-> Show BatchDetachFromIndex
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDetachFromIndex] -> ShowS
$cshowList :: [BatchDetachFromIndex] -> ShowS
show :: BatchDetachFromIndex -> String
$cshow :: BatchDetachFromIndex -> String
showsPrec :: Int -> BatchDetachFromIndex -> ShowS
$cshowsPrec :: Int -> BatchDetachFromIndex -> ShowS
Prelude.Show, (forall x. BatchDetachFromIndex -> Rep BatchDetachFromIndex x)
-> (forall x. Rep BatchDetachFromIndex x -> BatchDetachFromIndex)
-> Generic BatchDetachFromIndex
forall x. Rep BatchDetachFromIndex x -> BatchDetachFromIndex
forall x. BatchDetachFromIndex -> Rep BatchDetachFromIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchDetachFromIndex x -> BatchDetachFromIndex
$cfrom :: forall x. BatchDetachFromIndex -> Rep BatchDetachFromIndex x
Prelude.Generic)

-- |
-- Create a value of 'BatchDetachFromIndex' 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:
--
-- 'indexReference', 'batchDetachFromIndex_indexReference' - A reference to the index object.
--
-- 'targetReference', 'batchDetachFromIndex_targetReference' - A reference to the object being detached from the index.
newBatchDetachFromIndex ::
  -- | 'indexReference'
  ObjectReference ->
  -- | 'targetReference'
  ObjectReference ->
  BatchDetachFromIndex
newBatchDetachFromIndex :: ObjectReference -> ObjectReference -> BatchDetachFromIndex
newBatchDetachFromIndex
  ObjectReference
pIndexReference_
  ObjectReference
pTargetReference_ =
    BatchDetachFromIndex' :: ObjectReference -> ObjectReference -> BatchDetachFromIndex
BatchDetachFromIndex'
      { $sel:indexReference:BatchDetachFromIndex' :: ObjectReference
indexReference =
          ObjectReference
pIndexReference_,
        $sel:targetReference:BatchDetachFromIndex' :: ObjectReference
targetReference = ObjectReference
pTargetReference_
      }

-- | A reference to the index object.
batchDetachFromIndex_indexReference :: Lens.Lens' BatchDetachFromIndex ObjectReference
batchDetachFromIndex_indexReference :: (ObjectReference -> f ObjectReference)
-> BatchDetachFromIndex -> f BatchDetachFromIndex
batchDetachFromIndex_indexReference = (BatchDetachFromIndex -> ObjectReference)
-> (BatchDetachFromIndex
    -> ObjectReference -> BatchDetachFromIndex)
-> Lens
     BatchDetachFromIndex
     BatchDetachFromIndex
     ObjectReference
     ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetachFromIndex' {ObjectReference
indexReference :: ObjectReference
$sel:indexReference:BatchDetachFromIndex' :: BatchDetachFromIndex -> ObjectReference
indexReference} -> ObjectReference
indexReference) (\s :: BatchDetachFromIndex
s@BatchDetachFromIndex' {} ObjectReference
a -> BatchDetachFromIndex
s {$sel:indexReference:BatchDetachFromIndex' :: ObjectReference
indexReference = ObjectReference
a} :: BatchDetachFromIndex)

-- | A reference to the object being detached from the index.
batchDetachFromIndex_targetReference :: Lens.Lens' BatchDetachFromIndex ObjectReference
batchDetachFromIndex_targetReference :: (ObjectReference -> f ObjectReference)
-> BatchDetachFromIndex -> f BatchDetachFromIndex
batchDetachFromIndex_targetReference = (BatchDetachFromIndex -> ObjectReference)
-> (BatchDetachFromIndex
    -> ObjectReference -> BatchDetachFromIndex)
-> Lens
     BatchDetachFromIndex
     BatchDetachFromIndex
     ObjectReference
     ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetachFromIndex' {ObjectReference
targetReference :: ObjectReference
$sel:targetReference:BatchDetachFromIndex' :: BatchDetachFromIndex -> ObjectReference
targetReference} -> ObjectReference
targetReference) (\s :: BatchDetachFromIndex
s@BatchDetachFromIndex' {} ObjectReference
a -> BatchDetachFromIndex
s {$sel:targetReference:BatchDetachFromIndex' :: ObjectReference
targetReference = ObjectReference
a} :: BatchDetachFromIndex)

instance Prelude.Hashable BatchDetachFromIndex

instance Prelude.NFData BatchDetachFromIndex

instance Core.ToJSON BatchDetachFromIndex where
  toJSON :: BatchDetachFromIndex -> Value
toJSON BatchDetachFromIndex' {ObjectReference
targetReference :: ObjectReference
indexReference :: ObjectReference
$sel:targetReference:BatchDetachFromIndex' :: BatchDetachFromIndex -> ObjectReference
$sel:indexReference:BatchDetachFromIndex' :: BatchDetachFromIndex -> 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
"IndexReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
indexReference),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TargetReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
targetReference)
          ]
      )