{-# 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.ListCommandInvocations
-- 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)
--
-- An invocation is copy of a command sent to a specific instance. A
-- command can apply to one or more instances. A command invocation applies
-- to one instance. For example, if a user runs @SendCommand@ against three
-- instances, then a command invocation is created for each requested
-- instance ID. @ListCommandInvocations@ provide status about command
-- execution.
--
-- This operation returns paginated results.
module Amazonka.SSM.ListCommandInvocations
  ( -- * Creating a Request
    ListCommandInvocations (..),
    newListCommandInvocations,

    -- * Request Lenses
    listCommandInvocations_instanceId,
    listCommandInvocations_filters,
    listCommandInvocations_nextToken,
    listCommandInvocations_commandId,
    listCommandInvocations_details,
    listCommandInvocations_maxResults,

    -- * Destructuring the Response
    ListCommandInvocationsResponse (..),
    newListCommandInvocationsResponse,

    -- * Response Lenses
    listCommandInvocationsResponse_nextToken,
    listCommandInvocationsResponse_commandInvocations,
    listCommandInvocationsResponse_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:/ 'newListCommandInvocations' smart constructor.
data ListCommandInvocations = ListCommandInvocations'
  { -- | (Optional) The command execution details for a specific instance ID.
    ListCommandInvocations -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | (Optional) One or more filters. Use a filter to return a more specific
    -- list of results.
    ListCommandInvocations -> 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.)
    ListCommandInvocations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | (Optional) The invocations for a specific command ID.
    ListCommandInvocations -> Maybe Text
commandId :: Prelude.Maybe Prelude.Text,
    -- | (Optional) If set this returns the response of the command executions
    -- and any command output. The default value is @false@.
    ListCommandInvocations -> Maybe Bool
details :: Prelude.Maybe Prelude.Bool,
    -- | (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.
    ListCommandInvocations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListCommandInvocations -> ListCommandInvocations -> Bool
(ListCommandInvocations -> ListCommandInvocations -> Bool)
-> (ListCommandInvocations -> ListCommandInvocations -> Bool)
-> Eq ListCommandInvocations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCommandInvocations -> ListCommandInvocations -> Bool
$c/= :: ListCommandInvocations -> ListCommandInvocations -> Bool
== :: ListCommandInvocations -> ListCommandInvocations -> Bool
$c== :: ListCommandInvocations -> ListCommandInvocations -> Bool
Prelude.Eq, ReadPrec [ListCommandInvocations]
ReadPrec ListCommandInvocations
Int -> ReadS ListCommandInvocations
ReadS [ListCommandInvocations]
(Int -> ReadS ListCommandInvocations)
-> ReadS [ListCommandInvocations]
-> ReadPrec ListCommandInvocations
-> ReadPrec [ListCommandInvocations]
-> Read ListCommandInvocations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCommandInvocations]
$creadListPrec :: ReadPrec [ListCommandInvocations]
readPrec :: ReadPrec ListCommandInvocations
$creadPrec :: ReadPrec ListCommandInvocations
readList :: ReadS [ListCommandInvocations]
$creadList :: ReadS [ListCommandInvocations]
readsPrec :: Int -> ReadS ListCommandInvocations
$creadsPrec :: Int -> ReadS ListCommandInvocations
Prelude.Read, Int -> ListCommandInvocations -> ShowS
[ListCommandInvocations] -> ShowS
ListCommandInvocations -> String
(Int -> ListCommandInvocations -> ShowS)
-> (ListCommandInvocations -> String)
-> ([ListCommandInvocations] -> ShowS)
-> Show ListCommandInvocations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCommandInvocations] -> ShowS
$cshowList :: [ListCommandInvocations] -> ShowS
show :: ListCommandInvocations -> String
$cshow :: ListCommandInvocations -> String
showsPrec :: Int -> ListCommandInvocations -> ShowS
$cshowsPrec :: Int -> ListCommandInvocations -> ShowS
Prelude.Show, (forall x. ListCommandInvocations -> Rep ListCommandInvocations x)
-> (forall x.
    Rep ListCommandInvocations x -> ListCommandInvocations)
-> Generic ListCommandInvocations
forall x. Rep ListCommandInvocations x -> ListCommandInvocations
forall x. ListCommandInvocations -> Rep ListCommandInvocations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCommandInvocations x -> ListCommandInvocations
$cfrom :: forall x. ListCommandInvocations -> Rep ListCommandInvocations x
Prelude.Generic)

-- |
-- Create a value of 'ListCommandInvocations' 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', 'listCommandInvocations_instanceId' - (Optional) The command execution details for a specific instance ID.
--
-- 'filters', 'listCommandInvocations_filters' - (Optional) One or more filters. Use a filter to return a more specific
-- list of results.
--
-- 'nextToken', 'listCommandInvocations_nextToken' - (Optional) The token for the next set of items to return. (You received
-- this token from a previous call.)
--
-- 'commandId', 'listCommandInvocations_commandId' - (Optional) The invocations for a specific command ID.
--
-- 'details', 'listCommandInvocations_details' - (Optional) If set this returns the response of the command executions
-- and any command output. The default value is @false@.
--
-- 'maxResults', 'listCommandInvocations_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.
newListCommandInvocations ::
  ListCommandInvocations
newListCommandInvocations :: ListCommandInvocations
newListCommandInvocations =
  ListCommandInvocations' :: Maybe Text
-> Maybe (NonEmpty CommandFilter)
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Natural
-> ListCommandInvocations
ListCommandInvocations'
    { $sel:instanceId:ListCommandInvocations' :: Maybe Text
instanceId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:ListCommandInvocations' :: Maybe (NonEmpty CommandFilter)
filters = Maybe (NonEmpty CommandFilter)
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCommandInvocations' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:commandId:ListCommandInvocations' :: Maybe Text
commandId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:details:ListCommandInvocations' :: Maybe Bool
details = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListCommandInvocations' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | (Optional) The command execution details for a specific instance ID.
listCommandInvocations_instanceId :: Lens.Lens' ListCommandInvocations (Prelude.Maybe Prelude.Text)
listCommandInvocations_instanceId :: (Maybe Text -> f (Maybe Text))
-> ListCommandInvocations -> f ListCommandInvocations
listCommandInvocations_instanceId = (ListCommandInvocations -> Maybe Text)
-> (ListCommandInvocations -> Maybe Text -> ListCommandInvocations)
-> Lens
     ListCommandInvocations
     ListCommandInvocations
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommandInvocations' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:ListCommandInvocations' :: ListCommandInvocations -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: ListCommandInvocations
s@ListCommandInvocations' {} Maybe Text
a -> ListCommandInvocations
s {$sel:instanceId:ListCommandInvocations' :: Maybe Text
instanceId = Maybe Text
a} :: ListCommandInvocations)

-- | (Optional) One or more filters. Use a filter to return a more specific
-- list of results.
listCommandInvocations_filters :: Lens.Lens' ListCommandInvocations (Prelude.Maybe (Prelude.NonEmpty CommandFilter))
listCommandInvocations_filters :: (Maybe (NonEmpty CommandFilter)
 -> f (Maybe (NonEmpty CommandFilter)))
-> ListCommandInvocations -> f ListCommandInvocations
listCommandInvocations_filters = (ListCommandInvocations -> Maybe (NonEmpty CommandFilter))
-> (ListCommandInvocations
    -> Maybe (NonEmpty CommandFilter) -> ListCommandInvocations)
-> Lens
     ListCommandInvocations
     ListCommandInvocations
     (Maybe (NonEmpty CommandFilter))
     (Maybe (NonEmpty CommandFilter))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommandInvocations' {Maybe (NonEmpty CommandFilter)
filters :: Maybe (NonEmpty CommandFilter)
$sel:filters:ListCommandInvocations' :: ListCommandInvocations -> Maybe (NonEmpty CommandFilter)
filters} -> Maybe (NonEmpty CommandFilter)
filters) (\s :: ListCommandInvocations
s@ListCommandInvocations' {} Maybe (NonEmpty CommandFilter)
a -> ListCommandInvocations
s {$sel:filters:ListCommandInvocations' :: Maybe (NonEmpty CommandFilter)
filters = Maybe (NonEmpty CommandFilter)
a} :: ListCommandInvocations) ((Maybe (NonEmpty CommandFilter)
  -> f (Maybe (NonEmpty CommandFilter)))
 -> ListCommandInvocations -> f ListCommandInvocations)
-> ((Maybe (NonEmpty CommandFilter)
     -> f (Maybe (NonEmpty CommandFilter)))
    -> Maybe (NonEmpty CommandFilter)
    -> f (Maybe (NonEmpty CommandFilter)))
-> (Maybe (NonEmpty CommandFilter)
    -> f (Maybe (NonEmpty CommandFilter)))
-> ListCommandInvocations
-> f ListCommandInvocations
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.)
listCommandInvocations_nextToken :: Lens.Lens' ListCommandInvocations (Prelude.Maybe Prelude.Text)
listCommandInvocations_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListCommandInvocations -> f ListCommandInvocations
listCommandInvocations_nextToken = (ListCommandInvocations -> Maybe Text)
-> (ListCommandInvocations -> Maybe Text -> ListCommandInvocations)
-> Lens
     ListCommandInvocations
     ListCommandInvocations
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommandInvocations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCommandInvocations' :: ListCommandInvocations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCommandInvocations
s@ListCommandInvocations' {} Maybe Text
a -> ListCommandInvocations
s {$sel:nextToken:ListCommandInvocations' :: Maybe Text
nextToken = Maybe Text
a} :: ListCommandInvocations)

-- | (Optional) The invocations for a specific command ID.
listCommandInvocations_commandId :: Lens.Lens' ListCommandInvocations (Prelude.Maybe Prelude.Text)
listCommandInvocations_commandId :: (Maybe Text -> f (Maybe Text))
-> ListCommandInvocations -> f ListCommandInvocations
listCommandInvocations_commandId = (ListCommandInvocations -> Maybe Text)
-> (ListCommandInvocations -> Maybe Text -> ListCommandInvocations)
-> Lens
     ListCommandInvocations
     ListCommandInvocations
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommandInvocations' {Maybe Text
commandId :: Maybe Text
$sel:commandId:ListCommandInvocations' :: ListCommandInvocations -> Maybe Text
commandId} -> Maybe Text
commandId) (\s :: ListCommandInvocations
s@ListCommandInvocations' {} Maybe Text
a -> ListCommandInvocations
s {$sel:commandId:ListCommandInvocations' :: Maybe Text
commandId = Maybe Text
a} :: ListCommandInvocations)

-- | (Optional) If set this returns the response of the command executions
-- and any command output. The default value is @false@.
listCommandInvocations_details :: Lens.Lens' ListCommandInvocations (Prelude.Maybe Prelude.Bool)
listCommandInvocations_details :: (Maybe Bool -> f (Maybe Bool))
-> ListCommandInvocations -> f ListCommandInvocations
listCommandInvocations_details = (ListCommandInvocations -> Maybe Bool)
-> (ListCommandInvocations -> Maybe Bool -> ListCommandInvocations)
-> Lens
     ListCommandInvocations
     ListCommandInvocations
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommandInvocations' {Maybe Bool
details :: Maybe Bool
$sel:details:ListCommandInvocations' :: ListCommandInvocations -> Maybe Bool
details} -> Maybe Bool
details) (\s :: ListCommandInvocations
s@ListCommandInvocations' {} Maybe Bool
a -> ListCommandInvocations
s {$sel:details:ListCommandInvocations' :: Maybe Bool
details = Maybe Bool
a} :: ListCommandInvocations)

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

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

instance Prelude.NFData ListCommandInvocations

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

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

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

-- |
-- Create a value of 'ListCommandInvocationsResponse' 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:
--
-- 'nextToken', 'listCommandInvocationsResponse_nextToken' - (Optional) The token for the next set of items to return. (You received
-- this token from a previous call.)
--
-- 'commandInvocations', 'listCommandInvocationsResponse_commandInvocations' - (Optional) A list of all invocations.
--
-- 'httpStatus', 'listCommandInvocationsResponse_httpStatus' - The response's http status code.
newListCommandInvocationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListCommandInvocationsResponse
newListCommandInvocationsResponse :: Int -> ListCommandInvocationsResponse
newListCommandInvocationsResponse Int
pHttpStatus_ =
  ListCommandInvocationsResponse' :: Maybe Text
-> Maybe [CommandInvocation]
-> Int
-> ListCommandInvocationsResponse
ListCommandInvocationsResponse'
    { $sel:nextToken:ListCommandInvocationsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:commandInvocations:ListCommandInvocationsResponse' :: Maybe [CommandInvocation]
commandInvocations = Maybe [CommandInvocation]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListCommandInvocationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | (Optional) A list of all invocations.
listCommandInvocationsResponse_commandInvocations :: Lens.Lens' ListCommandInvocationsResponse (Prelude.Maybe [CommandInvocation])
listCommandInvocationsResponse_commandInvocations :: (Maybe [CommandInvocation] -> f (Maybe [CommandInvocation]))
-> ListCommandInvocationsResponse
-> f ListCommandInvocationsResponse
listCommandInvocationsResponse_commandInvocations = (ListCommandInvocationsResponse -> Maybe [CommandInvocation])
-> (ListCommandInvocationsResponse
    -> Maybe [CommandInvocation] -> ListCommandInvocationsResponse)
-> Lens' ListCommandInvocationsResponse (Maybe [CommandInvocation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCommandInvocationsResponse' {Maybe [CommandInvocation]
commandInvocations :: Maybe [CommandInvocation]
$sel:commandInvocations:ListCommandInvocationsResponse' :: ListCommandInvocationsResponse -> Maybe [CommandInvocation]
commandInvocations} -> Maybe [CommandInvocation]
commandInvocations) (\s :: ListCommandInvocationsResponse
s@ListCommandInvocationsResponse' {} Maybe [CommandInvocation]
a -> ListCommandInvocationsResponse
s {$sel:commandInvocations:ListCommandInvocationsResponse' :: Maybe [CommandInvocation]
commandInvocations = Maybe [CommandInvocation]
a} :: ListCommandInvocationsResponse) ((Maybe [CommandInvocation] -> f (Maybe [CommandInvocation]))
 -> ListCommandInvocationsResponse
 -> f ListCommandInvocationsResponse)
-> ((Maybe [CommandInvocation] -> f (Maybe [CommandInvocation]))
    -> Maybe [CommandInvocation] -> f (Maybe [CommandInvocation]))
-> (Maybe [CommandInvocation] -> f (Maybe [CommandInvocation]))
-> ListCommandInvocationsResponse
-> f ListCommandInvocationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CommandInvocation]
  [CommandInvocation]
  [CommandInvocation]
  [CommandInvocation]
-> Iso
     (Maybe [CommandInvocation])
     (Maybe [CommandInvocation])
     (Maybe [CommandInvocation])
     (Maybe [CommandInvocation])
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
  [CommandInvocation]
  [CommandInvocation]
  [CommandInvocation]
  [CommandInvocation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    ListCommandInvocationsResponse