{-# 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.FIS.ListActions
-- 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 available FIS actions.
module Amazonka.FIS.ListActions
  ( -- * Creating a Request
    ListActions (..),
    newListActions,

    -- * Request Lenses
    listActions_maxResults,
    listActions_nextToken,

    -- * Destructuring the Response
    ListActionsResponse (..),
    newListActionsResponse,

    -- * Response Lenses
    listActionsResponse_actions,
    listActionsResponse_nextToken,
    listActionsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListActions' smart constructor.
data ListActions = ListActions'
  { -- | The maximum number of results to return with a single call. To retrieve
    -- the remaining results, make another call with the returned @nextToken@
    -- value.
    ListActions -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token for the next page of results.
    ListActions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListActions -> ListActions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListActions -> ListActions -> Bool
$c/= :: ListActions -> ListActions -> Bool
== :: ListActions -> ListActions -> Bool
$c== :: ListActions -> ListActions -> Bool
Prelude.Eq, ReadPrec [ListActions]
ReadPrec ListActions
Int -> ReadS ListActions
ReadS [ListActions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListActions]
$creadListPrec :: ReadPrec [ListActions]
readPrec :: ReadPrec ListActions
$creadPrec :: ReadPrec ListActions
readList :: ReadS [ListActions]
$creadList :: ReadS [ListActions]
readsPrec :: Int -> ReadS ListActions
$creadsPrec :: Int -> ReadS ListActions
Prelude.Read, Int -> ListActions -> ShowS
[ListActions] -> ShowS
ListActions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListActions] -> ShowS
$cshowList :: [ListActions] -> ShowS
show :: ListActions -> String
$cshow :: ListActions -> String
showsPrec :: Int -> ListActions -> ShowS
$cshowsPrec :: Int -> ListActions -> ShowS
Prelude.Show, forall x. Rep ListActions x -> ListActions
forall x. ListActions -> Rep ListActions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListActions x -> ListActions
$cfrom :: forall x. ListActions -> Rep ListActions x
Prelude.Generic)

-- |
-- Create a value of 'ListActions' 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', 'listActions_maxResults' - The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
--
-- 'nextToken', 'listActions_nextToken' - The token for the next page of results.
newListActions ::
  ListActions
newListActions :: ListActions
newListActions =
  ListActions'
    { $sel:maxResults:ListActions' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListActions' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to return with a single call. To retrieve
-- the remaining results, make another call with the returned @nextToken@
-- value.
listActions_maxResults :: Lens.Lens' ListActions (Prelude.Maybe Prelude.Natural)
listActions_maxResults :: Lens' ListActions (Maybe Natural)
listActions_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActions' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListActions' :: ListActions -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListActions
s@ListActions' {} Maybe Natural
a -> ListActions
s {$sel:maxResults:ListActions' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListActions)

-- | The token for the next page of results.
listActions_nextToken :: Lens.Lens' ListActions (Prelude.Maybe Prelude.Text)
listActions_nextToken :: Lens' ListActions (Maybe Text)
listActions_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActions' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListActions' :: ListActions -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListActions
s@ListActions' {} Maybe Text
a -> ListActions
s {$sel:nextToken:ListActions' :: Maybe Text
nextToken = Maybe Text
a} :: ListActions)

instance Core.AWSRequest ListActions where
  type AWSResponse ListActions = ListActionsResponse
  request :: (Service -> Service) -> ListActions -> Request ListActions
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListActions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListActions)))
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 [ActionSummary] -> Maybe Text -> Int -> ListActionsResponse
ListActionsResponse'
            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
"actions" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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
"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))
      )

instance Prelude.Hashable ListActions where
  hashWithSalt :: Int -> ListActions -> Int
hashWithSalt Int
_salt ListActions' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListActions' :: ListActions -> Maybe Text
$sel:maxResults:ListActions' :: ListActions -> 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 ListActions where
  rnf :: ListActions -> ()
rnf ListActions' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListActions' :: ListActions -> Maybe Text
$sel:maxResults:ListActions' :: ListActions -> 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 ListActions where
  toHeaders :: ListActions -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToQuery ListActions where
  toQuery :: ListActions -> QueryString
toQuery ListActions' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListActions' :: ListActions -> Maybe Text
$sel:maxResults:ListActions' :: ListActions -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListActionsResponse' smart constructor.
data ListActionsResponse = ListActionsResponse'
  { -- | The actions.
    ListActionsResponse -> Maybe [ActionSummary]
actions :: Prelude.Maybe [ActionSummary],
    -- | The token to use to retrieve the next page of results. This value is
    -- @null@ when there are no more results to return.
    ListActionsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListActionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListActionsResponse -> ListActionsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListActionsResponse -> ListActionsResponse -> Bool
$c/= :: ListActionsResponse -> ListActionsResponse -> Bool
== :: ListActionsResponse -> ListActionsResponse -> Bool
$c== :: ListActionsResponse -> ListActionsResponse -> Bool
Prelude.Eq, ReadPrec [ListActionsResponse]
ReadPrec ListActionsResponse
Int -> ReadS ListActionsResponse
ReadS [ListActionsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListActionsResponse]
$creadListPrec :: ReadPrec [ListActionsResponse]
readPrec :: ReadPrec ListActionsResponse
$creadPrec :: ReadPrec ListActionsResponse
readList :: ReadS [ListActionsResponse]
$creadList :: ReadS [ListActionsResponse]
readsPrec :: Int -> ReadS ListActionsResponse
$creadsPrec :: Int -> ReadS ListActionsResponse
Prelude.Read, Int -> ListActionsResponse -> ShowS
[ListActionsResponse] -> ShowS
ListActionsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListActionsResponse] -> ShowS
$cshowList :: [ListActionsResponse] -> ShowS
show :: ListActionsResponse -> String
$cshow :: ListActionsResponse -> String
showsPrec :: Int -> ListActionsResponse -> ShowS
$cshowsPrec :: Int -> ListActionsResponse -> ShowS
Prelude.Show, forall x. Rep ListActionsResponse x -> ListActionsResponse
forall x. ListActionsResponse -> Rep ListActionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListActionsResponse x -> ListActionsResponse
$cfrom :: forall x. ListActionsResponse -> Rep ListActionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListActionsResponse' 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:
--
-- 'actions', 'listActionsResponse_actions' - The actions.
--
-- 'nextToken', 'listActionsResponse_nextToken' - The token to use to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
--
-- 'httpStatus', 'listActionsResponse_httpStatus' - The response's http status code.
newListActionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListActionsResponse
newListActionsResponse :: Int -> ListActionsResponse
newListActionsResponse Int
pHttpStatus_ =
  ListActionsResponse'
    { $sel:actions:ListActionsResponse' :: Maybe [ActionSummary]
actions = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListActionsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListActionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The actions.
listActionsResponse_actions :: Lens.Lens' ListActionsResponse (Prelude.Maybe [ActionSummary])
listActionsResponse_actions :: Lens' ListActionsResponse (Maybe [ActionSummary])
listActionsResponse_actions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActionsResponse' {Maybe [ActionSummary]
actions :: Maybe [ActionSummary]
$sel:actions:ListActionsResponse' :: ListActionsResponse -> Maybe [ActionSummary]
actions} -> Maybe [ActionSummary]
actions) (\s :: ListActionsResponse
s@ListActionsResponse' {} Maybe [ActionSummary]
a -> ListActionsResponse
s {$sel:actions:ListActionsResponse' :: Maybe [ActionSummary]
actions = Maybe [ActionSummary]
a} :: ListActionsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token to use to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
listActionsResponse_nextToken :: Lens.Lens' ListActionsResponse (Prelude.Maybe Prelude.Text)
listActionsResponse_nextToken :: Lens' ListActionsResponse (Maybe Text)
listActionsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListActionsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListActionsResponse' :: ListActionsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListActionsResponse
s@ListActionsResponse' {} Maybe Text
a -> ListActionsResponse
s {$sel:nextToken:ListActionsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListActionsResponse)

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

instance Prelude.NFData ListActionsResponse where
  rnf :: ListActionsResponse -> ()
rnf ListActionsResponse' {Int
Maybe [ActionSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
actions :: Maybe [ActionSummary]
$sel:httpStatus:ListActionsResponse' :: ListActionsResponse -> Int
$sel:nextToken:ListActionsResponse' :: ListActionsResponse -> Maybe Text
$sel:actions:ListActionsResponse' :: ListActionsResponse -> Maybe [ActionSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ActionSummary]
actions
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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