{-# 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.ListCommands
-- 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 the commands requested by users of the Amazon Web Services
-- account.
--
-- This operation returns paginated results.
module Amazonka.SSM.ListCommands
  ( -- * Creating a Request
    ListCommands (..),
    newListCommands,

    -- * Request Lenses
    listCommands_instanceId,
    listCommands_filters,
    listCommands_nextToken,
    listCommands_commandId,
    listCommands_maxResults,

    -- * Destructuring the Response
    ListCommandsResponse (..),
    newListCommandsResponse,

    -- * Response Lenses
    listCommandsResponse_commands,
    listCommandsResponse_nextToken,
    listCommandsResponse_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:/ 'newListCommands' smart constructor.
data ListCommands = ListCommands'
  { -- | (Optional) Lists commands issued against this instance ID.
    --
    -- You can\'t specify an instance ID in the same command that you specify
    -- @Status@ = @Pending@. This is because the command hasn\'t reached the
    -- instance yet.
    ListCommands -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | (Optional) One or more filters. Use a filter to return a more specific
    -- list of results.
    ListCommands -> Maybe (NonEmpty CommandFilter)
filters :: Prelude.Maybe (Prelude.NonEmpty CommandFilter),
    -- | (Optional) The token for the next set of items to return. (You received
    -- this token from a previous call.)
    ListCommands -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | (Optional) If provided, lists only the specified command.
    ListCommands -> Maybe Text
commandId :: Prelude.Maybe Prelude.Text,
    -- | (Optional) 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.
    ListCommands -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListCommands -> ListCommands -> Bool
(ListCommands -> ListCommands -> Bool)
-> (ListCommands -> ListCommands -> Bool) -> Eq ListCommands
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCommands -> ListCommands -> Bool
$c/= :: ListCommands -> ListCommands -> Bool
== :: ListCommands -> ListCommands -> Bool
$c== :: ListCommands -> ListCommands -> Bool
Prelude.Eq, ReadPrec [ListCommands]
ReadPrec ListCommands
Int -> ReadS ListCommands
ReadS [ListCommands]
(Int -> ReadS ListCommands)
-> ReadS [ListCommands]
-> ReadPrec ListCommands
-> ReadPrec [ListCommands]
-> Read ListCommands
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCommands]
$creadListPrec :: ReadPrec [ListCommands]
readPrec :: ReadPrec ListCommands
$creadPrec :: ReadPrec ListCommands
readList :: ReadS [ListCommands]
$creadList :: ReadS [ListCommands]
readsPrec :: Int -> ReadS ListCommands
$creadsPrec :: Int -> ReadS ListCommands
Prelude.Read, Int -> ListCommands -> ShowS
[ListCommands] -> ShowS
ListCommands -> String
(Int -> ListCommands -> ShowS)
-> (ListCommands -> String)
-> ([ListCommands] -> ShowS)
-> Show ListCommands
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCommands] -> ShowS
$cshowList :: [ListCommands] -> ShowS
show :: ListCommands -> String
$cshow :: ListCommands -> String
showsPrec :: Int -> ListCommands -> ShowS
$cshowsPrec :: Int -> ListCommands -> ShowS
Prelude.Show, (forall x. ListCommands -> Rep ListCommands x)
-> (forall x. Rep ListCommands x -> ListCommands)
-> Generic ListCommands
forall x. Rep ListCommands x -> ListCommands
forall x. ListCommands -> Rep ListCommands x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCommands x -> ListCommands
$cfrom :: forall x. ListCommands -> Rep ListCommands x
Prelude.Generic)

-- |
-- Create a value of 'ListCommands' 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:
--
-- 'instanceId', 'listCommands_instanceId' - (Optional) Lists commands issued against this instance ID.
--
-- You can\'t specify an instance ID in the same command that you specify
-- @Status@ = @Pending@. This is because the command hasn\'t reached the
-- instance yet.
--
-- 'filters', 'listCommands_filters' - (Optional) One or more filters. Use a filter to return a more specific
-- list of results.
--
-- 'nextToken', 'listCommands_nextToken' - (Optional) The token for the next set of items to return. (You received
-- this token from a previous call.)
--
-- 'commandId', 'listCommands_commandId' - (Optional) If provided, lists only the specified command.
--
-- 'maxResults', 'listCommands_maxResults' - (Optional) 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.
newListCommands ::
  ListCommands
newListCommands :: ListCommands
newListCommands =
  ListCommands' :: Maybe Text
-> Maybe (NonEmpty CommandFilter)
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> ListCommands
ListCommands'
    { $sel:instanceId:ListCommands' :: Maybe Text
instanceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:ListCommands' :: Maybe (NonEmpty CommandFilter)
filters = Maybe (NonEmpty CommandFilter)
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCommands' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:commandId:ListCommands' :: Maybe Text
commandId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListCommands' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | (Optional) Lists commands issued against this instance ID.
--
-- You can\'t specify an instance ID in the same command that you specify
-- @Status@ = @Pending@. This is because the command hasn\'t reached the
-- instance yet.
listCommands_instanceId :: Lens.Lens' ListCommands (Prelude.Maybe Prelude.Text)
listCommands_instanceId :: (Maybe Text -> f (Maybe Text)) -> ListCommands -> f ListCommands
listCommands_instanceId = (ListCommands -> Maybe Text)
-> (ListCommands -> Maybe Text -> ListCommands)
-> Lens ListCommands ListCommands (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommands' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:ListCommands' :: ListCommands -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: ListCommands
s@ListCommands' {} Maybe Text
a -> ListCommands
s {$sel:instanceId:ListCommands' :: Maybe Text
instanceId = Maybe Text
a} :: ListCommands)

-- | (Optional) One or more filters. Use a filter to return a more specific
-- list of results.
listCommands_filters :: Lens.Lens' ListCommands (Prelude.Maybe (Prelude.NonEmpty CommandFilter))
listCommands_filters :: (Maybe (NonEmpty CommandFilter)
 -> f (Maybe (NonEmpty CommandFilter)))
-> ListCommands -> f ListCommands
listCommands_filters = (ListCommands -> Maybe (NonEmpty CommandFilter))
-> (ListCommands -> Maybe (NonEmpty CommandFilter) -> ListCommands)
-> Lens
     ListCommands
     ListCommands
     (Maybe (NonEmpty CommandFilter))
     (Maybe (NonEmpty CommandFilter))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommands' {Maybe (NonEmpty CommandFilter)
filters :: Maybe (NonEmpty CommandFilter)
$sel:filters:ListCommands' :: ListCommands -> Maybe (NonEmpty CommandFilter)
filters} -> Maybe (NonEmpty CommandFilter)
filters) (\s :: ListCommands
s@ListCommands' {} Maybe (NonEmpty CommandFilter)
a -> ListCommands
s {$sel:filters:ListCommands' :: Maybe (NonEmpty CommandFilter)
filters = Maybe (NonEmpty CommandFilter)
a} :: ListCommands) ((Maybe (NonEmpty CommandFilter)
  -> f (Maybe (NonEmpty CommandFilter)))
 -> ListCommands -> f ListCommands)
-> ((Maybe (NonEmpty CommandFilter)
     -> f (Maybe (NonEmpty CommandFilter)))
    -> Maybe (NonEmpty CommandFilter)
    -> f (Maybe (NonEmpty CommandFilter)))
-> (Maybe (NonEmpty CommandFilter)
    -> f (Maybe (NonEmpty CommandFilter)))
-> ListCommands
-> f ListCommands
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty CommandFilter)
  (NonEmpty CommandFilter)
  (NonEmpty CommandFilter)
  (NonEmpty CommandFilter)
-> Iso
     (Maybe (NonEmpty CommandFilter))
     (Maybe (NonEmpty CommandFilter))
     (Maybe (NonEmpty CommandFilter))
     (Maybe (NonEmpty CommandFilter))
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 CommandFilter)
  (NonEmpty CommandFilter)
  (NonEmpty CommandFilter)
  (NonEmpty CommandFilter)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | (Optional) If provided, lists only the specified command.
listCommands_commandId :: Lens.Lens' ListCommands (Prelude.Maybe Prelude.Text)
listCommands_commandId :: (Maybe Text -> f (Maybe Text)) -> ListCommands -> f ListCommands
listCommands_commandId = (ListCommands -> Maybe Text)
-> (ListCommands -> Maybe Text -> ListCommands)
-> Lens ListCommands ListCommands (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommands' {Maybe Text
commandId :: Maybe Text
$sel:commandId:ListCommands' :: ListCommands -> Maybe Text
commandId} -> Maybe Text
commandId) (\s :: ListCommands
s@ListCommands' {} Maybe Text
a -> ListCommands
s {$sel:commandId:ListCommands' :: Maybe Text
commandId = Maybe Text
a} :: ListCommands)

-- | (Optional) 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.
listCommands_maxResults :: Lens.Lens' ListCommands (Prelude.Maybe Prelude.Natural)
listCommands_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListCommands -> f ListCommands
listCommands_maxResults = (ListCommands -> Maybe Natural)
-> (ListCommands -> Maybe Natural -> ListCommands)
-> Lens ListCommands ListCommands (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommands' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListCommands' :: ListCommands -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListCommands
s@ListCommands' {} Maybe Natural
a -> ListCommands
s {$sel:maxResults:ListCommands' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListCommands)

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

instance Prelude.NFData ListCommands

instance Core.ToHeaders ListCommands where
  toHeaders :: ListCommands -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListCommands -> 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.ListCommands" :: 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 ListCommands where
  toJSON :: ListCommands -> Value
toJSON ListCommands' {Maybe Natural
Maybe (NonEmpty CommandFilter)
Maybe Text
maxResults :: Maybe Natural
commandId :: Maybe Text
nextToken :: Maybe Text
filters :: Maybe (NonEmpty CommandFilter)
instanceId :: Maybe Text
$sel:maxResults:ListCommands' :: ListCommands -> Maybe Natural
$sel:commandId:ListCommands' :: ListCommands -> Maybe Text
$sel:nextToken:ListCommands' :: ListCommands -> Maybe Text
$sel:filters:ListCommands' :: ListCommands -> Maybe (NonEmpty CommandFilter)
$sel:instanceId:ListCommands' :: ListCommands -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InstanceId" 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
instanceId,
            (Text
"Filters" Text -> NonEmpty CommandFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty CommandFilter -> Pair)
-> Maybe (NonEmpty CommandFilter) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty CommandFilter)
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
"CommandId" 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
commandId,
            (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 ListCommands where
  toPath :: ListCommands -> ByteString
toPath = ByteString -> ListCommands -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListCommandsResponse' smart constructor.
data ListCommandsResponse = ListCommandsResponse'
  { -- | (Optional) The list of commands requested by the user.
    ListCommandsResponse -> Maybe [Command]
commands :: Prelude.Maybe [Command],
    -- | (Optional) The token for the next set of items to return. (You received
    -- this token from a previous call.)
    ListCommandsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListCommandsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListCommandsResponse -> ListCommandsResponse -> Bool
(ListCommandsResponse -> ListCommandsResponse -> Bool)
-> (ListCommandsResponse -> ListCommandsResponse -> Bool)
-> Eq ListCommandsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCommandsResponse -> ListCommandsResponse -> Bool
$c/= :: ListCommandsResponse -> ListCommandsResponse -> Bool
== :: ListCommandsResponse -> ListCommandsResponse -> Bool
$c== :: ListCommandsResponse -> ListCommandsResponse -> Bool
Prelude.Eq, ReadPrec [ListCommandsResponse]
ReadPrec ListCommandsResponse
Int -> ReadS ListCommandsResponse
ReadS [ListCommandsResponse]
(Int -> ReadS ListCommandsResponse)
-> ReadS [ListCommandsResponse]
-> ReadPrec ListCommandsResponse
-> ReadPrec [ListCommandsResponse]
-> Read ListCommandsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCommandsResponse]
$creadListPrec :: ReadPrec [ListCommandsResponse]
readPrec :: ReadPrec ListCommandsResponse
$creadPrec :: ReadPrec ListCommandsResponse
readList :: ReadS [ListCommandsResponse]
$creadList :: ReadS [ListCommandsResponse]
readsPrec :: Int -> ReadS ListCommandsResponse
$creadsPrec :: Int -> ReadS ListCommandsResponse
Prelude.Read, Int -> ListCommandsResponse -> ShowS
[ListCommandsResponse] -> ShowS
ListCommandsResponse -> String
(Int -> ListCommandsResponse -> ShowS)
-> (ListCommandsResponse -> String)
-> ([ListCommandsResponse] -> ShowS)
-> Show ListCommandsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCommandsResponse] -> ShowS
$cshowList :: [ListCommandsResponse] -> ShowS
show :: ListCommandsResponse -> String
$cshow :: ListCommandsResponse -> String
showsPrec :: Int -> ListCommandsResponse -> ShowS
$cshowsPrec :: Int -> ListCommandsResponse -> ShowS
Prelude.Show, (forall x. ListCommandsResponse -> Rep ListCommandsResponse x)
-> (forall x. Rep ListCommandsResponse x -> ListCommandsResponse)
-> Generic ListCommandsResponse
forall x. Rep ListCommandsResponse x -> ListCommandsResponse
forall x. ListCommandsResponse -> Rep ListCommandsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCommandsResponse x -> ListCommandsResponse
$cfrom :: forall x. ListCommandsResponse -> Rep ListCommandsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListCommandsResponse' 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:
--
-- 'commands', 'listCommandsResponse_commands' - (Optional) The list of commands requested by the user.
--
-- 'nextToken', 'listCommandsResponse_nextToken' - (Optional) The token for the next set of items to return. (You received
-- this token from a previous call.)
--
-- 'httpStatus', 'listCommandsResponse_httpStatus' - The response's http status code.
newListCommandsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListCommandsResponse
newListCommandsResponse :: Int -> ListCommandsResponse
newListCommandsResponse Int
pHttpStatus_ =
  ListCommandsResponse' :: Maybe [Command] -> Maybe Text -> Int -> ListCommandsResponse
ListCommandsResponse'
    { $sel:commands:ListCommandsResponse' :: Maybe [Command]
commands = Maybe [Command]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCommandsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListCommandsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | (Optional) The list of commands requested by the user.
listCommandsResponse_commands :: Lens.Lens' ListCommandsResponse (Prelude.Maybe [Command])
listCommandsResponse_commands :: (Maybe [Command] -> f (Maybe [Command]))
-> ListCommandsResponse -> f ListCommandsResponse
listCommandsResponse_commands = (ListCommandsResponse -> Maybe [Command])
-> (ListCommandsResponse
    -> Maybe [Command] -> ListCommandsResponse)
-> Lens' ListCommandsResponse (Maybe [Command])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommandsResponse' {Maybe [Command]
commands :: Maybe [Command]
$sel:commands:ListCommandsResponse' :: ListCommandsResponse -> Maybe [Command]
commands} -> Maybe [Command]
commands) (\s :: ListCommandsResponse
s@ListCommandsResponse' {} Maybe [Command]
a -> ListCommandsResponse
s {$sel:commands:ListCommandsResponse' :: Maybe [Command]
commands = Maybe [Command]
a} :: ListCommandsResponse) ((Maybe [Command] -> f (Maybe [Command]))
 -> ListCommandsResponse -> f ListCommandsResponse)
-> ((Maybe [Command] -> f (Maybe [Command]))
    -> Maybe [Command] -> f (Maybe [Command]))
-> (Maybe [Command] -> f (Maybe [Command]))
-> ListCommandsResponse
-> f ListCommandsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Command] [Command] [Command] [Command]
-> Iso
     (Maybe [Command])
     (Maybe [Command])
     (Maybe [Command])
     (Maybe [Command])
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 [Command] [Command] [Command] [Command]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.NFData ListCommandsResponse