{-# 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.ListAttachedIndices
-- 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 indices attached to the specified object.
--
-- This operation returns paginated results.
module Amazonka.CloudDirectory.ListAttachedIndices
  ( -- * Creating a Request
    ListAttachedIndices (..),
    newListAttachedIndices,

    -- * Request Lenses
    listAttachedIndices_consistencyLevel,
    listAttachedIndices_nextToken,
    listAttachedIndices_maxResults,
    listAttachedIndices_directoryArn,
    listAttachedIndices_targetReference,

    -- * Destructuring the Response
    ListAttachedIndicesResponse (..),
    newListAttachedIndicesResponse,

    -- * Response Lenses
    listAttachedIndicesResponse_indexAttachments,
    listAttachedIndicesResponse_nextToken,
    listAttachedIndicesResponse_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:/ 'newListAttachedIndices' smart constructor.
data ListAttachedIndices = ListAttachedIndices'
  { -- | The consistency level to use for this operation.
    ListAttachedIndices -> Maybe ConsistencyLevel
consistencyLevel :: Prelude.Maybe ConsistencyLevel,
    -- | The pagination token.
    ListAttachedIndices -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to retrieve.
    ListAttachedIndices -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ARN of the directory.
    ListAttachedIndices -> Text
directoryArn :: Prelude.Text,
    -- | A reference to the object that has indices attached.
    ListAttachedIndices -> ObjectReference
targetReference :: ObjectReference
  }
  deriving (ListAttachedIndices -> ListAttachedIndices -> Bool
(ListAttachedIndices -> ListAttachedIndices -> Bool)
-> (ListAttachedIndices -> ListAttachedIndices -> Bool)
-> Eq ListAttachedIndices
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAttachedIndices -> ListAttachedIndices -> Bool
$c/= :: ListAttachedIndices -> ListAttachedIndices -> Bool
== :: ListAttachedIndices -> ListAttachedIndices -> Bool
$c== :: ListAttachedIndices -> ListAttachedIndices -> Bool
Prelude.Eq, ReadPrec [ListAttachedIndices]
ReadPrec ListAttachedIndices
Int -> ReadS ListAttachedIndices
ReadS [ListAttachedIndices]
(Int -> ReadS ListAttachedIndices)
-> ReadS [ListAttachedIndices]
-> ReadPrec ListAttachedIndices
-> ReadPrec [ListAttachedIndices]
-> Read ListAttachedIndices
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAttachedIndices]
$creadListPrec :: ReadPrec [ListAttachedIndices]
readPrec :: ReadPrec ListAttachedIndices
$creadPrec :: ReadPrec ListAttachedIndices
readList :: ReadS [ListAttachedIndices]
$creadList :: ReadS [ListAttachedIndices]
readsPrec :: Int -> ReadS ListAttachedIndices
$creadsPrec :: Int -> ReadS ListAttachedIndices
Prelude.Read, Int -> ListAttachedIndices -> ShowS
[ListAttachedIndices] -> ShowS
ListAttachedIndices -> String
(Int -> ListAttachedIndices -> ShowS)
-> (ListAttachedIndices -> String)
-> ([ListAttachedIndices] -> ShowS)
-> Show ListAttachedIndices
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAttachedIndices] -> ShowS
$cshowList :: [ListAttachedIndices] -> ShowS
show :: ListAttachedIndices -> String
$cshow :: ListAttachedIndices -> String
showsPrec :: Int -> ListAttachedIndices -> ShowS
$cshowsPrec :: Int -> ListAttachedIndices -> ShowS
Prelude.Show, (forall x. ListAttachedIndices -> Rep ListAttachedIndices x)
-> (forall x. Rep ListAttachedIndices x -> ListAttachedIndices)
-> Generic ListAttachedIndices
forall x. Rep ListAttachedIndices x -> ListAttachedIndices
forall x. ListAttachedIndices -> Rep ListAttachedIndices x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAttachedIndices x -> ListAttachedIndices
$cfrom :: forall x. ListAttachedIndices -> Rep ListAttachedIndices x
Prelude.Generic)

-- |
-- Create a value of 'ListAttachedIndices' 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:
--
-- 'consistencyLevel', 'listAttachedIndices_consistencyLevel' - The consistency level to use for this operation.
--
-- 'nextToken', 'listAttachedIndices_nextToken' - The pagination token.
--
-- 'maxResults', 'listAttachedIndices_maxResults' - The maximum number of results to retrieve.
--
-- 'directoryArn', 'listAttachedIndices_directoryArn' - The ARN of the directory.
--
-- 'targetReference', 'listAttachedIndices_targetReference' - A reference to the object that has indices attached.
newListAttachedIndices ::
  -- | 'directoryArn'
  Prelude.Text ->
  -- | 'targetReference'
  ObjectReference ->
  ListAttachedIndices
newListAttachedIndices :: Text -> ObjectReference -> ListAttachedIndices
newListAttachedIndices
  Text
pDirectoryArn_
  ObjectReference
pTargetReference_ =
    ListAttachedIndices' :: Maybe ConsistencyLevel
-> Maybe Text
-> Maybe Natural
-> Text
-> ObjectReference
-> ListAttachedIndices
ListAttachedIndices'
      { $sel:consistencyLevel:ListAttachedIndices' :: Maybe ConsistencyLevel
consistencyLevel =
          Maybe ConsistencyLevel
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:ListAttachedIndices' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:ListAttachedIndices' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:directoryArn:ListAttachedIndices' :: Text
directoryArn = Text
pDirectoryArn_,
        $sel:targetReference:ListAttachedIndices' :: ObjectReference
targetReference = ObjectReference
pTargetReference_
      }

-- | The consistency level to use for this operation.
listAttachedIndices_consistencyLevel :: Lens.Lens' ListAttachedIndices (Prelude.Maybe ConsistencyLevel)
listAttachedIndices_consistencyLevel :: (Maybe ConsistencyLevel -> f (Maybe ConsistencyLevel))
-> ListAttachedIndices -> f ListAttachedIndices
listAttachedIndices_consistencyLevel = (ListAttachedIndices -> Maybe ConsistencyLevel)
-> (ListAttachedIndices
    -> Maybe ConsistencyLevel -> ListAttachedIndices)
-> Lens
     ListAttachedIndices
     ListAttachedIndices
     (Maybe ConsistencyLevel)
     (Maybe ConsistencyLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedIndices' {Maybe ConsistencyLevel
consistencyLevel :: Maybe ConsistencyLevel
$sel:consistencyLevel:ListAttachedIndices' :: ListAttachedIndices -> Maybe ConsistencyLevel
consistencyLevel} -> Maybe ConsistencyLevel
consistencyLevel) (\s :: ListAttachedIndices
s@ListAttachedIndices' {} Maybe ConsistencyLevel
a -> ListAttachedIndices
s {$sel:consistencyLevel:ListAttachedIndices' :: Maybe ConsistencyLevel
consistencyLevel = Maybe ConsistencyLevel
a} :: ListAttachedIndices)

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

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

-- | The ARN of the directory.
listAttachedIndices_directoryArn :: Lens.Lens' ListAttachedIndices Prelude.Text
listAttachedIndices_directoryArn :: (Text -> f Text) -> ListAttachedIndices -> f ListAttachedIndices
listAttachedIndices_directoryArn = (ListAttachedIndices -> Text)
-> (ListAttachedIndices -> Text -> ListAttachedIndices)
-> Lens ListAttachedIndices ListAttachedIndices Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedIndices' {Text
directoryArn :: Text
$sel:directoryArn:ListAttachedIndices' :: ListAttachedIndices -> Text
directoryArn} -> Text
directoryArn) (\s :: ListAttachedIndices
s@ListAttachedIndices' {} Text
a -> ListAttachedIndices
s {$sel:directoryArn:ListAttachedIndices' :: Text
directoryArn = Text
a} :: ListAttachedIndices)

-- | A reference to the object that has indices attached.
listAttachedIndices_targetReference :: Lens.Lens' ListAttachedIndices ObjectReference
listAttachedIndices_targetReference :: (ObjectReference -> f ObjectReference)
-> ListAttachedIndices -> f ListAttachedIndices
listAttachedIndices_targetReference = (ListAttachedIndices -> ObjectReference)
-> (ListAttachedIndices -> ObjectReference -> ListAttachedIndices)
-> Lens
     ListAttachedIndices
     ListAttachedIndices
     ObjectReference
     ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedIndices' {ObjectReference
targetReference :: ObjectReference
$sel:targetReference:ListAttachedIndices' :: ListAttachedIndices -> ObjectReference
targetReference} -> ObjectReference
targetReference) (\s :: ListAttachedIndices
s@ListAttachedIndices' {} ObjectReference
a -> ListAttachedIndices
s {$sel:targetReference:ListAttachedIndices' :: ObjectReference
targetReference = ObjectReference
a} :: ListAttachedIndices)

instance Core.AWSPager ListAttachedIndices where
  page :: ListAttachedIndices
-> AWSResponse ListAttachedIndices -> Maybe ListAttachedIndices
page ListAttachedIndices
rq AWSResponse ListAttachedIndices
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAttachedIndices
ListAttachedIndicesResponse
rs
            ListAttachedIndicesResponse
-> Getting (First Text) ListAttachedIndicesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAttachedIndicesResponse
-> Const (First Text) ListAttachedIndicesResponse
Lens' ListAttachedIndicesResponse (Maybe Text)
listAttachedIndicesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAttachedIndicesResponse
 -> Const (First Text) ListAttachedIndicesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAttachedIndicesResponse 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 ListAttachedIndices
forall a. Maybe a
Prelude.Nothing
    | Maybe [IndexAttachment] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAttachedIndices
ListAttachedIndicesResponse
rs
            ListAttachedIndicesResponse
-> Getting
     (First [IndexAttachment])
     ListAttachedIndicesResponse
     [IndexAttachment]
-> Maybe [IndexAttachment]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [IndexAttachment]
 -> Const (First [IndexAttachment]) (Maybe [IndexAttachment]))
-> ListAttachedIndicesResponse
-> Const (First [IndexAttachment]) ListAttachedIndicesResponse
Lens' ListAttachedIndicesResponse (Maybe [IndexAttachment])
listAttachedIndicesResponse_indexAttachments
              ((Maybe [IndexAttachment]
  -> Const (First [IndexAttachment]) (Maybe [IndexAttachment]))
 -> ListAttachedIndicesResponse
 -> Const (First [IndexAttachment]) ListAttachedIndicesResponse)
-> (([IndexAttachment]
     -> Const (First [IndexAttachment]) [IndexAttachment])
    -> Maybe [IndexAttachment]
    -> Const (First [IndexAttachment]) (Maybe [IndexAttachment]))
-> Getting
     (First [IndexAttachment])
     ListAttachedIndicesResponse
     [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 ListAttachedIndices
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListAttachedIndices -> Maybe ListAttachedIndices
forall a. a -> Maybe a
Prelude.Just (ListAttachedIndices -> Maybe ListAttachedIndices)
-> ListAttachedIndices -> Maybe ListAttachedIndices
forall a b. (a -> b) -> a -> b
Prelude.$
        ListAttachedIndices
rq
          ListAttachedIndices
-> (ListAttachedIndices -> ListAttachedIndices)
-> ListAttachedIndices
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAttachedIndices -> Identity ListAttachedIndices
Lens
  ListAttachedIndices ListAttachedIndices (Maybe Text) (Maybe Text)
listAttachedIndices_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListAttachedIndices -> Identity ListAttachedIndices)
-> Maybe Text -> ListAttachedIndices -> ListAttachedIndices
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAttachedIndices
ListAttachedIndicesResponse
rs
          ListAttachedIndicesResponse
-> Getting (First Text) ListAttachedIndicesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAttachedIndicesResponse
-> Const (First Text) ListAttachedIndicesResponse
Lens' ListAttachedIndicesResponse (Maybe Text)
listAttachedIndicesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAttachedIndicesResponse
 -> Const (First Text) ListAttachedIndicesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAttachedIndicesResponse 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 ListAttachedIndices where
  type
    AWSResponse ListAttachedIndices =
      ListAttachedIndicesResponse
  request :: ListAttachedIndices -> Request ListAttachedIndices
request = Service -> ListAttachedIndices -> Request ListAttachedIndices
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAttachedIndices
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAttachedIndices)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAttachedIndices))
-> Logger
-> Service
-> Proxy ListAttachedIndices
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAttachedIndices)))
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 -> ListAttachedIndicesResponse
ListAttachedIndicesResponse'
            (Maybe [IndexAttachment]
 -> Maybe Text -> Int -> ListAttachedIndicesResponse)
-> Either String (Maybe [IndexAttachment])
-> Either String (Maybe Text -> Int -> ListAttachedIndicesResponse)
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 -> ListAttachedIndicesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListAttachedIndicesResponse)
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 -> ListAttachedIndicesResponse)
-> Either String Int -> Either String ListAttachedIndicesResponse
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 ListAttachedIndices

instance Prelude.NFData ListAttachedIndices

instance Core.ToHeaders ListAttachedIndices where
  toHeaders :: ListAttachedIndices -> ResponseHeaders
toHeaders ListAttachedIndices' {Maybe Natural
Maybe Text
Maybe ConsistencyLevel
Text
ObjectReference
targetReference :: ObjectReference
directoryArn :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
consistencyLevel :: Maybe ConsistencyLevel
$sel:targetReference:ListAttachedIndices' :: ListAttachedIndices -> ObjectReference
$sel:directoryArn:ListAttachedIndices' :: ListAttachedIndices -> Text
$sel:maxResults:ListAttachedIndices' :: ListAttachedIndices -> Maybe Natural
$sel:nextToken:ListAttachedIndices' :: ListAttachedIndices -> Maybe Text
$sel:consistencyLevel:ListAttachedIndices' :: ListAttachedIndices -> Maybe ConsistencyLevel
..} =
    [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 ListAttachedIndices where
  toJSON :: ListAttachedIndices -> Value
toJSON ListAttachedIndices' {Maybe Natural
Maybe Text
Maybe ConsistencyLevel
Text
ObjectReference
targetReference :: ObjectReference
directoryArn :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
consistencyLevel :: Maybe ConsistencyLevel
$sel:targetReference:ListAttachedIndices' :: ListAttachedIndices -> ObjectReference
$sel:directoryArn:ListAttachedIndices' :: ListAttachedIndices -> Text
$sel:maxResults:ListAttachedIndices' :: ListAttachedIndices -> Maybe Natural
$sel:nextToken:ListAttachedIndices' :: ListAttachedIndices -> Maybe Text
$sel:consistencyLevel:ListAttachedIndices' :: ListAttachedIndices -> Maybe ConsistencyLevel
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"TargetReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
targetReference)
          ]
      )

instance Core.ToPath ListAttachedIndices where
  toPath :: ListAttachedIndices -> ByteString
toPath =
    ByteString -> ListAttachedIndices -> ByteString
forall a b. a -> b -> a
Prelude.const
      ByteString
"/amazonclouddirectory/2017-01-11/object/indices"

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

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

-- |
-- Create a value of 'ListAttachedIndicesResponse' 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', 'listAttachedIndicesResponse_indexAttachments' - The indices attached to the specified object.
--
-- 'nextToken', 'listAttachedIndicesResponse_nextToken' - The pagination token.
--
-- 'httpStatus', 'listAttachedIndicesResponse_httpStatus' - The response's http status code.
newListAttachedIndicesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAttachedIndicesResponse
newListAttachedIndicesResponse :: Int -> ListAttachedIndicesResponse
newListAttachedIndicesResponse Int
pHttpStatus_ =
  ListAttachedIndicesResponse' :: Maybe [IndexAttachment]
-> Maybe Text -> Int -> ListAttachedIndicesResponse
ListAttachedIndicesResponse'
    { $sel:indexAttachments:ListAttachedIndicesResponse' :: Maybe [IndexAttachment]
indexAttachments =
        Maybe [IndexAttachment]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAttachedIndicesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAttachedIndicesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The indices attached to the specified object.
listAttachedIndicesResponse_indexAttachments :: Lens.Lens' ListAttachedIndicesResponse (Prelude.Maybe [IndexAttachment])
listAttachedIndicesResponse_indexAttachments :: (Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
-> ListAttachedIndicesResponse -> f ListAttachedIndicesResponse
listAttachedIndicesResponse_indexAttachments = (ListAttachedIndicesResponse -> Maybe [IndexAttachment])
-> (ListAttachedIndicesResponse
    -> Maybe [IndexAttachment] -> ListAttachedIndicesResponse)
-> Lens' ListAttachedIndicesResponse (Maybe [IndexAttachment])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedIndicesResponse' {Maybe [IndexAttachment]
indexAttachments :: Maybe [IndexAttachment]
$sel:indexAttachments:ListAttachedIndicesResponse' :: ListAttachedIndicesResponse -> Maybe [IndexAttachment]
indexAttachments} -> Maybe [IndexAttachment]
indexAttachments) (\s :: ListAttachedIndicesResponse
s@ListAttachedIndicesResponse' {} Maybe [IndexAttachment]
a -> ListAttachedIndicesResponse
s {$sel:indexAttachments:ListAttachedIndicesResponse' :: Maybe [IndexAttachment]
indexAttachments = Maybe [IndexAttachment]
a} :: ListAttachedIndicesResponse) ((Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
 -> ListAttachedIndicesResponse -> f ListAttachedIndicesResponse)
-> ((Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
    -> Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
-> (Maybe [IndexAttachment] -> f (Maybe [IndexAttachment]))
-> ListAttachedIndicesResponse
-> f ListAttachedIndicesResponse
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.
listAttachedIndicesResponse_nextToken :: Lens.Lens' ListAttachedIndicesResponse (Prelude.Maybe Prelude.Text)
listAttachedIndicesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAttachedIndicesResponse -> f ListAttachedIndicesResponse
listAttachedIndicesResponse_nextToken = (ListAttachedIndicesResponse -> Maybe Text)
-> (ListAttachedIndicesResponse
    -> Maybe Text -> ListAttachedIndicesResponse)
-> Lens' ListAttachedIndicesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttachedIndicesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAttachedIndicesResponse' :: ListAttachedIndicesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAttachedIndicesResponse
s@ListAttachedIndicesResponse' {} Maybe Text
a -> ListAttachedIndicesResponse
s {$sel:nextToken:ListAttachedIndicesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAttachedIndicesResponse)

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

instance Prelude.NFData ListAttachedIndicesResponse