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

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

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

-- | The maximum number of results to retrieve.
batchListIndex_maxResults :: Lens.Lens' BatchListIndex (Prelude.Maybe Prelude.Natural)
batchListIndex_maxResults :: Lens' BatchListIndex (Maybe Natural)
batchListIndex_maxResults = 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 pagination token.
batchListIndex_nextToken :: Lens.Lens' BatchListIndex (Prelude.Maybe Prelude.Text)
batchListIndex_nextToken :: Lens' BatchListIndex (Maybe Text)
batchListIndex_nextToken = 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)

-- | Specifies the ranges of indexed values that you want to query.
batchListIndex_rangesOnIndexedValues :: Lens.Lens' BatchListIndex (Prelude.Maybe [ObjectAttributeRange])
batchListIndex_rangesOnIndexedValues :: Lens' BatchListIndex (Maybe [ObjectAttributeRange])
batchListIndex_rangesOnIndexedValues = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The reference to the index to list.
batchListIndex_indexReference :: Lens.Lens' BatchListIndex ObjectReference
batchListIndex_indexReference :: Lens' BatchListIndex ObjectReference
batchListIndex_indexReference = 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 where
  hashWithSalt :: Int -> BatchListIndex -> Int
hashWithSalt Int
_salt BatchListIndex' {Maybe Natural
Maybe [ObjectAttributeRange]
Maybe Text
ObjectReference
indexReference :: ObjectReference
rangesOnIndexedValues :: Maybe [ObjectAttributeRange]
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:indexReference:BatchListIndex' :: BatchListIndex -> ObjectReference
$sel:rangesOnIndexedValues:BatchListIndex' :: BatchListIndex -> Maybe [ObjectAttributeRange]
$sel:nextToken:BatchListIndex' :: BatchListIndex -> Maybe Text
$sel:maxResults:BatchListIndex' :: BatchListIndex -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ObjectAttributeRange]
rangesOnIndexedValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ObjectReference
indexReference

instance Prelude.NFData BatchListIndex where
  rnf :: BatchListIndex -> ()
rnf BatchListIndex' {Maybe Natural
Maybe [ObjectAttributeRange]
Maybe Text
ObjectReference
indexReference :: ObjectReference
rangesOnIndexedValues :: Maybe [ObjectAttributeRange]
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:indexReference:BatchListIndex' :: BatchListIndex -> ObjectReference
$sel:rangesOnIndexedValues:BatchListIndex' :: BatchListIndex -> Maybe [ObjectAttributeRange]
$sel:nextToken:BatchListIndex' :: BatchListIndex -> Maybe Text
$sel:maxResults:BatchListIndex' :: BatchListIndex -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ObjectAttributeRange]
rangesOnIndexedValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ObjectReference
indexReference

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