{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.ListIndex
-- 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)
--
-- Lists objects attached to the specified index.
--
-- This operation returns paginated results.
module Amazonka.CloudDirectory.ListIndex
  ( -- * Creating a Request
    ListIndex (..),
    newListIndex,

    -- * Request Lenses
    listIndex_rangesOnIndexedValues,
    listIndex_consistencyLevel,
    listIndex_nextToken,
    listIndex_maxResults,
    listIndex_directoryArn,
    listIndex_indexReference,

    -- * Destructuring the Response
    ListIndexResponse (..),
    newListIndexResponse,

    -- * Response Lenses
    listIndexResponse_indexAttachments,
    listIndexResponse_nextToken,
    listIndexResponse_httpStatus,
  )
where

import Amazonka.CloudDirectory.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListIndex' smart constructor.
data ListIndex = ListIndex'
  { -- | Specifies the ranges of indexed values that you want to query.
    ListIndex -> Maybe [ObjectAttributeRange]
rangesOnIndexedValues :: Prelude.Maybe [ObjectAttributeRange],
    -- | The consistency level to execute the request at.
    ListIndex -> Maybe ConsistencyLevel
consistencyLevel :: Prelude.Maybe ConsistencyLevel,
    -- | The pagination token.
    ListIndex -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of objects in a single page to retrieve from the
    -- index during a request. For more information, see
    -- <http://docs.aws.amazon.com/clouddirectory/latest/developerguide/limits.html Amazon Cloud Directory Limits>.
    ListIndex -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ARN of the directory that the index exists in.
    ListIndex -> Text
directoryArn :: Prelude.Text,
    -- | The reference to the index to list.
    ListIndex -> ObjectReference
indexReference :: ObjectReference
  }
  deriving (ListIndex -> ListIndex -> Bool
(ListIndex -> ListIndex -> Bool)
-> (ListIndex -> ListIndex -> Bool) -> Eq ListIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIndex -> ListIndex -> Bool
$c/= :: ListIndex -> ListIndex -> Bool
== :: ListIndex -> ListIndex -> Bool
$c== :: ListIndex -> ListIndex -> Bool
Prelude.Eq, ReadPrec [ListIndex]
ReadPrec ListIndex
Int -> ReadS ListIndex
ReadS [ListIndex]
(Int -> ReadS ListIndex)
-> ReadS [ListIndex]
-> ReadPrec ListIndex
-> ReadPrec [ListIndex]
-> Read ListIndex
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListIndex]
$creadListPrec :: ReadPrec [ListIndex]
readPrec :: ReadPrec ListIndex
$creadPrec :: ReadPrec ListIndex
readList :: ReadS [ListIndex]
$creadList :: ReadS [ListIndex]
readsPrec :: Int -> ReadS ListIndex
$creadsPrec :: Int -> ReadS ListIndex
Prelude.Read, Int -> ListIndex -> ShowS
[ListIndex] -> ShowS
ListIndex -> String
(Int -> ListIndex -> ShowS)
-> (ListIndex -> String)
-> ([ListIndex] -> ShowS)
-> Show ListIndex
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIndex] -> ShowS
$cshowList :: [ListIndex] -> ShowS
show :: ListIndex -> String
$cshow :: ListIndex -> String
showsPrec :: Int -> ListIndex -> ShowS
$cshowsPrec :: Int -> ListIndex -> ShowS
Prelude.Show, (forall x. ListIndex -> Rep ListIndex x)
-> (forall x. Rep ListIndex x -> ListIndex) -> Generic ListIndex
forall x. Rep ListIndex x -> ListIndex
forall x. ListIndex -> Rep ListIndex x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListIndex x -> ListIndex
$cfrom :: forall x. ListIndex -> Rep ListIndex x
Prelude.Generic)

-- |
-- Create a value of 'ListIndex' 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', 'listIndex_rangesOnIndexedValues' - Specifies the ranges of indexed values that you want to query.
--
-- 'consistencyLevel', 'listIndex_consistencyLevel' - The consistency level to execute the request at.
--
-- 'nextToken', 'listIndex_nextToken' - The pagination token.
--
-- 'maxResults', 'listIndex_maxResults' - The maximum number of objects in a single page to retrieve from the
-- index during a request. For more information, see
-- <http://docs.aws.amazon.com/clouddirectory/latest/developerguide/limits.html Amazon Cloud Directory Limits>.
--
-- 'directoryArn', 'listIndex_directoryArn' - The ARN of the directory that the index exists in.
--
-- 'indexReference', 'listIndex_indexReference' - The reference to the index to list.
newListIndex ::
  -- | 'directoryArn'
  Prelude.Text ->
  -- | 'indexReference'
  ObjectReference ->
  ListIndex
newListIndex :: Text -> ObjectReference -> ListIndex
newListIndex Text
pDirectoryArn_ ObjectReference
pIndexReference_ =
  ListIndex' :: Maybe [ObjectAttributeRange]
-> Maybe ConsistencyLevel
-> Maybe Text
-> Maybe Natural
-> Text
-> ObjectReference
-> ListIndex
ListIndex'
    { $sel:rangesOnIndexedValues:ListIndex' :: Maybe [ObjectAttributeRange]
rangesOnIndexedValues = Maybe [ObjectAttributeRange]
forall a. Maybe a
Prelude.Nothing,
      $sel:consistencyLevel:ListIndex' :: Maybe ConsistencyLevel
consistencyLevel = Maybe ConsistencyLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListIndex' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListIndex' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:directoryArn:ListIndex' :: Text
directoryArn = Text
pDirectoryArn_,
      $sel:indexReference:ListIndex' :: ObjectReference
indexReference = ObjectReference
pIndexReference_
    }

-- | Specifies the ranges of indexed values that you want to query.
listIndex_rangesOnIndexedValues :: Lens.Lens' ListIndex (Prelude.Maybe [ObjectAttributeRange])
listIndex_rangesOnIndexedValues :: (Maybe [ObjectAttributeRange] -> f (Maybe [ObjectAttributeRange]))
-> ListIndex -> f ListIndex
listIndex_rangesOnIndexedValues = (ListIndex -> Maybe [ObjectAttributeRange])
-> (ListIndex -> Maybe [ObjectAttributeRange] -> ListIndex)
-> Lens
     ListIndex
     ListIndex
     (Maybe [ObjectAttributeRange])
     (Maybe [ObjectAttributeRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIndex' {Maybe [ObjectAttributeRange]
rangesOnIndexedValues :: Maybe [ObjectAttributeRange]
$sel:rangesOnIndexedValues:ListIndex' :: ListIndex -> Maybe [ObjectAttributeRange]
rangesOnIndexedValues} -> Maybe [ObjectAttributeRange]
rangesOnIndexedValues) (\s :: ListIndex
s@ListIndex' {} Maybe [ObjectAttributeRange]
a -> ListIndex
s {$sel:rangesOnIndexedValues:ListIndex' :: Maybe [ObjectAttributeRange]
rangesOnIndexedValues = Maybe [ObjectAttributeRange]
a} :: ListIndex) ((Maybe [ObjectAttributeRange] -> f (Maybe [ObjectAttributeRange]))
 -> ListIndex -> f ListIndex)
-> ((Maybe [ObjectAttributeRange]
     -> f (Maybe [ObjectAttributeRange]))
    -> Maybe [ObjectAttributeRange]
    -> f (Maybe [ObjectAttributeRange]))
-> (Maybe [ObjectAttributeRange]
    -> f (Maybe [ObjectAttributeRange]))
-> ListIndex
-> f ListIndex
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 consistency level to execute the request at.
listIndex_consistencyLevel :: Lens.Lens' ListIndex (Prelude.Maybe ConsistencyLevel)
listIndex_consistencyLevel :: (Maybe ConsistencyLevel -> f (Maybe ConsistencyLevel))
-> ListIndex -> f ListIndex
listIndex_consistencyLevel = (ListIndex -> Maybe ConsistencyLevel)
-> (ListIndex -> Maybe ConsistencyLevel -> ListIndex)
-> Lens
     ListIndex
     ListIndex
     (Maybe ConsistencyLevel)
     (Maybe ConsistencyLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIndex' {Maybe ConsistencyLevel
consistencyLevel :: Maybe ConsistencyLevel
$sel:consistencyLevel:ListIndex' :: ListIndex -> Maybe ConsistencyLevel
consistencyLevel} -> Maybe ConsistencyLevel
consistencyLevel) (\s :: ListIndex
s@ListIndex' {} Maybe ConsistencyLevel
a -> ListIndex
s {$sel:consistencyLevel:ListIndex' :: Maybe ConsistencyLevel
consistencyLevel = Maybe ConsistencyLevel
a} :: ListIndex)

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

-- | The maximum number of objects in a single page to retrieve from the
-- index during a request. For more information, see
-- <http://docs.aws.amazon.com/clouddirectory/latest/developerguide/limits.html Amazon Cloud Directory Limits>.
listIndex_maxResults :: Lens.Lens' ListIndex (Prelude.Maybe Prelude.Natural)
listIndex_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> ListIndex -> f ListIndex
listIndex_maxResults = (ListIndex -> Maybe Natural)
-> (ListIndex -> Maybe Natural -> ListIndex)
-> Lens ListIndex ListIndex (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIndex' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListIndex' :: ListIndex -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListIndex
s@ListIndex' {} Maybe Natural
a -> ListIndex
s {$sel:maxResults:ListIndex' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListIndex)

-- | The ARN of the directory that the index exists in.
listIndex_directoryArn :: Lens.Lens' ListIndex Prelude.Text
listIndex_directoryArn :: (Text -> f Text) -> ListIndex -> f ListIndex
listIndex_directoryArn = (ListIndex -> Text)
-> (ListIndex -> Text -> ListIndex)
-> Lens ListIndex ListIndex Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIndex' {Text
directoryArn :: Text
$sel:directoryArn:ListIndex' :: ListIndex -> Text
directoryArn} -> Text
directoryArn) (\s :: ListIndex
s@ListIndex' {} Text
a -> ListIndex
s {$sel:directoryArn:ListIndex' :: Text
directoryArn = Text
a} :: ListIndex)

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

instance Core.AWSPager ListIndex where
  page :: ListIndex -> AWSResponse ListIndex -> Maybe ListIndex
page ListIndex
rq AWSResponse ListIndex
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListIndex
ListIndexResponse
rs
            ListIndexResponse
-> Getting (First Text) ListIndexResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListIndexResponse -> Const (First Text) ListIndexResponse
Lens' ListIndexResponse (Maybe Text)
listIndexResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListIndexResponse -> Const (First Text) ListIndexResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListIndexResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListIndex
forall a. Maybe a
Prelude.Nothing
    | Maybe [IndexAttachment] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListIndex
ListIndexResponse
rs
            ListIndexResponse
-> Getting
     (First [IndexAttachment]) ListIndexResponse [IndexAttachment]
-> Maybe [IndexAttachment]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [IndexAttachment]
 -> Const (First [IndexAttachment]) (Maybe [IndexAttachment]))
-> ListIndexResponse
-> Const (First [IndexAttachment]) ListIndexResponse
Lens' ListIndexResponse (Maybe [IndexAttachment])
listIndexResponse_indexAttachments
              ((Maybe [IndexAttachment]
  -> Const (First [IndexAttachment]) (Maybe [IndexAttachment]))
 -> ListIndexResponse
 -> Const (First [IndexAttachment]) ListIndexResponse)
-> (([IndexAttachment]
     -> Const (First [IndexAttachment]) [IndexAttachment])
    -> Maybe [IndexAttachment]
    -> Const (First [IndexAttachment]) (Maybe [IndexAttachment]))
-> Getting
     (First [IndexAttachment]) ListIndexResponse [IndexAttachment]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([IndexAttachment]
 -> Const (First [IndexAttachment]) [IndexAttachment])
-> Maybe [IndexAttachment]
-> Const (First [IndexAttachment]) (Maybe [IndexAttachment])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListIndex
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListIndex -> Maybe ListIndex
forall a. a -> Maybe a
Prelude.Just (ListIndex -> Maybe ListIndex) -> ListIndex -> Maybe ListIndex
forall a b. (a -> b) -> a -> b
Prelude.$
        ListIndex
rq
          ListIndex -> (ListIndex -> ListIndex) -> ListIndex
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListIndex -> Identity ListIndex
Lens ListIndex ListIndex (Maybe Text) (Maybe Text)
listIndex_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListIndex -> Identity ListIndex)
-> Maybe Text -> ListIndex -> ListIndex
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListIndex
ListIndexResponse
rs
          ListIndexResponse
-> Getting (First Text) ListIndexResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListIndexResponse -> Const (First Text) ListIndexResponse
Lens' ListIndexResponse (Maybe Text)
listIndexResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListIndexResponse -> Const (First Text) ListIndexResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListIndexResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListIndex where
  type AWSResponse ListIndex = ListIndexResponse
  request :: ListIndex -> Request ListIndex
request = Service -> ListIndex -> Request ListIndex
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListIndex
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListIndex)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListIndex))
-> Logger
-> Service
-> Proxy ListIndex
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListIndex)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [IndexAttachment] -> Maybe Text -> Int -> ListIndexResponse
ListIndexResponse'
            (Maybe [IndexAttachment] -> Maybe Text -> Int -> ListIndexResponse)
-> Either String (Maybe [IndexAttachment])
-> Either String (Maybe Text -> Int -> ListIndexResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [IndexAttachment]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"IndexAttachments"
                            Either String (Maybe (Maybe [IndexAttachment]))
-> Maybe [IndexAttachment]
-> Either String (Maybe [IndexAttachment])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [IndexAttachment]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Maybe Text -> Int -> ListIndexResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListIndexResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> ListIndexResponse)
-> Either String Int -> Either String ListIndexResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListIndex

instance Prelude.NFData ListIndex

instance Core.ToHeaders ListIndex where
  toHeaders :: ListIndex -> ResponseHeaders
toHeaders ListIndex' {Maybe Natural
Maybe [ObjectAttributeRange]
Maybe Text
Maybe ConsistencyLevel
Text
ObjectReference
indexReference :: ObjectReference
directoryArn :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
consistencyLevel :: Maybe ConsistencyLevel
rangesOnIndexedValues :: Maybe [ObjectAttributeRange]
$sel:indexReference:ListIndex' :: ListIndex -> ObjectReference
$sel:directoryArn:ListIndex' :: ListIndex -> Text
$sel:maxResults:ListIndex' :: ListIndex -> Maybe Natural
$sel:nextToken:ListIndex' :: ListIndex -> Maybe Text
$sel:consistencyLevel:ListIndex' :: ListIndex -> Maybe ConsistencyLevel
$sel:rangesOnIndexedValues:ListIndex' :: ListIndex -> Maybe [ObjectAttributeRange]
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-consistency-level" HeaderName -> Maybe ConsistencyLevel -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe ConsistencyLevel
consistencyLevel,
        HeaderName
"x-amz-data-partition" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
directoryArn
      ]

instance Core.ToJSON ListIndex where
  toJSON :: ListIndex -> Value
toJSON ListIndex' {Maybe Natural
Maybe [ObjectAttributeRange]
Maybe Text
Maybe ConsistencyLevel
Text
ObjectReference
indexReference :: ObjectReference
directoryArn :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
consistencyLevel :: Maybe ConsistencyLevel
rangesOnIndexedValues :: Maybe [ObjectAttributeRange]
$sel:indexReference:ListIndex' :: ListIndex -> ObjectReference
$sel:directoryArn:ListIndex' :: ListIndex -> Text
$sel:maxResults:ListIndex' :: ListIndex -> Maybe Natural
$sel:nextToken:ListIndex' :: ListIndex -> Maybe Text
$sel:consistencyLevel:ListIndex' :: ListIndex -> Maybe ConsistencyLevel
$sel:rangesOnIndexedValues:ListIndex' :: ListIndex -> 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)
          ]
      )

instance Core.ToPath ListIndex where
  toPath :: ListIndex -> ByteString
toPath =
    ByteString -> ListIndex -> ByteString
forall a b. a -> b -> a
Prelude.const
      ByteString
"/amazonclouddirectory/2017-01-11/index/targets"

instance Core.ToQuery ListIndex where
  toQuery :: ListIndex -> QueryString
toQuery = QueryString -> ListIndex -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListIndexResponse' smart constructor.
data ListIndexResponse = ListIndexResponse'
  { -- | The objects and indexed values attached to the index.
    ListIndexResponse -> Maybe [IndexAttachment]
indexAttachments :: Prelude.Maybe [IndexAttachment],
    -- | The pagination token.
    ListIndexResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListIndexResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListIndexResponse -> ListIndexResponse -> Bool
(ListIndexResponse -> ListIndexResponse -> Bool)
-> (ListIndexResponse -> ListIndexResponse -> Bool)
-> Eq ListIndexResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIndexResponse -> ListIndexResponse -> Bool
$c/= :: ListIndexResponse -> ListIndexResponse -> Bool
== :: ListIndexResponse -> ListIndexResponse -> Bool
$c== :: ListIndexResponse -> ListIndexResponse -> Bool
Prelude.Eq, ReadPrec [ListIndexResponse]
ReadPrec ListIndexResponse
Int -> ReadS ListIndexResponse
ReadS [ListIndexResponse]
(Int -> ReadS ListIndexResponse)
-> ReadS [ListIndexResponse]
-> ReadPrec ListIndexResponse
-> ReadPrec [ListIndexResponse]
-> Read ListIndexResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListIndexResponse]
$creadListPrec :: ReadPrec [ListIndexResponse]
readPrec :: ReadPrec ListIndexResponse
$creadPrec :: ReadPrec ListIndexResponse
readList :: ReadS [ListIndexResponse]
$creadList :: ReadS [ListIndexResponse]
readsPrec :: Int -> ReadS ListIndexResponse
$creadsPrec :: Int -> ReadS ListIndexResponse
Prelude.Read, Int -> ListIndexResponse -> ShowS
[ListIndexResponse] -> ShowS
ListIndexResponse -> String
(Int -> ListIndexResponse -> ShowS)
-> (ListIndexResponse -> String)
-> ([ListIndexResponse] -> ShowS)
-> Show ListIndexResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIndexResponse] -> ShowS
$cshowList :: [ListIndexResponse] -> ShowS
show :: ListIndexResponse -> String
$cshow :: ListIndexResponse -> String
showsPrec :: Int -> ListIndexResponse -> ShowS
$cshowsPrec :: Int -> ListIndexResponse -> ShowS
Prelude.Show, (forall x. ListIndexResponse -> Rep ListIndexResponse x)
-> (forall x. Rep ListIndexResponse x -> ListIndexResponse)
-> Generic ListIndexResponse
forall x. Rep ListIndexResponse x -> ListIndexResponse
forall x. ListIndexResponse -> Rep ListIndexResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListIndexResponse x -> ListIndexResponse
$cfrom :: forall x. ListIndexResponse -> Rep ListIndexResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListIndexResponse' 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:
--
-- 'indexAttachments', 'listIndexResponse_indexAttachments' - The objects and indexed values attached to the index.
--
-- 'nextToken', 'listIndexResponse_nextToken' - The pagination token.
--
-- 'httpStatus', 'listIndexResponse_httpStatus' - The response's http status code.
newListIndexResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListIndexResponse
newListIndexResponse :: Int -> ListIndexResponse
newListIndexResponse Int
pHttpStatus_ =
  ListIndexResponse' :: Maybe [IndexAttachment] -> Maybe Text -> Int -> ListIndexResponse
ListIndexResponse'
    { $sel:indexAttachments:ListIndexResponse' :: Maybe [IndexAttachment]
indexAttachments =
        Maybe [IndexAttachment]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListIndexResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListIndexResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The objects and indexed values attached to the index.
listIndexResponse_indexAttachments :: Lens.Lens' ListIndexResponse (Prelude.Maybe [IndexAttachment])
listIndexResponse_indexAttachments :: (Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
-> ListIndexResponse -> f ListIndexResponse
listIndexResponse_indexAttachments = (ListIndexResponse -> Maybe [IndexAttachment])
-> (ListIndexResponse
    -> Maybe [IndexAttachment] -> ListIndexResponse)
-> Lens' ListIndexResponse (Maybe [IndexAttachment])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIndexResponse' {Maybe [IndexAttachment]
indexAttachments :: Maybe [IndexAttachment]
$sel:indexAttachments:ListIndexResponse' :: ListIndexResponse -> Maybe [IndexAttachment]
indexAttachments} -> Maybe [IndexAttachment]
indexAttachments) (\s :: ListIndexResponse
s@ListIndexResponse' {} Maybe [IndexAttachment]
a -> ListIndexResponse
s {$sel:indexAttachments:ListIndexResponse' :: Maybe [IndexAttachment]
indexAttachments = Maybe [IndexAttachment]
a} :: ListIndexResponse) ((Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
 -> ListIndexResponse -> f ListIndexResponse)
-> ((Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
    -> Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
-> (Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
-> ListIndexResponse
-> f ListIndexResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [IndexAttachment]
  [IndexAttachment]
  [IndexAttachment]
  [IndexAttachment]
-> Iso
     (Maybe [IndexAttachment])
     (Maybe [IndexAttachment])
     (Maybe [IndexAttachment])
     (Maybe [IndexAttachment])
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
  [IndexAttachment]
  [IndexAttachment]
  [IndexAttachment]
  [IndexAttachment]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The response's http status code.
listIndexResponse_httpStatus :: Lens.Lens' ListIndexResponse Prelude.Int
listIndexResponse_httpStatus :: (Int -> f Int) -> ListIndexResponse -> f ListIndexResponse
listIndexResponse_httpStatus = (ListIndexResponse -> Int)
-> (ListIndexResponse -> Int -> ListIndexResponse)
-> Lens ListIndexResponse ListIndexResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIndexResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListIndexResponse' :: ListIndexResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListIndexResponse
s@ListIndexResponse' {} Int
a -> ListIndexResponse
s {$sel:httpStatus:ListIndexResponse' :: Int
httpStatus = Int
a} :: ListIndexResponse)

instance Prelude.NFData ListIndexResponse