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

import Amazonka.CloudDirectory.Types.AttributeKey
import Amazonka.CloudDirectory.Types.ObjectReference
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | A reference to the parent object that contains the index object.
    BatchCreateIndex -> Maybe ObjectReference
parentReference :: Prelude.Maybe ObjectReference,
    -- | The name of the link between the parent object and the index object.
    BatchCreateIndex -> Maybe Text
linkName :: Prelude.Maybe Prelude.Text,
    -- | 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,
    -- | 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
(BatchCreateIndex -> BatchCreateIndex -> Bool)
-> (BatchCreateIndex -> BatchCreateIndex -> Bool)
-> Eq BatchCreateIndex
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]
(Int -> ReadS BatchCreateIndex)
-> ReadS [BatchCreateIndex]
-> ReadPrec BatchCreateIndex
-> ReadPrec [BatchCreateIndex]
-> Read 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
(Int -> BatchCreateIndex -> ShowS)
-> (BatchCreateIndex -> String)
-> ([BatchCreateIndex] -> ShowS)
-> Show BatchCreateIndex
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. BatchCreateIndex -> Rep BatchCreateIndex x)
-> (forall x. Rep BatchCreateIndex x -> BatchCreateIndex)
-> Generic BatchCreateIndex
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:
--
-- 'parentReference', 'batchCreateIndex_parentReference' - A reference to the parent object that contains the index object.
--
-- 'linkName', 'batchCreateIndex_linkName' - The name of the link between the parent object and the index object.
--
-- 'batchReferenceName', 'batchCreateIndex_batchReferenceName' - The batch reference name. See
-- <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/transaction_support.html Transaction Support>
-- for more information.
--
-- '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' :: Maybe ObjectReference
-> Maybe Text
-> Maybe Text
-> [AttributeKey]
-> Bool
-> BatchCreateIndex
BatchCreateIndex'
    { $sel:parentReference:BatchCreateIndex' :: Maybe ObjectReference
parentReference =
        Maybe ObjectReference
forall a. Maybe a
Prelude.Nothing,
      $sel:linkName:BatchCreateIndex' :: Maybe Text
linkName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:batchReferenceName:BatchCreateIndex' :: Maybe Text
batchReferenceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:orderedIndexedAttributeList:BatchCreateIndex' :: [AttributeKey]
orderedIndexedAttributeList = [AttributeKey]
forall a. Monoid a => a
Prelude.mempty,
      $sel:isUnique:BatchCreateIndex' :: Bool
isUnique = Bool
pIsUnique_
    }

-- | A reference to the parent object that contains the index object.
batchCreateIndex_parentReference :: Lens.Lens' BatchCreateIndex (Prelude.Maybe ObjectReference)
batchCreateIndex_parentReference :: (Maybe ObjectReference -> f (Maybe ObjectReference))
-> BatchCreateIndex -> f BatchCreateIndex
batchCreateIndex_parentReference = (BatchCreateIndex -> Maybe ObjectReference)
-> (BatchCreateIndex -> Maybe ObjectReference -> BatchCreateIndex)
-> Lens
     BatchCreateIndex
     BatchCreateIndex
     (Maybe ObjectReference)
     (Maybe ObjectReference)
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)

-- | The name of the link between the parent object and the index object.
batchCreateIndex_linkName :: Lens.Lens' BatchCreateIndex (Prelude.Maybe Prelude.Text)
batchCreateIndex_linkName :: (Maybe Text -> f (Maybe Text))
-> BatchCreateIndex -> f BatchCreateIndex
batchCreateIndex_linkName = (BatchCreateIndex -> Maybe Text)
-> (BatchCreateIndex -> Maybe Text -> BatchCreateIndex)
-> Lens BatchCreateIndex BatchCreateIndex (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> BatchCreateIndex -> f BatchCreateIndex
batchCreateIndex_batchReferenceName = (BatchCreateIndex -> Maybe Text)
-> (BatchCreateIndex -> Maybe Text -> BatchCreateIndex)
-> Lens BatchCreateIndex BatchCreateIndex (Maybe Text) (Maybe Text)
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)

-- | Specifies the attributes that should be indexed on. Currently only a
-- single attribute is supported.
batchCreateIndex_orderedIndexedAttributeList :: Lens.Lens' BatchCreateIndex [AttributeKey]
batchCreateIndex_orderedIndexedAttributeList :: ([AttributeKey] -> f [AttributeKey])
-> BatchCreateIndex -> f BatchCreateIndex
batchCreateIndex_orderedIndexedAttributeList = (BatchCreateIndex -> [AttributeKey])
-> (BatchCreateIndex -> [AttributeKey] -> BatchCreateIndex)
-> Lens
     BatchCreateIndex BatchCreateIndex [AttributeKey] [AttributeKey]
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) (([AttributeKey] -> f [AttributeKey])
 -> BatchCreateIndex -> f BatchCreateIndex)
-> (([AttributeKey] -> f [AttributeKey])
    -> [AttributeKey] -> f [AttributeKey])
-> ([AttributeKey] -> f [AttributeKey])
-> BatchCreateIndex
-> f BatchCreateIndex
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AttributeKey] -> f [AttributeKey])
-> [AttributeKey] -> f [AttributeKey]
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 :: (Bool -> f Bool) -> BatchCreateIndex -> f BatchCreateIndex
batchCreateIndex_isUnique = (BatchCreateIndex -> Bool)
-> (BatchCreateIndex -> Bool -> BatchCreateIndex)
-> Lens BatchCreateIndex BatchCreateIndex Bool Bool
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

instance Prelude.NFData BatchCreateIndex

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