{-# 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.StepFunctions.ListActivities
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the existing activities.
--
-- If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ is a unique pagination token for each page. Make the call
-- again using the returned token to retrieve the next page. Keep all other
-- arguments unchanged. Each pagination token expires after 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
--
-- This operation is eventually consistent. The results are best effort and
-- may not reflect very recent updates and changes.
--
-- This operation returns paginated results.
module Amazonka.StepFunctions.ListActivities
  ( -- * Creating a Request
    ListActivities (..),
    newListActivities,

    -- * Request Lenses
    listActivities_maxResults,
    listActivities_nextToken,

    -- * Destructuring the Response
    ListActivitiesResponse (..),
    newListActivitiesResponse,

    -- * Response Lenses
    listActivitiesResponse_nextToken,
    listActivitiesResponse_httpStatus,
    listActivitiesResponse_activities,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.StepFunctions.Types

-- | /See:/ 'newListActivities' smart constructor.
data ListActivities = ListActivities'
  { -- | The maximum number of results that are returned per call. You can use
    -- @nextToken@ to obtain further pages of results. The default is 100 and
    -- the maximum allowed page size is 1000. A value of 0 uses the default.
    --
    -- This is only an upper limit. The actual number of results returned per
    -- call might be fewer than the specified maximum.
    ListActivities -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | If @nextToken@ is returned, there are more results available. The value
    -- of @nextToken@ is a unique pagination token for each page. Make the call
    -- again using the returned token to retrieve the next page. Keep all other
    -- arguments unchanged. Each pagination token expires after 24 hours. Using
    -- an expired pagination token will return an /HTTP 400 InvalidToken/
    -- error.
    ListActivities -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListActivities -> ListActivities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListActivities -> ListActivities -> Bool
$c/= :: ListActivities -> ListActivities -> Bool
== :: ListActivities -> ListActivities -> Bool
$c== :: ListActivities -> ListActivities -> Bool
Prelude.Eq, ReadPrec [ListActivities]
ReadPrec ListActivities
Int -> ReadS ListActivities
ReadS [ListActivities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListActivities]
$creadListPrec :: ReadPrec [ListActivities]
readPrec :: ReadPrec ListActivities
$creadPrec :: ReadPrec ListActivities
readList :: ReadS [ListActivities]
$creadList :: ReadS [ListActivities]
readsPrec :: Int -> ReadS ListActivities
$creadsPrec :: Int -> ReadS ListActivities
Prelude.Read, Int -> ListActivities -> ShowS
[ListActivities] -> ShowS
ListActivities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListActivities] -> ShowS
$cshowList :: [ListActivities] -> ShowS
show :: ListActivities -> String
$cshow :: ListActivities -> String
showsPrec :: Int -> ListActivities -> ShowS
$cshowsPrec :: Int -> ListActivities -> ShowS
Prelude.Show, forall x. Rep ListActivities x -> ListActivities
forall x. ListActivities -> Rep ListActivities x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListActivities x -> ListActivities
$cfrom :: forall x. ListActivities -> Rep ListActivities x
Prelude.Generic)

-- |
-- Create a value of 'ListActivities' 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:
--
-- 'maxResults', 'listActivities_maxResults' - The maximum number of results that are returned per call. You can use
-- @nextToken@ to obtain further pages of results. The default is 100 and
-- the maximum allowed page size is 1000. A value of 0 uses the default.
--
-- This is only an upper limit. The actual number of results returned per
-- call might be fewer than the specified maximum.
--
-- 'nextToken', 'listActivities_nextToken' - If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ is a unique pagination token for each page. Make the call
-- again using the returned token to retrieve the next page. Keep all other
-- arguments unchanged. Each pagination token expires after 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
newListActivities ::
  ListActivities
newListActivities :: ListActivities
newListActivities =
  ListActivities'
    { $sel:maxResults:ListActivities' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListActivities' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results that are returned per call. You can use
-- @nextToken@ to obtain further pages of results. The default is 100 and
-- the maximum allowed page size is 1000. A value of 0 uses the default.
--
-- This is only an upper limit. The actual number of results returned per
-- call might be fewer than the specified maximum.
listActivities_maxResults :: Lens.Lens' ListActivities (Prelude.Maybe Prelude.Natural)
listActivities_maxResults :: Lens' ListActivities (Maybe Natural)
listActivities_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActivities' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListActivities' :: ListActivities -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListActivities
s@ListActivities' {} Maybe Natural
a -> ListActivities
s {$sel:maxResults:ListActivities' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListActivities)

-- | If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ is a unique pagination token for each page. Make the call
-- again using the returned token to retrieve the next page. Keep all other
-- arguments unchanged. Each pagination token expires after 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
listActivities_nextToken :: Lens.Lens' ListActivities (Prelude.Maybe Prelude.Text)
listActivities_nextToken :: Lens' ListActivities (Maybe Text)
listActivities_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActivities' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListActivities' :: ListActivities -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListActivities
s@ListActivities' {} Maybe Text
a -> ListActivities
s {$sel:nextToken:ListActivities' :: Maybe Text
nextToken = Maybe Text
a} :: ListActivities)

instance Core.AWSPager ListActivities where
  page :: ListActivities
-> AWSResponse ListActivities -> Maybe ListActivities
page ListActivities
rq AWSResponse ListActivities
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListActivities
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListActivitiesResponse (Maybe Text)
listActivitiesResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        (AWSResponse ListActivities
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListActivitiesResponse [ActivityListItem]
listActivitiesResponse_activities) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListActivities
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListActivities (Maybe Text)
listActivities_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListActivities
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListActivitiesResponse (Maybe Text)
listActivitiesResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListActivities where
  type
    AWSResponse ListActivities =
      ListActivitiesResponse
  request :: (Service -> Service) -> ListActivities -> Request ListActivities
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListActivities
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListActivities)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> [ActivityListItem] -> ListActivitiesResponse
ListActivitiesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"activities" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListActivities where
  hashWithSalt :: Int -> ListActivities -> Int
hashWithSalt Int
_salt ListActivities' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListActivities' :: ListActivities -> Maybe Text
$sel:maxResults:ListActivities' :: ListActivities -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListActivities where
  rnf :: ListActivities -> ()
rnf ListActivities' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListActivities' :: ListActivities -> Maybe Text
$sel:maxResults:ListActivities' :: ListActivities -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

instance Data.ToJSON ListActivities where
  toJSON :: ListActivities -> Value
toJSON ListActivities' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListActivities' :: ListActivities -> Maybe Text
$sel:maxResults:ListActivities' :: ListActivities -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"nextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
          ]
      )

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

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

-- | /See:/ 'newListActivitiesResponse' smart constructor.
data ListActivitiesResponse = ListActivitiesResponse'
  { -- | If @nextToken@ is returned, there are more results available. The value
    -- of @nextToken@ is a unique pagination token for each page. Make the call
    -- again using the returned token to retrieve the next page. Keep all other
    -- arguments unchanged. Each pagination token expires after 24 hours. Using
    -- an expired pagination token will return an /HTTP 400 InvalidToken/
    -- error.
    ListActivitiesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListActivitiesResponse -> Int
httpStatus :: Prelude.Int,
    -- | The list of activities.
    ListActivitiesResponse -> [ActivityListItem]
activities :: [ActivityListItem]
  }
  deriving (ListActivitiesResponse -> ListActivitiesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListActivitiesResponse -> ListActivitiesResponse -> Bool
$c/= :: ListActivitiesResponse -> ListActivitiesResponse -> Bool
== :: ListActivitiesResponse -> ListActivitiesResponse -> Bool
$c== :: ListActivitiesResponse -> ListActivitiesResponse -> Bool
Prelude.Eq, ReadPrec [ListActivitiesResponse]
ReadPrec ListActivitiesResponse
Int -> ReadS ListActivitiesResponse
ReadS [ListActivitiesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListActivitiesResponse]
$creadListPrec :: ReadPrec [ListActivitiesResponse]
readPrec :: ReadPrec ListActivitiesResponse
$creadPrec :: ReadPrec ListActivitiesResponse
readList :: ReadS [ListActivitiesResponse]
$creadList :: ReadS [ListActivitiesResponse]
readsPrec :: Int -> ReadS ListActivitiesResponse
$creadsPrec :: Int -> ReadS ListActivitiesResponse
Prelude.Read, Int -> ListActivitiesResponse -> ShowS
[ListActivitiesResponse] -> ShowS
ListActivitiesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListActivitiesResponse] -> ShowS
$cshowList :: [ListActivitiesResponse] -> ShowS
show :: ListActivitiesResponse -> String
$cshow :: ListActivitiesResponse -> String
showsPrec :: Int -> ListActivitiesResponse -> ShowS
$cshowsPrec :: Int -> ListActivitiesResponse -> ShowS
Prelude.Show, forall x. Rep ListActivitiesResponse x -> ListActivitiesResponse
forall x. ListActivitiesResponse -> Rep ListActivitiesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListActivitiesResponse x -> ListActivitiesResponse
$cfrom :: forall x. ListActivitiesResponse -> Rep ListActivitiesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListActivitiesResponse' 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', 'listActivitiesResponse_nextToken' - If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ is a unique pagination token for each page. Make the call
-- again using the returned token to retrieve the next page. Keep all other
-- arguments unchanged. Each pagination token expires after 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
--
-- 'httpStatus', 'listActivitiesResponse_httpStatus' - The response's http status code.
--
-- 'activities', 'listActivitiesResponse_activities' - The list of activities.
newListActivitiesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListActivitiesResponse
newListActivitiesResponse :: Int -> ListActivitiesResponse
newListActivitiesResponse Int
pHttpStatus_ =
  ListActivitiesResponse'
    { $sel:nextToken:ListActivitiesResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListActivitiesResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:activities:ListActivitiesResponse' :: [ActivityListItem]
activities = forall a. Monoid a => a
Prelude.mempty
    }

-- | If @nextToken@ is returned, there are more results available. The value
-- of @nextToken@ is a unique pagination token for each page. Make the call
-- again using the returned token to retrieve the next page. Keep all other
-- arguments unchanged. Each pagination token expires after 24 hours. Using
-- an expired pagination token will return an /HTTP 400 InvalidToken/
-- error.
listActivitiesResponse_nextToken :: Lens.Lens' ListActivitiesResponse (Prelude.Maybe Prelude.Text)
listActivitiesResponse_nextToken :: Lens' ListActivitiesResponse (Maybe Text)
listActivitiesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActivitiesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListActivitiesResponse' :: ListActivitiesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListActivitiesResponse
s@ListActivitiesResponse' {} Maybe Text
a -> ListActivitiesResponse
s {$sel:nextToken:ListActivitiesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListActivitiesResponse)

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

-- | The list of activities.
listActivitiesResponse_activities :: Lens.Lens' ListActivitiesResponse [ActivityListItem]
listActivitiesResponse_activities :: Lens' ListActivitiesResponse [ActivityListItem]
listActivitiesResponse_activities = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActivitiesResponse' {[ActivityListItem]
activities :: [ActivityListItem]
$sel:activities:ListActivitiesResponse' :: ListActivitiesResponse -> [ActivityListItem]
activities} -> [ActivityListItem]
activities) (\s :: ListActivitiesResponse
s@ListActivitiesResponse' {} [ActivityListItem]
a -> ListActivitiesResponse
s {$sel:activities:ListActivitiesResponse' :: [ActivityListItem]
activities = [ActivityListItem]
a} :: ListActivitiesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListActivitiesResponse where
  rnf :: ListActivitiesResponse -> ()
rnf ListActivitiesResponse' {Int
[ActivityListItem]
Maybe Text
activities :: [ActivityListItem]
httpStatus :: Int
nextToken :: Maybe Text
$sel:activities:ListActivitiesResponse' :: ListActivitiesResponse -> [ActivityListItem]
$sel:httpStatus:ListActivitiesResponse' :: ListActivitiesResponse -> Int
$sel:nextToken:ListActivitiesResponse' :: ListActivitiesResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [ActivityListItem]
activities