{-# 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.SSM.ListDocuments
-- 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)
--
-- Returns all Systems Manager (SSM) documents in the current Amazon Web
-- Services account and Amazon Web Services Region. You can limit the
-- results of this request by using a filter.
--
-- This operation returns paginated results.
module Amazonka.SSM.ListDocuments
  ( -- * Creating a Request
    ListDocuments (..),
    newListDocuments,

    -- * Request Lenses
    listDocuments_documentFilterList,
    listDocuments_filters,
    listDocuments_nextToken,
    listDocuments_maxResults,

    -- * Destructuring the Response
    ListDocumentsResponse (..),
    newListDocumentsResponse,

    -- * Response Lenses
    listDocumentsResponse_documentIdentifiers,
    listDocumentsResponse_nextToken,
    listDocumentsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListDocuments' smart constructor.
data ListDocuments = ListDocuments'
  { -- | This data type is deprecated. Instead, use @Filters@.
    ListDocuments -> Maybe (NonEmpty DocumentFilter)
documentFilterList :: Prelude.Maybe (Prelude.NonEmpty DocumentFilter),
    -- | One or more @DocumentKeyValuesFilter@ objects. Use a filter to return a
    -- more specific list of results. For keys, you can specify one or more
    -- key-value pair tags that have been applied to a document. Other valid
    -- keys include @Owner@, @Name@, @PlatformTypes@, @DocumentType@, and
    -- @TargetType@. For example, to return documents you own use
    -- @Key=Owner,Values=Self@. To specify a custom key-value pair, use the
    -- format @Key=tag:tagName,Values=valueName@.
    --
    -- This API operation only supports filtering documents by using a single
    -- tag key and one or more tag values. For example:
    -- @Key=tag:tagName,Values=valueName1,valueName2@
    ListDocuments -> Maybe [DocumentKeyValuesFilter]
filters :: Prelude.Maybe [DocumentKeyValuesFilter],
    -- | The token for the next set of items to return. (You received this token
    -- from a previous call.)
    ListDocuments -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return for this call. The call also
    -- returns a token that you can specify in a subsequent call to get the
    -- next set of results.
    ListDocuments -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListDocuments -> ListDocuments -> Bool
(ListDocuments -> ListDocuments -> Bool)
-> (ListDocuments -> ListDocuments -> Bool) -> Eq ListDocuments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDocuments -> ListDocuments -> Bool
$c/= :: ListDocuments -> ListDocuments -> Bool
== :: ListDocuments -> ListDocuments -> Bool
$c== :: ListDocuments -> ListDocuments -> Bool
Prelude.Eq, ReadPrec [ListDocuments]
ReadPrec ListDocuments
Int -> ReadS ListDocuments
ReadS [ListDocuments]
(Int -> ReadS ListDocuments)
-> ReadS [ListDocuments]
-> ReadPrec ListDocuments
-> ReadPrec [ListDocuments]
-> Read ListDocuments
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDocuments]
$creadListPrec :: ReadPrec [ListDocuments]
readPrec :: ReadPrec ListDocuments
$creadPrec :: ReadPrec ListDocuments
readList :: ReadS [ListDocuments]
$creadList :: ReadS [ListDocuments]
readsPrec :: Int -> ReadS ListDocuments
$creadsPrec :: Int -> ReadS ListDocuments
Prelude.Read, Int -> ListDocuments -> ShowS
[ListDocuments] -> ShowS
ListDocuments -> String
(Int -> ListDocuments -> ShowS)
-> (ListDocuments -> String)
-> ([ListDocuments] -> ShowS)
-> Show ListDocuments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDocuments] -> ShowS
$cshowList :: [ListDocuments] -> ShowS
show :: ListDocuments -> String
$cshow :: ListDocuments -> String
showsPrec :: Int -> ListDocuments -> ShowS
$cshowsPrec :: Int -> ListDocuments -> ShowS
Prelude.Show, (forall x. ListDocuments -> Rep ListDocuments x)
-> (forall x. Rep ListDocuments x -> ListDocuments)
-> Generic ListDocuments
forall x. Rep ListDocuments x -> ListDocuments
forall x. ListDocuments -> Rep ListDocuments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDocuments x -> ListDocuments
$cfrom :: forall x. ListDocuments -> Rep ListDocuments x
Prelude.Generic)

-- |
-- Create a value of 'ListDocuments' 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:
--
-- 'documentFilterList', 'listDocuments_documentFilterList' - This data type is deprecated. Instead, use @Filters@.
--
-- 'filters', 'listDocuments_filters' - One or more @DocumentKeyValuesFilter@ objects. Use a filter to return a
-- more specific list of results. For keys, you can specify one or more
-- key-value pair tags that have been applied to a document. Other valid
-- keys include @Owner@, @Name@, @PlatformTypes@, @DocumentType@, and
-- @TargetType@. For example, to return documents you own use
-- @Key=Owner,Values=Self@. To specify a custom key-value pair, use the
-- format @Key=tag:tagName,Values=valueName@.
--
-- This API operation only supports filtering documents by using a single
-- tag key and one or more tag values. For example:
-- @Key=tag:tagName,Values=valueName1,valueName2@
--
-- 'nextToken', 'listDocuments_nextToken' - The token for the next set of items to return. (You received this token
-- from a previous call.)
--
-- 'maxResults', 'listDocuments_maxResults' - The maximum number of items to return for this call. The call also
-- returns a token that you can specify in a subsequent call to get the
-- next set of results.
newListDocuments ::
  ListDocuments
newListDocuments :: ListDocuments
newListDocuments =
  ListDocuments' :: Maybe (NonEmpty DocumentFilter)
-> Maybe [DocumentKeyValuesFilter]
-> Maybe Text
-> Maybe Natural
-> ListDocuments
ListDocuments'
    { $sel:documentFilterList:ListDocuments' :: Maybe (NonEmpty DocumentFilter)
documentFilterList =
        Maybe (NonEmpty DocumentFilter)
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:ListDocuments' :: Maybe [DocumentKeyValuesFilter]
filters = Maybe [DocumentKeyValuesFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDocuments' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListDocuments' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | This data type is deprecated. Instead, use @Filters@.
listDocuments_documentFilterList :: Lens.Lens' ListDocuments (Prelude.Maybe (Prelude.NonEmpty DocumentFilter))
listDocuments_documentFilterList :: (Maybe (NonEmpty DocumentFilter)
 -> f (Maybe (NonEmpty DocumentFilter)))
-> ListDocuments -> f ListDocuments
listDocuments_documentFilterList = (ListDocuments -> Maybe (NonEmpty DocumentFilter))
-> (ListDocuments
    -> Maybe (NonEmpty DocumentFilter) -> ListDocuments)
-> Lens
     ListDocuments
     ListDocuments
     (Maybe (NonEmpty DocumentFilter))
     (Maybe (NonEmpty DocumentFilter))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDocuments' {Maybe (NonEmpty DocumentFilter)
documentFilterList :: Maybe (NonEmpty DocumentFilter)
$sel:documentFilterList:ListDocuments' :: ListDocuments -> Maybe (NonEmpty DocumentFilter)
documentFilterList} -> Maybe (NonEmpty DocumentFilter)
documentFilterList) (\s :: ListDocuments
s@ListDocuments' {} Maybe (NonEmpty DocumentFilter)
a -> ListDocuments
s {$sel:documentFilterList:ListDocuments' :: Maybe (NonEmpty DocumentFilter)
documentFilterList = Maybe (NonEmpty DocumentFilter)
a} :: ListDocuments) ((Maybe (NonEmpty DocumentFilter)
  -> f (Maybe (NonEmpty DocumentFilter)))
 -> ListDocuments -> f ListDocuments)
-> ((Maybe (NonEmpty DocumentFilter)
     -> f (Maybe (NonEmpty DocumentFilter)))
    -> Maybe (NonEmpty DocumentFilter)
    -> f (Maybe (NonEmpty DocumentFilter)))
-> (Maybe (NonEmpty DocumentFilter)
    -> f (Maybe (NonEmpty DocumentFilter)))
-> ListDocuments
-> f ListDocuments
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty DocumentFilter)
  (NonEmpty DocumentFilter)
  (NonEmpty DocumentFilter)
  (NonEmpty DocumentFilter)
-> Iso
     (Maybe (NonEmpty DocumentFilter))
     (Maybe (NonEmpty DocumentFilter))
     (Maybe (NonEmpty DocumentFilter))
     (Maybe (NonEmpty DocumentFilter))
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
  (NonEmpty DocumentFilter)
  (NonEmpty DocumentFilter)
  (NonEmpty DocumentFilter)
  (NonEmpty DocumentFilter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | One or more @DocumentKeyValuesFilter@ objects. Use a filter to return a
-- more specific list of results. For keys, you can specify one or more
-- key-value pair tags that have been applied to a document. Other valid
-- keys include @Owner@, @Name@, @PlatformTypes@, @DocumentType@, and
-- @TargetType@. For example, to return documents you own use
-- @Key=Owner,Values=Self@. To specify a custom key-value pair, use the
-- format @Key=tag:tagName,Values=valueName@.
--
-- This API operation only supports filtering documents by using a single
-- tag key and one or more tag values. For example:
-- @Key=tag:tagName,Values=valueName1,valueName2@
listDocuments_filters :: Lens.Lens' ListDocuments (Prelude.Maybe [DocumentKeyValuesFilter])
listDocuments_filters :: (Maybe [DocumentKeyValuesFilter]
 -> f (Maybe [DocumentKeyValuesFilter]))
-> ListDocuments -> f ListDocuments
listDocuments_filters = (ListDocuments -> Maybe [DocumentKeyValuesFilter])
-> (ListDocuments
    -> Maybe [DocumentKeyValuesFilter] -> ListDocuments)
-> Lens
     ListDocuments
     ListDocuments
     (Maybe [DocumentKeyValuesFilter])
     (Maybe [DocumentKeyValuesFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDocuments' {Maybe [DocumentKeyValuesFilter]
filters :: Maybe [DocumentKeyValuesFilter]
$sel:filters:ListDocuments' :: ListDocuments -> Maybe [DocumentKeyValuesFilter]
filters} -> Maybe [DocumentKeyValuesFilter]
filters) (\s :: ListDocuments
s@ListDocuments' {} Maybe [DocumentKeyValuesFilter]
a -> ListDocuments
s {$sel:filters:ListDocuments' :: Maybe [DocumentKeyValuesFilter]
filters = Maybe [DocumentKeyValuesFilter]
a} :: ListDocuments) ((Maybe [DocumentKeyValuesFilter]
  -> f (Maybe [DocumentKeyValuesFilter]))
 -> ListDocuments -> f ListDocuments)
-> ((Maybe [DocumentKeyValuesFilter]
     -> f (Maybe [DocumentKeyValuesFilter]))
    -> Maybe [DocumentKeyValuesFilter]
    -> f (Maybe [DocumentKeyValuesFilter]))
-> (Maybe [DocumentKeyValuesFilter]
    -> f (Maybe [DocumentKeyValuesFilter]))
-> ListDocuments
-> f ListDocuments
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DocumentKeyValuesFilter]
  [DocumentKeyValuesFilter]
  [DocumentKeyValuesFilter]
  [DocumentKeyValuesFilter]
-> Iso
     (Maybe [DocumentKeyValuesFilter])
     (Maybe [DocumentKeyValuesFilter])
     (Maybe [DocumentKeyValuesFilter])
     (Maybe [DocumentKeyValuesFilter])
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
  [DocumentKeyValuesFilter]
  [DocumentKeyValuesFilter]
  [DocumentKeyValuesFilter]
  [DocumentKeyValuesFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token for the next set of items to return. (You received this token
-- from a previous call.)
listDocuments_nextToken :: Lens.Lens' ListDocuments (Prelude.Maybe Prelude.Text)
listDocuments_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListDocuments -> f ListDocuments
listDocuments_nextToken = (ListDocuments -> Maybe Text)
-> (ListDocuments -> Maybe Text -> ListDocuments)
-> Lens ListDocuments ListDocuments (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDocuments' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDocuments' :: ListDocuments -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDocuments
s@ListDocuments' {} Maybe Text
a -> ListDocuments
s {$sel:nextToken:ListDocuments' :: Maybe Text
nextToken = Maybe Text
a} :: ListDocuments)

-- | The maximum number of items to return for this call. The call also
-- returns a token that you can specify in a subsequent call to get the
-- next set of results.
listDocuments_maxResults :: Lens.Lens' ListDocuments (Prelude.Maybe Prelude.Natural)
listDocuments_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListDocuments -> f ListDocuments
listDocuments_maxResults = (ListDocuments -> Maybe Natural)
-> (ListDocuments -> Maybe Natural -> ListDocuments)
-> Lens ListDocuments ListDocuments (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDocuments' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDocuments' :: ListDocuments -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDocuments
s@ListDocuments' {} Maybe Natural
a -> ListDocuments
s {$sel:maxResults:ListDocuments' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDocuments)

instance Core.AWSPager ListDocuments where
  page :: ListDocuments -> AWSResponse ListDocuments -> Maybe ListDocuments
page ListDocuments
rq AWSResponse ListDocuments
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDocuments
ListDocumentsResponse
rs
            ListDocumentsResponse
-> Getting (First Text) ListDocumentsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListDocumentsResponse
-> Const (First Text) ListDocumentsResponse
Lens' ListDocumentsResponse (Maybe Text)
listDocumentsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListDocumentsResponse
 -> Const (First Text) ListDocumentsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListDocumentsResponse 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 ListDocuments
forall a. Maybe a
Prelude.Nothing
    | Maybe [DocumentIdentifier] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListDocuments
ListDocumentsResponse
rs
            ListDocumentsResponse
-> Getting
     (First [DocumentIdentifier])
     ListDocumentsResponse
     [DocumentIdentifier]
-> Maybe [DocumentIdentifier]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [DocumentIdentifier]
 -> Const (First [DocumentIdentifier]) (Maybe [DocumentIdentifier]))
-> ListDocumentsResponse
-> Const (First [DocumentIdentifier]) ListDocumentsResponse
Lens' ListDocumentsResponse (Maybe [DocumentIdentifier])
listDocumentsResponse_documentIdentifiers
              ((Maybe [DocumentIdentifier]
  -> Const (First [DocumentIdentifier]) (Maybe [DocumentIdentifier]))
 -> ListDocumentsResponse
 -> Const (First [DocumentIdentifier]) ListDocumentsResponse)
-> (([DocumentIdentifier]
     -> Const (First [DocumentIdentifier]) [DocumentIdentifier])
    -> Maybe [DocumentIdentifier]
    -> Const (First [DocumentIdentifier]) (Maybe [DocumentIdentifier]))
-> Getting
     (First [DocumentIdentifier])
     ListDocumentsResponse
     [DocumentIdentifier]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([DocumentIdentifier]
 -> Const (First [DocumentIdentifier]) [DocumentIdentifier])
-> Maybe [DocumentIdentifier]
-> Const (First [DocumentIdentifier]) (Maybe [DocumentIdentifier])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListDocuments
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListDocuments -> Maybe ListDocuments
forall a. a -> Maybe a
Prelude.Just (ListDocuments -> Maybe ListDocuments)
-> ListDocuments -> Maybe ListDocuments
forall a b. (a -> b) -> a -> b
Prelude.$
        ListDocuments
rq
          ListDocuments -> (ListDocuments -> ListDocuments) -> ListDocuments
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListDocuments -> Identity ListDocuments
Lens ListDocuments ListDocuments (Maybe Text) (Maybe Text)
listDocuments_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListDocuments -> Identity ListDocuments)
-> Maybe Text -> ListDocuments -> ListDocuments
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListDocuments
ListDocumentsResponse
rs
          ListDocumentsResponse
-> Getting (First Text) ListDocumentsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListDocumentsResponse
-> Const (First Text) ListDocumentsResponse
Lens' ListDocumentsResponse (Maybe Text)
listDocumentsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListDocumentsResponse
 -> Const (First Text) ListDocumentsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListDocumentsResponse 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 ListDocuments where
  type
    AWSResponse ListDocuments =
      ListDocumentsResponse
  request :: ListDocuments -> Request ListDocuments
request = Service -> ListDocuments -> Request ListDocuments
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListDocuments
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDocuments)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListDocuments))
-> Logger
-> Service
-> Proxy ListDocuments
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDocuments)))
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 [DocumentIdentifier]
-> Maybe Text -> Int -> ListDocumentsResponse
ListDocumentsResponse'
            (Maybe [DocumentIdentifier]
 -> Maybe Text -> Int -> ListDocumentsResponse)
-> Either String (Maybe [DocumentIdentifier])
-> Either String (Maybe Text -> Int -> ListDocumentsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [DocumentIdentifier]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DocumentIdentifiers"
                            Either String (Maybe (Maybe [DocumentIdentifier]))
-> Maybe [DocumentIdentifier]
-> Either String (Maybe [DocumentIdentifier])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DocumentIdentifier]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Maybe Text -> Int -> ListDocumentsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListDocumentsResponse)
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 -> ListDocumentsResponse)
-> Either String Int -> Either String ListDocumentsResponse
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 ListDocuments

instance Prelude.NFData ListDocuments

instance Core.ToHeaders ListDocuments where
  toHeaders :: ListDocuments -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListDocuments -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"AmazonSSM.ListDocuments" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListDocuments where
  toJSON :: ListDocuments -> Value
toJSON ListDocuments' {Maybe Natural
Maybe [DocumentKeyValuesFilter]
Maybe (NonEmpty DocumentFilter)
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
filters :: Maybe [DocumentKeyValuesFilter]
documentFilterList :: Maybe (NonEmpty DocumentFilter)
$sel:maxResults:ListDocuments' :: ListDocuments -> Maybe Natural
$sel:nextToken:ListDocuments' :: ListDocuments -> Maybe Text
$sel:filters:ListDocuments' :: ListDocuments -> Maybe [DocumentKeyValuesFilter]
$sel:documentFilterList:ListDocuments' :: ListDocuments -> Maybe (NonEmpty DocumentFilter)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DocumentFilterList" Text -> NonEmpty DocumentFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty DocumentFilter -> Pair)
-> Maybe (NonEmpty DocumentFilter) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty DocumentFilter)
documentFilterList,
            (Text
"Filters" Text -> [DocumentKeyValuesFilter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([DocumentKeyValuesFilter] -> Pair)
-> Maybe [DocumentKeyValuesFilter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DocumentKeyValuesFilter]
filters,
            (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
          ]
      )

instance Core.ToPath ListDocuments where
  toPath :: ListDocuments -> ByteString
toPath = ByteString -> ListDocuments -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListDocumentsResponse' smart constructor.
data ListDocumentsResponse = ListDocumentsResponse'
  { -- | The names of the SSM documents.
    ListDocumentsResponse -> Maybe [DocumentIdentifier]
documentIdentifiers :: Prelude.Maybe [DocumentIdentifier],
    -- | The token to use when requesting the next set of items. If there are no
    -- additional items to return, the string is empty.
    ListDocumentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDocumentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDocumentsResponse -> ListDocumentsResponse -> Bool
(ListDocumentsResponse -> ListDocumentsResponse -> Bool)
-> (ListDocumentsResponse -> ListDocumentsResponse -> Bool)
-> Eq ListDocumentsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDocumentsResponse -> ListDocumentsResponse -> Bool
$c/= :: ListDocumentsResponse -> ListDocumentsResponse -> Bool
== :: ListDocumentsResponse -> ListDocumentsResponse -> Bool
$c== :: ListDocumentsResponse -> ListDocumentsResponse -> Bool
Prelude.Eq, ReadPrec [ListDocumentsResponse]
ReadPrec ListDocumentsResponse
Int -> ReadS ListDocumentsResponse
ReadS [ListDocumentsResponse]
(Int -> ReadS ListDocumentsResponse)
-> ReadS [ListDocumentsResponse]
-> ReadPrec ListDocumentsResponse
-> ReadPrec [ListDocumentsResponse]
-> Read ListDocumentsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDocumentsResponse]
$creadListPrec :: ReadPrec [ListDocumentsResponse]
readPrec :: ReadPrec ListDocumentsResponse
$creadPrec :: ReadPrec ListDocumentsResponse
readList :: ReadS [ListDocumentsResponse]
$creadList :: ReadS [ListDocumentsResponse]
readsPrec :: Int -> ReadS ListDocumentsResponse
$creadsPrec :: Int -> ReadS ListDocumentsResponse
Prelude.Read, Int -> ListDocumentsResponse -> ShowS
[ListDocumentsResponse] -> ShowS
ListDocumentsResponse -> String
(Int -> ListDocumentsResponse -> ShowS)
-> (ListDocumentsResponse -> String)
-> ([ListDocumentsResponse] -> ShowS)
-> Show ListDocumentsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDocumentsResponse] -> ShowS
$cshowList :: [ListDocumentsResponse] -> ShowS
show :: ListDocumentsResponse -> String
$cshow :: ListDocumentsResponse -> String
showsPrec :: Int -> ListDocumentsResponse -> ShowS
$cshowsPrec :: Int -> ListDocumentsResponse -> ShowS
Prelude.Show, (forall x. ListDocumentsResponse -> Rep ListDocumentsResponse x)
-> (forall x. Rep ListDocumentsResponse x -> ListDocumentsResponse)
-> Generic ListDocumentsResponse
forall x. Rep ListDocumentsResponse x -> ListDocumentsResponse
forall x. ListDocumentsResponse -> Rep ListDocumentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDocumentsResponse x -> ListDocumentsResponse
$cfrom :: forall x. ListDocumentsResponse -> Rep ListDocumentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDocumentsResponse' 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:
--
-- 'documentIdentifiers', 'listDocumentsResponse_documentIdentifiers' - The names of the SSM documents.
--
-- 'nextToken', 'listDocumentsResponse_nextToken' - The token to use when requesting the next set of items. If there are no
-- additional items to return, the string is empty.
--
-- 'httpStatus', 'listDocumentsResponse_httpStatus' - The response's http status code.
newListDocumentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDocumentsResponse
newListDocumentsResponse :: Int -> ListDocumentsResponse
newListDocumentsResponse Int
pHttpStatus_ =
  ListDocumentsResponse' :: Maybe [DocumentIdentifier]
-> Maybe Text -> Int -> ListDocumentsResponse
ListDocumentsResponse'
    { $sel:documentIdentifiers:ListDocumentsResponse' :: Maybe [DocumentIdentifier]
documentIdentifiers =
        Maybe [DocumentIdentifier]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDocumentsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDocumentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The names of the SSM documents.
listDocumentsResponse_documentIdentifiers :: Lens.Lens' ListDocumentsResponse (Prelude.Maybe [DocumentIdentifier])
listDocumentsResponse_documentIdentifiers :: (Maybe [DocumentIdentifier] -> f (Maybe [DocumentIdentifier]))
-> ListDocumentsResponse -> f ListDocumentsResponse
listDocumentsResponse_documentIdentifiers = (ListDocumentsResponse -> Maybe [DocumentIdentifier])
-> (ListDocumentsResponse
    -> Maybe [DocumentIdentifier] -> ListDocumentsResponse)
-> Lens' ListDocumentsResponse (Maybe [DocumentIdentifier])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDocumentsResponse' {Maybe [DocumentIdentifier]
documentIdentifiers :: Maybe [DocumentIdentifier]
$sel:documentIdentifiers:ListDocumentsResponse' :: ListDocumentsResponse -> Maybe [DocumentIdentifier]
documentIdentifiers} -> Maybe [DocumentIdentifier]
documentIdentifiers) (\s :: ListDocumentsResponse
s@ListDocumentsResponse' {} Maybe [DocumentIdentifier]
a -> ListDocumentsResponse
s {$sel:documentIdentifiers:ListDocumentsResponse' :: Maybe [DocumentIdentifier]
documentIdentifiers = Maybe [DocumentIdentifier]
a} :: ListDocumentsResponse) ((Maybe [DocumentIdentifier] -> f (Maybe [DocumentIdentifier]))
 -> ListDocumentsResponse -> f ListDocumentsResponse)
-> ((Maybe [DocumentIdentifier] -> f (Maybe [DocumentIdentifier]))
    -> Maybe [DocumentIdentifier] -> f (Maybe [DocumentIdentifier]))
-> (Maybe [DocumentIdentifier] -> f (Maybe [DocumentIdentifier]))
-> ListDocumentsResponse
-> f ListDocumentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DocumentIdentifier]
  [DocumentIdentifier]
  [DocumentIdentifier]
  [DocumentIdentifier]
-> Iso
     (Maybe [DocumentIdentifier])
     (Maybe [DocumentIdentifier])
     (Maybe [DocumentIdentifier])
     (Maybe [DocumentIdentifier])
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
  [DocumentIdentifier]
  [DocumentIdentifier]
  [DocumentIdentifier]
  [DocumentIdentifier]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token to use when requesting the next set of items. If there are no
-- additional items to return, the string is empty.
listDocumentsResponse_nextToken :: Lens.Lens' ListDocumentsResponse (Prelude.Maybe Prelude.Text)
listDocumentsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDocumentsResponse -> f ListDocumentsResponse
listDocumentsResponse_nextToken = (ListDocumentsResponse -> Maybe Text)
-> (ListDocumentsResponse -> Maybe Text -> ListDocumentsResponse)
-> Lens' ListDocumentsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDocumentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDocumentsResponse' :: ListDocumentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDocumentsResponse
s@ListDocumentsResponse' {} Maybe Text
a -> ListDocumentsResponse
s {$sel:nextToken:ListDocumentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDocumentsResponse)

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

instance Prelude.NFData ListDocumentsResponse