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

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

-- | Lists objects attached to the specified index inside a BatchRead
-- operation. For more information, see ListIndex and
-- BatchReadRequest$Operations.
--
-- /See:/ 'newBatchListIndex' smart constructor.
data BatchListIndex = BatchListIndex'
  { -- | Specifies the ranges of indexed values that you want to query.
    BatchListIndex -> Maybe [ObjectAttributeRange]
rangesOnIndexedValues :: Prelude.Maybe [ObjectAttributeRange],
    -- | The pagination token.
    BatchListIndex -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to retrieve.
    BatchListIndex -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The reference to the index to list.
    BatchListIndex -> ObjectReference
indexReference :: ObjectReference
  }
  deriving (BatchListIndex -> BatchListIndex -> Bool
(BatchListIndex -> BatchListIndex -> Bool)
-> (BatchListIndex -> BatchListIndex -> Bool) -> Eq BatchListIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchListIndex -> BatchListIndex -> Bool
$c/= :: BatchListIndex -> BatchListIndex -> Bool
== :: BatchListIndex -> BatchListIndex -> Bool
$c== :: BatchListIndex -> BatchListIndex -> Bool
Prelude.Eq, ReadPrec [BatchListIndex]
ReadPrec BatchListIndex
Int -> ReadS BatchListIndex
ReadS [BatchListIndex]
(Int -> ReadS BatchListIndex)
-> ReadS [BatchListIndex]
-> ReadPrec BatchListIndex
-> ReadPrec [BatchListIndex]
-> Read BatchListIndex
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchListIndex]
$creadListPrec :: ReadPrec [BatchListIndex]
readPrec :: ReadPrec BatchListIndex
$creadPrec :: ReadPrec BatchListIndex
readList :: ReadS [BatchListIndex]
$creadList :: ReadS [BatchListIndex]
readsPrec :: Int -> ReadS BatchListIndex
$creadsPrec :: Int -> ReadS BatchListIndex
Prelude.Read, Int -> BatchListIndex -> ShowS
[BatchListIndex] -> ShowS
BatchListIndex -> String
(Int -> BatchListIndex -> ShowS)
-> (BatchListIndex -> String)
-> ([BatchListIndex] -> ShowS)
-> Show BatchListIndex
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchListIndex] -> ShowS
$cshowList :: [BatchListIndex] -> ShowS
show :: BatchListIndex -> String
$cshow :: BatchListIndex -> String
showsPrec :: Int -> BatchListIndex -> ShowS
$cshowsPrec :: Int -> BatchListIndex -> ShowS
Prelude.Show, (forall x. BatchListIndex -> Rep BatchListIndex x)
-> (forall x. Rep BatchListIndex x -> BatchListIndex)
-> Generic BatchListIndex
forall x. Rep BatchListIndex x -> BatchListIndex
forall x. BatchListIndex -> Rep BatchListIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchListIndex x -> BatchListIndex
$cfrom :: forall x. BatchListIndex -> Rep BatchListIndex x
Prelude.Generic)

-- |
-- Create a value of 'BatchListIndex' 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:
--
-- 'rangesOnIndexedValues', 'batchListIndex_rangesOnIndexedValues' - Specifies the ranges of indexed values that you want to query.
--
-- 'nextToken', 'batchListIndex_nextToken' - The pagination token.
--
-- 'maxResults', 'batchListIndex_maxResults' - The maximum number of results to retrieve.
--
-- 'indexReference', 'batchListIndex_indexReference' - The reference to the index to list.
newBatchListIndex ::
  -- | 'indexReference'
  ObjectReference ->
  BatchListIndex
newBatchListIndex :: ObjectReference -> BatchListIndex
newBatchListIndex ObjectReference
pIndexReference_ =
  BatchListIndex' :: Maybe [ObjectAttributeRange]
-> Maybe Text -> Maybe Natural -> ObjectReference -> BatchListIndex
BatchListIndex'
    { $sel:rangesOnIndexedValues:BatchListIndex' :: Maybe [ObjectAttributeRange]
rangesOnIndexedValues =
        Maybe [ObjectAttributeRange]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:BatchListIndex' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:BatchListIndex' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:indexReference:BatchListIndex' :: ObjectReference
indexReference = ObjectReference
pIndexReference_
    }

-- | Specifies the ranges of indexed values that you want to query.
batchListIndex_rangesOnIndexedValues :: Lens.Lens' BatchListIndex (Prelude.Maybe [ObjectAttributeRange])
batchListIndex_rangesOnIndexedValues :: (Maybe [ObjectAttributeRange] -> f (Maybe [ObjectAttributeRange]))
-> BatchListIndex -> f BatchListIndex
batchListIndex_rangesOnIndexedValues = (BatchListIndex -> Maybe [ObjectAttributeRange])
-> (BatchListIndex
    -> Maybe [ObjectAttributeRange] -> BatchListIndex)
-> Lens
     BatchListIndex
     BatchListIndex
     (Maybe [ObjectAttributeRange])
     (Maybe [ObjectAttributeRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchListIndex' {Maybe [ObjectAttributeRange]
rangesOnIndexedValues :: Maybe [ObjectAttributeRange]
$sel:rangesOnIndexedValues:BatchListIndex' :: BatchListIndex -> Maybe [ObjectAttributeRange]
rangesOnIndexedValues} -> Maybe [ObjectAttributeRange]
rangesOnIndexedValues) (\s :: BatchListIndex
s@BatchListIndex' {} Maybe [ObjectAttributeRange]
a -> BatchListIndex
s {$sel:rangesOnIndexedValues:BatchListIndex' :: Maybe [ObjectAttributeRange]
rangesOnIndexedValues = Maybe [ObjectAttributeRange]
a} :: BatchListIndex) ((Maybe [ObjectAttributeRange] -> f (Maybe [ObjectAttributeRange]))
 -> BatchListIndex -> f BatchListIndex)
-> ((Maybe [ObjectAttributeRange]
     -> f (Maybe [ObjectAttributeRange]))
    -> Maybe [ObjectAttributeRange]
    -> f (Maybe [ObjectAttributeRange]))
-> (Maybe [ObjectAttributeRange]
    -> f (Maybe [ObjectAttributeRange]))
-> BatchListIndex
-> f BatchListIndex
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ObjectAttributeRange]
  [ObjectAttributeRange]
  [ObjectAttributeRange]
  [ObjectAttributeRange]
-> Iso
     (Maybe [ObjectAttributeRange])
     (Maybe [ObjectAttributeRange])
     (Maybe [ObjectAttributeRange])
     (Maybe [ObjectAttributeRange])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ObjectAttributeRange]
  [ObjectAttributeRange]
  [ObjectAttributeRange]
  [ObjectAttributeRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pagination token.
batchListIndex_nextToken :: Lens.Lens' BatchListIndex (Prelude.Maybe Prelude.Text)
batchListIndex_nextToken :: (Maybe Text -> f (Maybe Text))
-> BatchListIndex -> f BatchListIndex
batchListIndex_nextToken = (BatchListIndex -> Maybe Text)
-> (BatchListIndex -> Maybe Text -> BatchListIndex)
-> Lens BatchListIndex BatchListIndex (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchListIndex' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:BatchListIndex' :: BatchListIndex -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: BatchListIndex
s@BatchListIndex' {} Maybe Text
a -> BatchListIndex
s {$sel:nextToken:BatchListIndex' :: Maybe Text
nextToken = Maybe Text
a} :: BatchListIndex)

-- | The maximum number of results to retrieve.
batchListIndex_maxResults :: Lens.Lens' BatchListIndex (Prelude.Maybe Prelude.Natural)
batchListIndex_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> BatchListIndex -> f BatchListIndex
batchListIndex_maxResults = (BatchListIndex -> Maybe Natural)
-> (BatchListIndex -> Maybe Natural -> BatchListIndex)
-> Lens
     BatchListIndex BatchListIndex (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchListIndex' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:BatchListIndex' :: BatchListIndex -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: BatchListIndex
s@BatchListIndex' {} Maybe Natural
a -> BatchListIndex
s {$sel:maxResults:BatchListIndex' :: Maybe Natural
maxResults = Maybe Natural
a} :: BatchListIndex)

-- | The reference to the index to list.
batchListIndex_indexReference :: Lens.Lens' BatchListIndex ObjectReference
batchListIndex_indexReference :: (ObjectReference -> f ObjectReference)
-> BatchListIndex -> f BatchListIndex
batchListIndex_indexReference = (BatchListIndex -> ObjectReference)
-> (BatchListIndex -> ObjectReference -> BatchListIndex)
-> Lens
     BatchListIndex BatchListIndex ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchListIndex' {ObjectReference
indexReference :: ObjectReference
$sel:indexReference:BatchListIndex' :: BatchListIndex -> ObjectReference
indexReference} -> ObjectReference
indexReference) (\s :: BatchListIndex
s@BatchListIndex' {} ObjectReference
a -> BatchListIndex
s {$sel:indexReference:BatchListIndex' :: ObjectReference
indexReference = ObjectReference
a} :: BatchListIndex)

instance Prelude.Hashable BatchListIndex

instance Prelude.NFData BatchListIndex

instance Core.ToJSON BatchListIndex where
  toJSON :: BatchListIndex -> Value
toJSON BatchListIndex' {Maybe Natural
Maybe [ObjectAttributeRange]
Maybe Text
ObjectReference
indexReference :: ObjectReference
maxResults :: Maybe Natural
nextToken :: Maybe Text
rangesOnIndexedValues :: Maybe [ObjectAttributeRange]
$sel:indexReference:BatchListIndex' :: BatchListIndex -> ObjectReference
$sel:maxResults:BatchListIndex' :: BatchListIndex -> Maybe Natural
$sel:nextToken:BatchListIndex' :: BatchListIndex -> Maybe Text
$sel:rangesOnIndexedValues:BatchListIndex' :: BatchListIndex -> Maybe [ObjectAttributeRange]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RangesOnIndexedValues" Text -> [ObjectAttributeRange] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ObjectAttributeRange] -> Pair)
-> Maybe [ObjectAttributeRange] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ObjectAttributeRange]
rangesOnIndexedValues,
            (Text
"NextToken" 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
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            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)
          ]
      )