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

-- |
-- Create a value of 'BatchAttachToIndex' 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', 'batchAttachToIndex_indexReference' - A reference to the index that you are attaching the object to.
--
-- 'targetReference', 'batchAttachToIndex_targetReference' - A reference to the object that you are attaching to the index.
newBatchAttachToIndex ::
  -- | 'indexReference'
  ObjectReference ->
  -- | 'targetReference'
  ObjectReference ->
  BatchAttachToIndex
newBatchAttachToIndex :: ObjectReference -> ObjectReference -> BatchAttachToIndex
newBatchAttachToIndex
  ObjectReference
pIndexReference_
  ObjectReference
pTargetReference_ =
    BatchAttachToIndex' :: ObjectReference -> ObjectReference -> BatchAttachToIndex
BatchAttachToIndex'
      { $sel:indexReference:BatchAttachToIndex' :: ObjectReference
indexReference =
          ObjectReference
pIndexReference_,
        $sel:targetReference:BatchAttachToIndex' :: ObjectReference
targetReference = ObjectReference
pTargetReference_
      }

-- | A reference to the index that you are attaching the object to.
batchAttachToIndex_indexReference :: Lens.Lens' BatchAttachToIndex ObjectReference
batchAttachToIndex_indexReference :: (ObjectReference -> f ObjectReference)
-> BatchAttachToIndex -> f BatchAttachToIndex
batchAttachToIndex_indexReference = (BatchAttachToIndex -> ObjectReference)
-> (BatchAttachToIndex -> ObjectReference -> BatchAttachToIndex)
-> Lens
     BatchAttachToIndex
     BatchAttachToIndex
     ObjectReference
     ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAttachToIndex' {ObjectReference
indexReference :: ObjectReference
$sel:indexReference:BatchAttachToIndex' :: BatchAttachToIndex -> ObjectReference
indexReference} -> ObjectReference
indexReference) (\s :: BatchAttachToIndex
s@BatchAttachToIndex' {} ObjectReference
a -> BatchAttachToIndex
s {$sel:indexReference:BatchAttachToIndex' :: ObjectReference
indexReference = ObjectReference
a} :: BatchAttachToIndex)

-- | A reference to the object that you are attaching to the index.
batchAttachToIndex_targetReference :: Lens.Lens' BatchAttachToIndex ObjectReference
batchAttachToIndex_targetReference :: (ObjectReference -> f ObjectReference)
-> BatchAttachToIndex -> f BatchAttachToIndex
batchAttachToIndex_targetReference = (BatchAttachToIndex -> ObjectReference)
-> (BatchAttachToIndex -> ObjectReference -> BatchAttachToIndex)
-> Lens
     BatchAttachToIndex
     BatchAttachToIndex
     ObjectReference
     ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAttachToIndex' {ObjectReference
targetReference :: ObjectReference
$sel:targetReference:BatchAttachToIndex' :: BatchAttachToIndex -> ObjectReference
targetReference} -> ObjectReference
targetReference) (\s :: BatchAttachToIndex
s@BatchAttachToIndex' {} ObjectReference
a -> BatchAttachToIndex
s {$sel:targetReference:BatchAttachToIndex' :: ObjectReference
targetReference = ObjectReference
a} :: BatchAttachToIndex)

instance Prelude.Hashable BatchAttachToIndex

instance Prelude.NFData BatchAttachToIndex

instance Core.ToJSON BatchAttachToIndex where
  toJSON :: BatchAttachToIndex -> Value
toJSON BatchAttachToIndex' {ObjectReference
targetReference :: ObjectReference
indexReference :: ObjectReference
$sel:targetReference:BatchAttachToIndex' :: BatchAttachToIndex -> ObjectReference
$sel:indexReference:BatchAttachToIndex' :: BatchAttachToIndex -> 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)
          ]
      )