{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the available AWS FIS actions.
module Amazonka.FIS.ListActions
  ( -- * Creating a Request
    ListActions (..),
    newListActions,

    -- * Request Lenses
    listActions_nextToken,
    listActions_maxResults,

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

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

import qualified Amazonka.Core as Core
import Amazonka.FIS.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:/ 'newListActions' smart constructor.
data ListActions = ListActions'
  { -- | The token for the next page of results.
    ListActions -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (ListActions -> ListActions -> Bool
(ListActions -> ListActions -> Bool)
-> (ListActions -> ListActions -> Bool) -> Eq ListActions
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]
(Int -> ReadS ListActions)
-> ReadS [ListActions]
-> ReadPrec ListActions
-> ReadPrec [ListActions]
-> Read 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
(Int -> ListActions -> ShowS)
-> (ListActions -> String)
-> ([ListActions] -> ShowS)
-> Show ListActions
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. ListActions -> Rep ListActions x)
-> (forall x. Rep ListActions x -> ListActions)
-> Generic ListActions
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:
--
-- 'nextToken', 'listActions_nextToken' - The token for the next page of results.
--
-- '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.
newListActions ::
  ListActions
newListActions :: ListActions
newListActions =
  ListActions' :: Maybe Text -> Maybe Natural -> ListActions
ListActions'
    { $sel:nextToken:ListActions' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListActions' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The token for the next page of results.
listActions_nextToken :: Lens.Lens' ListActions (Prelude.Maybe Prelude.Text)
listActions_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListActions -> f ListActions
listActions_nextToken = (ListActions -> Maybe Text)
-> (ListActions -> Maybe Text -> ListActions)
-> Lens ListActions ListActions (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> ListActions -> f ListActions
listActions_maxResults = (ListActions -> Maybe Natural)
-> (ListActions -> Maybe Natural -> ListActions)
-> Lens ListActions ListActions (Maybe Natural) (Maybe Natural)
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)

instance Core.AWSRequest ListActions where
  type AWSResponse ListActions = ListActionsResponse
  request :: ListActions -> Request ListActions
request = Service -> ListActions -> Request ListActions
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListActions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListActions)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListActions))
-> Logger
-> Service
-> Proxy ListActions
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListActions)))
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 [ActionSummary] -> Maybe Text -> Int -> ListActionsResponse
ListActionsResponse'
            (Maybe [ActionSummary] -> Maybe Text -> Int -> ListActionsResponse)
-> Either String (Maybe [ActionSummary])
-> Either String (Maybe Text -> Int -> ListActionsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [ActionSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"actions" Either String (Maybe (Maybe [ActionSummary]))
-> Maybe [ActionSummary] -> Either String (Maybe [ActionSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ActionSummary]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> ListActionsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListActionsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either String (Int -> ListActionsResponse)
-> Either String Int -> Either String ListActionsResponse
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 ListActions

instance Prelude.NFData ListActions

instance Core.ToHeaders ListActions where
  toHeaders :: ListActions -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListActions -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath ListActions where
  toPath :: ListActions -> ByteString
toPath = ByteString -> ListActions -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/actions"

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

-- | /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
(ListActionsResponse -> ListActionsResponse -> Bool)
-> (ListActionsResponse -> ListActionsResponse -> Bool)
-> Eq ListActionsResponse
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]
(Int -> ReadS ListActionsResponse)
-> ReadS [ListActionsResponse]
-> ReadPrec ListActionsResponse
-> ReadPrec [ListActionsResponse]
-> Read 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
(Int -> ListActionsResponse -> ShowS)
-> (ListActionsResponse -> String)
-> ([ListActionsResponse] -> ShowS)
-> Show ListActionsResponse
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. ListActionsResponse -> Rep ListActionsResponse x)
-> (forall x. Rep ListActionsResponse x -> ListActionsResponse)
-> Generic ListActionsResponse
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' :: Maybe [ActionSummary] -> Maybe Text -> Int -> ListActionsResponse
ListActionsResponse'
    { $sel:actions:ListActionsResponse' :: Maybe [ActionSummary]
actions = Maybe [ActionSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListActionsResponse' :: Maybe Text
nextToken = Maybe Text
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 :: (Maybe [ActionSummary] -> f (Maybe [ActionSummary]))
-> ListActionsResponse -> f ListActionsResponse
listActionsResponse_actions = (ListActionsResponse -> Maybe [ActionSummary])
-> (ListActionsResponse
    -> Maybe [ActionSummary] -> ListActionsResponse)
-> Lens
     ListActionsResponse
     ListActionsResponse
     (Maybe [ActionSummary])
     (Maybe [ActionSummary])
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) ((Maybe [ActionSummary] -> f (Maybe [ActionSummary]))
 -> ListActionsResponse -> f ListActionsResponse)
-> ((Maybe [ActionSummary] -> f (Maybe [ActionSummary]))
    -> Maybe [ActionSummary] -> f (Maybe [ActionSummary]))
-> (Maybe [ActionSummary] -> f (Maybe [ActionSummary]))
-> ListActionsResponse
-> f ListActionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ActionSummary] [ActionSummary] [ActionSummary] [ActionSummary]
-> Iso
     (Maybe [ActionSummary])
     (Maybe [ActionSummary])
     (Maybe [ActionSummary])
     (Maybe [ActionSummary])
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
  [ActionSummary] [ActionSummary] [ActionSummary] [ActionSummary]
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 :: (Maybe Text -> f (Maybe Text))
-> ListActionsResponse -> f ListActionsResponse
listActionsResponse_nextToken = (ListActionsResponse -> Maybe Text)
-> (ListActionsResponse -> Maybe Text -> ListActionsResponse)
-> Lens
     ListActionsResponse ListActionsResponse (Maybe Text) (Maybe Text)
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 :: (Int -> f Int) -> ListActionsResponse -> f ListActionsResponse
listActionsResponse_httpStatus = (ListActionsResponse -> Int)
-> (ListActionsResponse -> Int -> ListActionsResponse)
-> Lens ListActionsResponse ListActionsResponse Int Int
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