{-# 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.ECS.ListTasks
-- 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 a list of tasks. You can filter the results by cluster, task
-- definition family, container instance, launch type, what IAM principal
-- started the task, or by the desired status of the task.
--
-- Recently stopped tasks might appear in the returned results. Currently,
-- stopped tasks appear in the returned results for at least one hour.
--
-- This operation returns paginated results.
module Amazonka.ECS.ListTasks
  ( -- * Creating a Request
    ListTasks (..),
    newListTasks,

    -- * Request Lenses
    listTasks_desiredStatus,
    listTasks_cluster,
    listTasks_family,
    listTasks_nextToken,
    listTasks_startedBy,
    listTasks_serviceName,
    listTasks_launchType,
    listTasks_containerInstance,
    listTasks_maxResults,

    -- * Destructuring the Response
    ListTasksResponse (..),
    newListTasksResponse,

    -- * Response Lenses
    listTasksResponse_nextToken,
    listTasksResponse_taskArns,
    listTasksResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListTasks' smart constructor.
data ListTasks = ListTasks'
  { -- | The task desired status to use when filtering the @ListTasks@ results.
    -- Specifying a @desiredStatus@ of @STOPPED@ limits the results to tasks
    -- that Amazon ECS has set the desired status to @STOPPED@. This can be
    -- useful for debugging tasks that are not starting properly or have died
    -- or finished. The default status filter is @RUNNING@, which shows tasks
    -- that Amazon ECS has set the desired status to @RUNNING@.
    --
    -- Although you can filter results based on a desired status of @PENDING@,
    -- this does not return any results. Amazon ECS never sets the desired
    -- status of a task to that value (only a task\'s @lastStatus@ may have a
    -- value of @PENDING@).
    ListTasks -> Maybe DesiredStatus
desiredStatus :: Prelude.Maybe DesiredStatus,
    -- | The short name or full Amazon Resource Name (ARN) of the cluster to use
    -- when filtering the @ListTasks@ results. If you do not specify a cluster,
    -- the default cluster is assumed.
    ListTasks -> Maybe Text
cluster :: Prelude.Maybe Prelude.Text,
    -- | The name of the task definition family to use when filtering the
    -- @ListTasks@ results. Specifying a @family@ limits the results to tasks
    -- that belong to that family.
    ListTasks -> Maybe Text
family :: Prelude.Maybe Prelude.Text,
    -- | The @nextToken@ value returned from a @ListTasks@ request indicating
    -- that more results are available to fulfill the request and further calls
    -- will be needed. If @maxResults@ was provided, it is possible the number
    -- of results to be fewer than @maxResults@.
    --
    -- This token should be treated as an opaque identifier that is only used
    -- to retrieve the next items in a list and not for other programmatic
    -- purposes.
    ListTasks -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The @startedBy@ value with which to filter the task results. Specifying
    -- a @startedBy@ value limits the results to tasks that were started with
    -- that value.
    ListTasks -> Maybe Text
startedBy :: Prelude.Maybe Prelude.Text,
    -- | The name of the service to use when filtering the @ListTasks@ results.
    -- Specifying a @serviceName@ limits the results to tasks that belong to
    -- that service.
    ListTasks -> Maybe Text
serviceName :: Prelude.Maybe Prelude.Text,
    -- | The launch type to use when filtering the @ListTasks@ results.
    ListTasks -> Maybe LaunchType
launchType :: Prelude.Maybe LaunchType,
    -- | The container instance ID or full ARN of the container instance to use
    -- when filtering the @ListTasks@ results. Specifying a @containerInstance@
    -- limits the results to tasks that belong to that container instance.
    ListTasks -> Maybe Text
containerInstance :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of task results returned by @ListTasks@ in paginated
    -- output. When this parameter is used, @ListTasks@ only returns
    -- @maxResults@ results in a single page along with a @nextToken@ response
    -- element. The remaining results of the initial request can be seen by
    -- sending another @ListTasks@ request with the returned @nextToken@ value.
    -- This value can be between 1 and 100. If this parameter is not used, then
    -- @ListTasks@ returns up to 100 results and a @nextToken@ value if
    -- applicable.
    ListTasks -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int
  }
  deriving (ListTasks -> ListTasks -> Bool
(ListTasks -> ListTasks -> Bool)
-> (ListTasks -> ListTasks -> Bool) -> Eq ListTasks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTasks -> ListTasks -> Bool
$c/= :: ListTasks -> ListTasks -> Bool
== :: ListTasks -> ListTasks -> Bool
$c== :: ListTasks -> ListTasks -> Bool
Prelude.Eq, ReadPrec [ListTasks]
ReadPrec ListTasks
Int -> ReadS ListTasks
ReadS [ListTasks]
(Int -> ReadS ListTasks)
-> ReadS [ListTasks]
-> ReadPrec ListTasks
-> ReadPrec [ListTasks]
-> Read ListTasks
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTasks]
$creadListPrec :: ReadPrec [ListTasks]
readPrec :: ReadPrec ListTasks
$creadPrec :: ReadPrec ListTasks
readList :: ReadS [ListTasks]
$creadList :: ReadS [ListTasks]
readsPrec :: Int -> ReadS ListTasks
$creadsPrec :: Int -> ReadS ListTasks
Prelude.Read, Int -> ListTasks -> ShowS
[ListTasks] -> ShowS
ListTasks -> String
(Int -> ListTasks -> ShowS)
-> (ListTasks -> String)
-> ([ListTasks] -> ShowS)
-> Show ListTasks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTasks] -> ShowS
$cshowList :: [ListTasks] -> ShowS
show :: ListTasks -> String
$cshow :: ListTasks -> String
showsPrec :: Int -> ListTasks -> ShowS
$cshowsPrec :: Int -> ListTasks -> ShowS
Prelude.Show, (forall x. ListTasks -> Rep ListTasks x)
-> (forall x. Rep ListTasks x -> ListTasks) -> Generic ListTasks
forall x. Rep ListTasks x -> ListTasks
forall x. ListTasks -> Rep ListTasks x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTasks x -> ListTasks
$cfrom :: forall x. ListTasks -> Rep ListTasks x
Prelude.Generic)

-- |
-- Create a value of 'ListTasks' 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:
--
-- 'desiredStatus', 'listTasks_desiredStatus' - The task desired status to use when filtering the @ListTasks@ results.
-- Specifying a @desiredStatus@ of @STOPPED@ limits the results to tasks
-- that Amazon ECS has set the desired status to @STOPPED@. This can be
-- useful for debugging tasks that are not starting properly or have died
-- or finished. The default status filter is @RUNNING@, which shows tasks
-- that Amazon ECS has set the desired status to @RUNNING@.
--
-- Although you can filter results based on a desired status of @PENDING@,
-- this does not return any results. Amazon ECS never sets the desired
-- status of a task to that value (only a task\'s @lastStatus@ may have a
-- value of @PENDING@).
--
-- 'cluster', 'listTasks_cluster' - The short name or full Amazon Resource Name (ARN) of the cluster to use
-- when filtering the @ListTasks@ results. If you do not specify a cluster,
-- the default cluster is assumed.
--
-- 'family', 'listTasks_family' - The name of the task definition family to use when filtering the
-- @ListTasks@ results. Specifying a @family@ limits the results to tasks
-- that belong to that family.
--
-- 'nextToken', 'listTasks_nextToken' - The @nextToken@ value returned from a @ListTasks@ request indicating
-- that more results are available to fulfill the request and further calls
-- will be needed. If @maxResults@ was provided, it is possible the number
-- of results to be fewer than @maxResults@.
--
-- This token should be treated as an opaque identifier that is only used
-- to retrieve the next items in a list and not for other programmatic
-- purposes.
--
-- 'startedBy', 'listTasks_startedBy' - The @startedBy@ value with which to filter the task results. Specifying
-- a @startedBy@ value limits the results to tasks that were started with
-- that value.
--
-- 'serviceName', 'listTasks_serviceName' - The name of the service to use when filtering the @ListTasks@ results.
-- Specifying a @serviceName@ limits the results to tasks that belong to
-- that service.
--
-- 'launchType', 'listTasks_launchType' - The launch type to use when filtering the @ListTasks@ results.
--
-- 'containerInstance', 'listTasks_containerInstance' - The container instance ID or full ARN of the container instance to use
-- when filtering the @ListTasks@ results. Specifying a @containerInstance@
-- limits the results to tasks that belong to that container instance.
--
-- 'maxResults', 'listTasks_maxResults' - The maximum number of task results returned by @ListTasks@ in paginated
-- output. When this parameter is used, @ListTasks@ only returns
-- @maxResults@ results in a single page along with a @nextToken@ response
-- element. The remaining results of the initial request can be seen by
-- sending another @ListTasks@ request with the returned @nextToken@ value.
-- This value can be between 1 and 100. If this parameter is not used, then
-- @ListTasks@ returns up to 100 results and a @nextToken@ value if
-- applicable.
newListTasks ::
  ListTasks
newListTasks :: ListTasks
newListTasks =
  ListTasks' :: Maybe DesiredStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe LaunchType
-> Maybe Text
-> Maybe Int
-> ListTasks
ListTasks'
    { $sel:desiredStatus:ListTasks' :: Maybe DesiredStatus
desiredStatus = Maybe DesiredStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:cluster:ListTasks' :: Maybe Text
cluster = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:family:ListTasks' :: Maybe Text
family = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListTasks' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:startedBy:ListTasks' :: Maybe Text
startedBy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:ListTasks' :: Maybe Text
serviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:launchType:ListTasks' :: Maybe LaunchType
launchType = Maybe LaunchType
forall a. Maybe a
Prelude.Nothing,
      $sel:containerInstance:ListTasks' :: Maybe Text
containerInstance = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListTasks' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The task desired status to use when filtering the @ListTasks@ results.
-- Specifying a @desiredStatus@ of @STOPPED@ limits the results to tasks
-- that Amazon ECS has set the desired status to @STOPPED@. This can be
-- useful for debugging tasks that are not starting properly or have died
-- or finished. The default status filter is @RUNNING@, which shows tasks
-- that Amazon ECS has set the desired status to @RUNNING@.
--
-- Although you can filter results based on a desired status of @PENDING@,
-- this does not return any results. Amazon ECS never sets the desired
-- status of a task to that value (only a task\'s @lastStatus@ may have a
-- value of @PENDING@).
listTasks_desiredStatus :: Lens.Lens' ListTasks (Prelude.Maybe DesiredStatus)
listTasks_desiredStatus :: (Maybe DesiredStatus -> f (Maybe DesiredStatus))
-> ListTasks -> f ListTasks
listTasks_desiredStatus = (ListTasks -> Maybe DesiredStatus)
-> (ListTasks -> Maybe DesiredStatus -> ListTasks)
-> Lens
     ListTasks ListTasks (Maybe DesiredStatus) (Maybe DesiredStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasks' {Maybe DesiredStatus
desiredStatus :: Maybe DesiredStatus
$sel:desiredStatus:ListTasks' :: ListTasks -> Maybe DesiredStatus
desiredStatus} -> Maybe DesiredStatus
desiredStatus) (\s :: ListTasks
s@ListTasks' {} Maybe DesiredStatus
a -> ListTasks
s {$sel:desiredStatus:ListTasks' :: Maybe DesiredStatus
desiredStatus = Maybe DesiredStatus
a} :: ListTasks)

-- | The short name or full Amazon Resource Name (ARN) of the cluster to use
-- when filtering the @ListTasks@ results. If you do not specify a cluster,
-- the default cluster is assumed.
listTasks_cluster :: Lens.Lens' ListTasks (Prelude.Maybe Prelude.Text)
listTasks_cluster :: (Maybe Text -> f (Maybe Text)) -> ListTasks -> f ListTasks
listTasks_cluster = (ListTasks -> Maybe Text)
-> (ListTasks -> Maybe Text -> ListTasks)
-> Lens ListTasks ListTasks (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasks' {Maybe Text
cluster :: Maybe Text
$sel:cluster:ListTasks' :: ListTasks -> Maybe Text
cluster} -> Maybe Text
cluster) (\s :: ListTasks
s@ListTasks' {} Maybe Text
a -> ListTasks
s {$sel:cluster:ListTasks' :: Maybe Text
cluster = Maybe Text
a} :: ListTasks)

-- | The name of the task definition family to use when filtering the
-- @ListTasks@ results. Specifying a @family@ limits the results to tasks
-- that belong to that family.
listTasks_family :: Lens.Lens' ListTasks (Prelude.Maybe Prelude.Text)
listTasks_family :: (Maybe Text -> f (Maybe Text)) -> ListTasks -> f ListTasks
listTasks_family = (ListTasks -> Maybe Text)
-> (ListTasks -> Maybe Text -> ListTasks)
-> Lens ListTasks ListTasks (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasks' {Maybe Text
family :: Maybe Text
$sel:family:ListTasks' :: ListTasks -> Maybe Text
family} -> Maybe Text
family) (\s :: ListTasks
s@ListTasks' {} Maybe Text
a -> ListTasks
s {$sel:family:ListTasks' :: Maybe Text
family = Maybe Text
a} :: ListTasks)

-- | The @nextToken@ value returned from a @ListTasks@ request indicating
-- that more results are available to fulfill the request and further calls
-- will be needed. If @maxResults@ was provided, it is possible the number
-- of results to be fewer than @maxResults@.
--
-- This token should be treated as an opaque identifier that is only used
-- to retrieve the next items in a list and not for other programmatic
-- purposes.
listTasks_nextToken :: Lens.Lens' ListTasks (Prelude.Maybe Prelude.Text)
listTasks_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListTasks -> f ListTasks
listTasks_nextToken = (ListTasks -> Maybe Text)
-> (ListTasks -> Maybe Text -> ListTasks)
-> Lens ListTasks ListTasks (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasks' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTasks' :: ListTasks -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTasks
s@ListTasks' {} Maybe Text
a -> ListTasks
s {$sel:nextToken:ListTasks' :: Maybe Text
nextToken = Maybe Text
a} :: ListTasks)

-- | The @startedBy@ value with which to filter the task results. Specifying
-- a @startedBy@ value limits the results to tasks that were started with
-- that value.
listTasks_startedBy :: Lens.Lens' ListTasks (Prelude.Maybe Prelude.Text)
listTasks_startedBy :: (Maybe Text -> f (Maybe Text)) -> ListTasks -> f ListTasks
listTasks_startedBy = (ListTasks -> Maybe Text)
-> (ListTasks -> Maybe Text -> ListTasks)
-> Lens ListTasks ListTasks (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasks' {Maybe Text
startedBy :: Maybe Text
$sel:startedBy:ListTasks' :: ListTasks -> Maybe Text
startedBy} -> Maybe Text
startedBy) (\s :: ListTasks
s@ListTasks' {} Maybe Text
a -> ListTasks
s {$sel:startedBy:ListTasks' :: Maybe Text
startedBy = Maybe Text
a} :: ListTasks)

-- | The name of the service to use when filtering the @ListTasks@ results.
-- Specifying a @serviceName@ limits the results to tasks that belong to
-- that service.
listTasks_serviceName :: Lens.Lens' ListTasks (Prelude.Maybe Prelude.Text)
listTasks_serviceName :: (Maybe Text -> f (Maybe Text)) -> ListTasks -> f ListTasks
listTasks_serviceName = (ListTasks -> Maybe Text)
-> (ListTasks -> Maybe Text -> ListTasks)
-> Lens ListTasks ListTasks (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasks' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:ListTasks' :: ListTasks -> Maybe Text
serviceName} -> Maybe Text
serviceName) (\s :: ListTasks
s@ListTasks' {} Maybe Text
a -> ListTasks
s {$sel:serviceName:ListTasks' :: Maybe Text
serviceName = Maybe Text
a} :: ListTasks)

-- | The launch type to use when filtering the @ListTasks@ results.
listTasks_launchType :: Lens.Lens' ListTasks (Prelude.Maybe LaunchType)
listTasks_launchType :: (Maybe LaunchType -> f (Maybe LaunchType))
-> ListTasks -> f ListTasks
listTasks_launchType = (ListTasks -> Maybe LaunchType)
-> (ListTasks -> Maybe LaunchType -> ListTasks)
-> Lens ListTasks ListTasks (Maybe LaunchType) (Maybe LaunchType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasks' {Maybe LaunchType
launchType :: Maybe LaunchType
$sel:launchType:ListTasks' :: ListTasks -> Maybe LaunchType
launchType} -> Maybe LaunchType
launchType) (\s :: ListTasks
s@ListTasks' {} Maybe LaunchType
a -> ListTasks
s {$sel:launchType:ListTasks' :: Maybe LaunchType
launchType = Maybe LaunchType
a} :: ListTasks)

-- | The container instance ID or full ARN of the container instance to use
-- when filtering the @ListTasks@ results. Specifying a @containerInstance@
-- limits the results to tasks that belong to that container instance.
listTasks_containerInstance :: Lens.Lens' ListTasks (Prelude.Maybe Prelude.Text)
listTasks_containerInstance :: (Maybe Text -> f (Maybe Text)) -> ListTasks -> f ListTasks
listTasks_containerInstance = (ListTasks -> Maybe Text)
-> (ListTasks -> Maybe Text -> ListTasks)
-> Lens ListTasks ListTasks (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasks' {Maybe Text
containerInstance :: Maybe Text
$sel:containerInstance:ListTasks' :: ListTasks -> Maybe Text
containerInstance} -> Maybe Text
containerInstance) (\s :: ListTasks
s@ListTasks' {} Maybe Text
a -> ListTasks
s {$sel:containerInstance:ListTasks' :: Maybe Text
containerInstance = Maybe Text
a} :: ListTasks)

-- | The maximum number of task results returned by @ListTasks@ in paginated
-- output. When this parameter is used, @ListTasks@ only returns
-- @maxResults@ results in a single page along with a @nextToken@ response
-- element. The remaining results of the initial request can be seen by
-- sending another @ListTasks@ request with the returned @nextToken@ value.
-- This value can be between 1 and 100. If this parameter is not used, then
-- @ListTasks@ returns up to 100 results and a @nextToken@ value if
-- applicable.
listTasks_maxResults :: Lens.Lens' ListTasks (Prelude.Maybe Prelude.Int)
listTasks_maxResults :: (Maybe Int -> f (Maybe Int)) -> ListTasks -> f ListTasks
listTasks_maxResults = (ListTasks -> Maybe Int)
-> (ListTasks -> Maybe Int -> ListTasks)
-> Lens ListTasks ListTasks (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasks' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:ListTasks' :: ListTasks -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: ListTasks
s@ListTasks' {} Maybe Int
a -> ListTasks
s {$sel:maxResults:ListTasks' :: Maybe Int
maxResults = Maybe Int
a} :: ListTasks)

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

instance Prelude.NFData ListTasks

instance Core.ToHeaders ListTasks where
  toHeaders :: ListTasks -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListTasks -> 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
"AmazonEC2ContainerServiceV20141113.ListTasks" ::
                          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 ListTasks where
  toJSON :: ListTasks -> Value
toJSON ListTasks' {Maybe Int
Maybe Text
Maybe DesiredStatus
Maybe LaunchType
maxResults :: Maybe Int
containerInstance :: Maybe Text
launchType :: Maybe LaunchType
serviceName :: Maybe Text
startedBy :: Maybe Text
nextToken :: Maybe Text
family :: Maybe Text
cluster :: Maybe Text
desiredStatus :: Maybe DesiredStatus
$sel:maxResults:ListTasks' :: ListTasks -> Maybe Int
$sel:containerInstance:ListTasks' :: ListTasks -> Maybe Text
$sel:launchType:ListTasks' :: ListTasks -> Maybe LaunchType
$sel:serviceName:ListTasks' :: ListTasks -> Maybe Text
$sel:startedBy:ListTasks' :: ListTasks -> Maybe Text
$sel:nextToken:ListTasks' :: ListTasks -> Maybe Text
$sel:family:ListTasks' :: ListTasks -> Maybe Text
$sel:cluster:ListTasks' :: ListTasks -> Maybe Text
$sel:desiredStatus:ListTasks' :: ListTasks -> Maybe DesiredStatus
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"desiredStatus" Text -> DesiredStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DesiredStatus -> Pair) -> Maybe DesiredStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DesiredStatus
desiredStatus,
            (Text
"cluster" 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
cluster,
            (Text
"family" 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
family,
            (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
"startedBy" 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
startedBy,
            (Text
"serviceName" 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
serviceName,
            (Text
"launchType" Text -> LaunchType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LaunchType -> Pair) -> Maybe LaunchType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LaunchType
launchType,
            (Text
"containerInstance" 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
containerInstance,
            (Text
"maxResults" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults
          ]
      )

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

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

-- | /See:/ 'newListTasksResponse' smart constructor.
data ListTasksResponse = ListTasksResponse'
  { -- | The @nextToken@ value to include in a future @ListTasks@ request. When
    -- the results of a @ListTasks@ request exceed @maxResults@, this value can
    -- be used to retrieve the next page of results. This value is @null@ when
    -- there are no more results to return.
    ListTasksResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The list of task ARN entries for the @ListTasks@ request.
    ListTasksResponse -> Maybe [Text]
taskArns :: Prelude.Maybe [Prelude.Text],
    -- | The response's http status code.
    ListTasksResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListTasksResponse -> ListTasksResponse -> Bool
(ListTasksResponse -> ListTasksResponse -> Bool)
-> (ListTasksResponse -> ListTasksResponse -> Bool)
-> Eq ListTasksResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTasksResponse -> ListTasksResponse -> Bool
$c/= :: ListTasksResponse -> ListTasksResponse -> Bool
== :: ListTasksResponse -> ListTasksResponse -> Bool
$c== :: ListTasksResponse -> ListTasksResponse -> Bool
Prelude.Eq, ReadPrec [ListTasksResponse]
ReadPrec ListTasksResponse
Int -> ReadS ListTasksResponse
ReadS [ListTasksResponse]
(Int -> ReadS ListTasksResponse)
-> ReadS [ListTasksResponse]
-> ReadPrec ListTasksResponse
-> ReadPrec [ListTasksResponse]
-> Read ListTasksResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTasksResponse]
$creadListPrec :: ReadPrec [ListTasksResponse]
readPrec :: ReadPrec ListTasksResponse
$creadPrec :: ReadPrec ListTasksResponse
readList :: ReadS [ListTasksResponse]
$creadList :: ReadS [ListTasksResponse]
readsPrec :: Int -> ReadS ListTasksResponse
$creadsPrec :: Int -> ReadS ListTasksResponse
Prelude.Read, Int -> ListTasksResponse -> ShowS
[ListTasksResponse] -> ShowS
ListTasksResponse -> String
(Int -> ListTasksResponse -> ShowS)
-> (ListTasksResponse -> String)
-> ([ListTasksResponse] -> ShowS)
-> Show ListTasksResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTasksResponse] -> ShowS
$cshowList :: [ListTasksResponse] -> ShowS
show :: ListTasksResponse -> String
$cshow :: ListTasksResponse -> String
showsPrec :: Int -> ListTasksResponse -> ShowS
$cshowsPrec :: Int -> ListTasksResponse -> ShowS
Prelude.Show, (forall x. ListTasksResponse -> Rep ListTasksResponse x)
-> (forall x. Rep ListTasksResponse x -> ListTasksResponse)
-> Generic ListTasksResponse
forall x. Rep ListTasksResponse x -> ListTasksResponse
forall x. ListTasksResponse -> Rep ListTasksResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTasksResponse x -> ListTasksResponse
$cfrom :: forall x. ListTasksResponse -> Rep ListTasksResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTasksResponse' 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', 'listTasksResponse_nextToken' - The @nextToken@ value to include in a future @ListTasks@ request. When
-- the results of a @ListTasks@ request exceed @maxResults@, this value can
-- be used to retrieve the next page of results. This value is @null@ when
-- there are no more results to return.
--
-- 'taskArns', 'listTasksResponse_taskArns' - The list of task ARN entries for the @ListTasks@ request.
--
-- 'httpStatus', 'listTasksResponse_httpStatus' - The response's http status code.
newListTasksResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTasksResponse
newListTasksResponse :: Int -> ListTasksResponse
newListTasksResponse Int
pHttpStatus_ =
  ListTasksResponse' :: Maybe Text -> Maybe [Text] -> Int -> ListTasksResponse
ListTasksResponse'
    { $sel:nextToken:ListTasksResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:taskArns:ListTasksResponse' :: Maybe [Text]
taskArns = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTasksResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The @nextToken@ value to include in a future @ListTasks@ request. When
-- the results of a @ListTasks@ request exceed @maxResults@, this value can
-- be used to retrieve the next page of results. This value is @null@ when
-- there are no more results to return.
listTasksResponse_nextToken :: Lens.Lens' ListTasksResponse (Prelude.Maybe Prelude.Text)
listTasksResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListTasksResponse -> f ListTasksResponse
listTasksResponse_nextToken = (ListTasksResponse -> Maybe Text)
-> (ListTasksResponse -> Maybe Text -> ListTasksResponse)
-> Lens' ListTasksResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasksResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTasksResponse' :: ListTasksResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTasksResponse
s@ListTasksResponse' {} Maybe Text
a -> ListTasksResponse
s {$sel:nextToken:ListTasksResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTasksResponse)

-- | The list of task ARN entries for the @ListTasks@ request.
listTasksResponse_taskArns :: Lens.Lens' ListTasksResponse (Prelude.Maybe [Prelude.Text])
listTasksResponse_taskArns :: (Maybe [Text] -> f (Maybe [Text]))
-> ListTasksResponse -> f ListTasksResponse
listTasksResponse_taskArns = (ListTasksResponse -> Maybe [Text])
-> (ListTasksResponse -> Maybe [Text] -> ListTasksResponse)
-> Lens' ListTasksResponse (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTasksResponse' {Maybe [Text]
taskArns :: Maybe [Text]
$sel:taskArns:ListTasksResponse' :: ListTasksResponse -> Maybe [Text]
taskArns} -> Maybe [Text]
taskArns) (\s :: ListTasksResponse
s@ListTasksResponse' {} Maybe [Text]
a -> ListTasksResponse
s {$sel:taskArns:ListTasksResponse' :: Maybe [Text]
taskArns = Maybe [Text]
a} :: ListTasksResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListTasksResponse -> f ListTasksResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListTasksResponse
-> f ListTasksResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListTasksResponse