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

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

-- | Creates an index object inside of a BatchRead operation. For more
-- information, see CreateIndex and BatchReadRequest$Operations.
--
-- /See:/ 'newBatchCreateIndex' smart constructor.
data BatchCreateIndex = BatchCreateIndex'
  { -- | The batch reference name. See
    -- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/transaction_support.html Transaction Support>
    -- for more information.
    BatchCreateIndex -> Maybe Text
batchReferenceName :: Prelude.Maybe Prelude.Text,
    -- | The name of the link between the parent object and the index object.
    BatchCreateIndex -> Maybe Text
linkName :: Prelude.Maybe Prelude.Text,
    -- | A reference to the parent object that contains the index object.
    BatchCreateIndex -> Maybe ObjectReference
parentReference :: Prelude.Maybe ObjectReference,
    -- | Specifies the attributes that should be indexed on. Currently only a
    -- single attribute is supported.
    BatchCreateIndex -> [AttributeKey]
orderedIndexedAttributeList :: [AttributeKey],
    -- | Indicates whether the attribute that is being indexed has unique values
    -- or not.
    BatchCreateIndex -> Bool
isUnique :: Prelude.Bool
  }
  deriving (BatchCreateIndex -> BatchCreateIndex -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreateIndex -> BatchCreateIndex -> Bool
$c/= :: BatchCreateIndex -> BatchCreateIndex -> Bool
== :: BatchCreateIndex -> BatchCreateIndex -> Bool
$c== :: BatchCreateIndex -> BatchCreateIndex -> Bool
Prelude.Eq, ReadPrec [BatchCreateIndex]
ReadPrec BatchCreateIndex
Int -> ReadS BatchCreateIndex
ReadS [BatchCreateIndex]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchCreateIndex]
$creadListPrec :: ReadPrec [BatchCreateIndex]
readPrec :: ReadPrec BatchCreateIndex
$creadPrec :: ReadPrec BatchCreateIndex
readList :: ReadS [BatchCreateIndex]
$creadList :: ReadS [BatchCreateIndex]
readsPrec :: Int -> ReadS BatchCreateIndex
$creadsPrec :: Int -> ReadS BatchCreateIndex
Prelude.Read, Int -> BatchCreateIndex -> ShowS
[BatchCreateIndex] -> ShowS
BatchCreateIndex -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreateIndex] -> ShowS
$cshowList :: [BatchCreateIndex] -> ShowS
show :: BatchCreateIndex -> String
$cshow :: BatchCreateIndex -> String
showsPrec :: Int -> BatchCreateIndex -> ShowS
$cshowsPrec :: Int -> BatchCreateIndex -> ShowS
Prelude.Show, forall x. Rep BatchCreateIndex x -> BatchCreateIndex
forall x. BatchCreateIndex -> Rep BatchCreateIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchCreateIndex x -> BatchCreateIndex
$cfrom :: forall x. BatchCreateIndex -> Rep BatchCreateIndex x
Prelude.Generic)

-- |
-- Create a value of 'BatchCreateIndex' 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:
--
-- 'batchReferenceName', 'batchCreateIndex_batchReferenceName' - The batch reference name. See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/transaction_support.html Transaction Support>
-- for more information.
--
-- 'linkName', 'batchCreateIndex_linkName' - The name of the link between the parent object and the index object.
--
-- 'parentReference', 'batchCreateIndex_parentReference' - A reference to the parent object that contains the index object.
--
-- 'orderedIndexedAttributeList', 'batchCreateIndex_orderedIndexedAttributeList' - Specifies the attributes that should be indexed on. Currently only a
-- single attribute is supported.
--
-- 'isUnique', 'batchCreateIndex_isUnique' - Indicates whether the attribute that is being indexed has unique values
-- or not.
newBatchCreateIndex ::
  -- | 'isUnique'
  Prelude.Bool ->
  BatchCreateIndex
newBatchCreateIndex :: Bool -> BatchCreateIndex
newBatchCreateIndex Bool
pIsUnique_ =
  BatchCreateIndex'
    { $sel:batchReferenceName:BatchCreateIndex' :: Maybe Text
batchReferenceName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:linkName:BatchCreateIndex' :: Maybe Text
linkName = forall a. Maybe a
Prelude.Nothing,
      $sel:parentReference:BatchCreateIndex' :: Maybe ObjectReference
parentReference = forall a. Maybe a
Prelude.Nothing,
      $sel:orderedIndexedAttributeList:BatchCreateIndex' :: [AttributeKey]
orderedIndexedAttributeList = forall a. Monoid a => a
Prelude.mempty,
      $sel:isUnique:BatchCreateIndex' :: Bool
isUnique = Bool
pIsUnique_
    }

-- | The batch reference name. See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/transaction_support.html Transaction Support>
-- for more information.
batchCreateIndex_batchReferenceName :: Lens.Lens' BatchCreateIndex (Prelude.Maybe Prelude.Text)
batchCreateIndex_batchReferenceName :: Lens' BatchCreateIndex (Maybe Text)
batchCreateIndex_batchReferenceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateIndex' {Maybe Text
batchReferenceName :: Maybe Text
$sel:batchReferenceName:BatchCreateIndex' :: BatchCreateIndex -> Maybe Text
batchReferenceName} -> Maybe Text
batchReferenceName) (\s :: BatchCreateIndex
s@BatchCreateIndex' {} Maybe Text
a -> BatchCreateIndex
s {$sel:batchReferenceName:BatchCreateIndex' :: Maybe Text
batchReferenceName = Maybe Text
a} :: BatchCreateIndex)

-- | The name of the link between the parent object and the index object.
batchCreateIndex_linkName :: Lens.Lens' BatchCreateIndex (Prelude.Maybe Prelude.Text)
batchCreateIndex_linkName :: Lens' BatchCreateIndex (Maybe Text)
batchCreateIndex_linkName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateIndex' {Maybe Text
linkName :: Maybe Text
$sel:linkName:BatchCreateIndex' :: BatchCreateIndex -> Maybe Text
linkName} -> Maybe Text
linkName) (\s :: BatchCreateIndex
s@BatchCreateIndex' {} Maybe Text
a -> BatchCreateIndex
s {$sel:linkName:BatchCreateIndex' :: Maybe Text
linkName = Maybe Text
a} :: BatchCreateIndex)

-- | A reference to the parent object that contains the index object.
batchCreateIndex_parentReference :: Lens.Lens' BatchCreateIndex (Prelude.Maybe ObjectReference)
batchCreateIndex_parentReference :: Lens' BatchCreateIndex (Maybe ObjectReference)
batchCreateIndex_parentReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateIndex' {Maybe ObjectReference
parentReference :: Maybe ObjectReference
$sel:parentReference:BatchCreateIndex' :: BatchCreateIndex -> Maybe ObjectReference
parentReference} -> Maybe ObjectReference
parentReference) (\s :: BatchCreateIndex
s@BatchCreateIndex' {} Maybe ObjectReference
a -> BatchCreateIndex
s {$sel:parentReference:BatchCreateIndex' :: Maybe ObjectReference
parentReference = Maybe ObjectReference
a} :: BatchCreateIndex)

-- | Specifies the attributes that should be indexed on. Currently only a
-- single attribute is supported.
batchCreateIndex_orderedIndexedAttributeList :: Lens.Lens' BatchCreateIndex [AttributeKey]
batchCreateIndex_orderedIndexedAttributeList :: Lens' BatchCreateIndex [AttributeKey]
batchCreateIndex_orderedIndexedAttributeList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateIndex' {[AttributeKey]
orderedIndexedAttributeList :: [AttributeKey]
$sel:orderedIndexedAttributeList:BatchCreateIndex' :: BatchCreateIndex -> [AttributeKey]
orderedIndexedAttributeList} -> [AttributeKey]
orderedIndexedAttributeList) (\s :: BatchCreateIndex
s@BatchCreateIndex' {} [AttributeKey]
a -> BatchCreateIndex
s {$sel:orderedIndexedAttributeList:BatchCreateIndex' :: [AttributeKey]
orderedIndexedAttributeList = [AttributeKey]
a} :: BatchCreateIndex) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Indicates whether the attribute that is being indexed has unique values
-- or not.
batchCreateIndex_isUnique :: Lens.Lens' BatchCreateIndex Prelude.Bool
batchCreateIndex_isUnique :: Lens' BatchCreateIndex Bool
batchCreateIndex_isUnique = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateIndex' {Bool
isUnique :: Bool
$sel:isUnique:BatchCreateIndex' :: BatchCreateIndex -> Bool
isUnique} -> Bool
isUnique) (\s :: BatchCreateIndex
s@BatchCreateIndex' {} Bool
a -> BatchCreateIndex
s {$sel:isUnique:BatchCreateIndex' :: Bool
isUnique = Bool
a} :: BatchCreateIndex)

instance Prelude.Hashable BatchCreateIndex where
  hashWithSalt :: Int -> BatchCreateIndex -> Int
hashWithSalt Int
_salt BatchCreateIndex' {Bool
[AttributeKey]
Maybe Text
Maybe ObjectReference
isUnique :: Bool
orderedIndexedAttributeList :: [AttributeKey]
parentReference :: Maybe ObjectReference
linkName :: Maybe Text
batchReferenceName :: Maybe Text
$sel:isUnique:BatchCreateIndex' :: BatchCreateIndex -> Bool
$sel:orderedIndexedAttributeList:BatchCreateIndex' :: BatchCreateIndex -> [AttributeKey]
$sel:parentReference:BatchCreateIndex' :: BatchCreateIndex -> Maybe ObjectReference
$sel:linkName:BatchCreateIndex' :: BatchCreateIndex -> Maybe Text
$sel:batchReferenceName:BatchCreateIndex' :: BatchCreateIndex -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
batchReferenceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
linkName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ObjectReference
parentReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AttributeKey]
orderedIndexedAttributeList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
isUnique

instance Prelude.NFData BatchCreateIndex where
  rnf :: BatchCreateIndex -> ()
rnf BatchCreateIndex' {Bool
[AttributeKey]
Maybe Text
Maybe ObjectReference
isUnique :: Bool
orderedIndexedAttributeList :: [AttributeKey]
parentReference :: Maybe ObjectReference
linkName :: Maybe Text
batchReferenceName :: Maybe Text
$sel:isUnique:BatchCreateIndex' :: BatchCreateIndex -> Bool
$sel:orderedIndexedAttributeList:BatchCreateIndex' :: BatchCreateIndex -> [AttributeKey]
$sel:parentReference:BatchCreateIndex' :: BatchCreateIndex -> Maybe ObjectReference
$sel:linkName:BatchCreateIndex' :: BatchCreateIndex -> Maybe Text
$sel:batchReferenceName:BatchCreateIndex' :: BatchCreateIndex -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
batchReferenceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
linkName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ObjectReference
parentReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AttributeKey]
orderedIndexedAttributeList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
isUnique

instance Data.ToJSON BatchCreateIndex where
  toJSON :: BatchCreateIndex -> Value
toJSON BatchCreateIndex' {Bool
[AttributeKey]
Maybe Text
Maybe ObjectReference
isUnique :: Bool
orderedIndexedAttributeList :: [AttributeKey]
parentReference :: Maybe ObjectReference
linkName :: Maybe Text
batchReferenceName :: Maybe Text
$sel:isUnique:BatchCreateIndex' :: BatchCreateIndex -> Bool
$sel:orderedIndexedAttributeList:BatchCreateIndex' :: BatchCreateIndex -> [AttributeKey]
$sel:parentReference:BatchCreateIndex' :: BatchCreateIndex -> Maybe ObjectReference
$sel:linkName:BatchCreateIndex' :: BatchCreateIndex -> Maybe Text
$sel:batchReferenceName:BatchCreateIndex' :: BatchCreateIndex -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BatchReferenceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
batchReferenceName,
            (Key
"LinkName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
linkName,
            (Key
"ParentReference" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ObjectReference
parentReference,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"OrderedIndexedAttributeList"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AttributeKey]
orderedIndexedAttributeList
              ),
            forall a. a -> Maybe a
Prelude.Just (Key
"IsUnique" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
isUnique)
          ]
      )