{-# 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.ListExperiments
-- 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 your experiments.
module Amazonka.FIS.ListExperiments
  ( -- * Creating a Request
    ListExperiments (..),
    newListExperiments,

    -- * Request Lenses
    listExperiments_nextToken,
    listExperiments_maxResults,

    -- * Destructuring the Response
    ListExperimentsResponse (..),
    newListExperimentsResponse,

    -- * Response Lenses
    listExperimentsResponse_experiments,
    listExperimentsResponse_nextToken,
    listExperimentsResponse_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:/ 'newListExperiments' smart constructor.
data ListExperiments = ListExperiments'
  { -- | The token for the next page of results.
    ListExperiments -> 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.
    ListExperiments -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListExperiments -> ListExperiments -> Bool
(ListExperiments -> ListExperiments -> Bool)
-> (ListExperiments -> ListExperiments -> Bool)
-> Eq ListExperiments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListExperiments -> ListExperiments -> Bool
$c/= :: ListExperiments -> ListExperiments -> Bool
== :: ListExperiments -> ListExperiments -> Bool
$c== :: ListExperiments -> ListExperiments -> Bool
Prelude.Eq, ReadPrec [ListExperiments]
ReadPrec ListExperiments
Int -> ReadS ListExperiments
ReadS [ListExperiments]
(Int -> ReadS ListExperiments)
-> ReadS [ListExperiments]
-> ReadPrec ListExperiments
-> ReadPrec [ListExperiments]
-> Read ListExperiments
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListExperiments]
$creadListPrec :: ReadPrec [ListExperiments]
readPrec :: ReadPrec ListExperiments
$creadPrec :: ReadPrec ListExperiments
readList :: ReadS [ListExperiments]
$creadList :: ReadS [ListExperiments]
readsPrec :: Int -> ReadS ListExperiments
$creadsPrec :: Int -> ReadS ListExperiments
Prelude.Read, Int -> ListExperiments -> ShowS
[ListExperiments] -> ShowS
ListExperiments -> String
(Int -> ListExperiments -> ShowS)
-> (ListExperiments -> String)
-> ([ListExperiments] -> ShowS)
-> Show ListExperiments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListExperiments] -> ShowS
$cshowList :: [ListExperiments] -> ShowS
show :: ListExperiments -> String
$cshow :: ListExperiments -> String
showsPrec :: Int -> ListExperiments -> ShowS
$cshowsPrec :: Int -> ListExperiments -> ShowS
Prelude.Show, (forall x. ListExperiments -> Rep ListExperiments x)
-> (forall x. Rep ListExperiments x -> ListExperiments)
-> Generic ListExperiments
forall x. Rep ListExperiments x -> ListExperiments
forall x. ListExperiments -> Rep ListExperiments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListExperiments x -> ListExperiments
$cfrom :: forall x. ListExperiments -> Rep ListExperiments x
Prelude.Generic)

-- |
-- Create a value of 'ListExperiments' 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', 'listExperiments_nextToken' - The token for the next page of results.
--
-- 'maxResults', 'listExperiments_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.
newListExperiments ::
  ListExperiments
newListExperiments :: ListExperiments
newListExperiments =
  ListExperiments' :: Maybe Text -> Maybe Natural -> ListExperiments
ListExperiments'
    { $sel:nextToken:ListExperiments' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListExperiments' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.NFData ListExperiments

instance Core.ToHeaders ListExperiments where
  toHeaders :: ListExperiments -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListExperiments -> 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 ListExperiments where
  toPath :: ListExperiments -> ByteString
toPath = ByteString -> ListExperiments -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/experiments"

instance Core.ToQuery ListExperiments where
  toQuery :: ListExperiments -> QueryString
toQuery ListExperiments' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListExperiments' :: ListExperiments -> Maybe Natural
$sel:nextToken:ListExperiments' :: ListExperiments -> 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:/ 'newListExperimentsResponse' smart constructor.
data ListExperimentsResponse = ListExperimentsResponse'
  { -- | The experiments.
    ListExperimentsResponse -> Maybe [ExperimentSummary]
experiments :: Prelude.Maybe [ExperimentSummary],
    -- | The token to use to retrieve the next page of results. This value is
    -- @null@ when there are no more results to return.
    ListExperimentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListExperimentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListExperimentsResponse -> ListExperimentsResponse -> Bool
(ListExperimentsResponse -> ListExperimentsResponse -> Bool)
-> (ListExperimentsResponse -> ListExperimentsResponse -> Bool)
-> Eq ListExperimentsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListExperimentsResponse -> ListExperimentsResponse -> Bool
$c/= :: ListExperimentsResponse -> ListExperimentsResponse -> Bool
== :: ListExperimentsResponse -> ListExperimentsResponse -> Bool
$c== :: ListExperimentsResponse -> ListExperimentsResponse -> Bool
Prelude.Eq, ReadPrec [ListExperimentsResponse]
ReadPrec ListExperimentsResponse
Int -> ReadS ListExperimentsResponse
ReadS [ListExperimentsResponse]
(Int -> ReadS ListExperimentsResponse)
-> ReadS [ListExperimentsResponse]
-> ReadPrec ListExperimentsResponse
-> ReadPrec [ListExperimentsResponse]
-> Read ListExperimentsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListExperimentsResponse]
$creadListPrec :: ReadPrec [ListExperimentsResponse]
readPrec :: ReadPrec ListExperimentsResponse
$creadPrec :: ReadPrec ListExperimentsResponse
readList :: ReadS [ListExperimentsResponse]
$creadList :: ReadS [ListExperimentsResponse]
readsPrec :: Int -> ReadS ListExperimentsResponse
$creadsPrec :: Int -> ReadS ListExperimentsResponse
Prelude.Read, Int -> ListExperimentsResponse -> ShowS
[ListExperimentsResponse] -> ShowS
ListExperimentsResponse -> String
(Int -> ListExperimentsResponse -> ShowS)
-> (ListExperimentsResponse -> String)
-> ([ListExperimentsResponse] -> ShowS)
-> Show ListExperimentsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListExperimentsResponse] -> ShowS
$cshowList :: [ListExperimentsResponse] -> ShowS
show :: ListExperimentsResponse -> String
$cshow :: ListExperimentsResponse -> String
showsPrec :: Int -> ListExperimentsResponse -> ShowS
$cshowsPrec :: Int -> ListExperimentsResponse -> ShowS
Prelude.Show, (forall x.
 ListExperimentsResponse -> Rep ListExperimentsResponse x)
-> (forall x.
    Rep ListExperimentsResponse x -> ListExperimentsResponse)
-> Generic ListExperimentsResponse
forall x. Rep ListExperimentsResponse x -> ListExperimentsResponse
forall x. ListExperimentsResponse -> Rep ListExperimentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListExperimentsResponse x -> ListExperimentsResponse
$cfrom :: forall x. ListExperimentsResponse -> Rep ListExperimentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListExperimentsResponse' 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:
--
-- 'experiments', 'listExperimentsResponse_experiments' - The experiments.
--
-- 'nextToken', 'listExperimentsResponse_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', 'listExperimentsResponse_httpStatus' - The response's http status code.
newListExperimentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListExperimentsResponse
newListExperimentsResponse :: Int -> ListExperimentsResponse
newListExperimentsResponse Int
pHttpStatus_ =
  ListExperimentsResponse' :: Maybe [ExperimentSummary]
-> Maybe Text -> Int -> ListExperimentsResponse
ListExperimentsResponse'
    { $sel:experiments:ListExperimentsResponse' :: Maybe [ExperimentSummary]
experiments =
        Maybe [ExperimentSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListExperimentsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListExperimentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The experiments.
listExperimentsResponse_experiments :: Lens.Lens' ListExperimentsResponse (Prelude.Maybe [ExperimentSummary])
listExperimentsResponse_experiments :: (Maybe [ExperimentSummary] -> f (Maybe [ExperimentSummary]))
-> ListExperimentsResponse -> f ListExperimentsResponse
listExperimentsResponse_experiments = (ListExperimentsResponse -> Maybe [ExperimentSummary])
-> (ListExperimentsResponse
    -> Maybe [ExperimentSummary] -> ListExperimentsResponse)
-> Lens
     ListExperimentsResponse
     ListExperimentsResponse
     (Maybe [ExperimentSummary])
     (Maybe [ExperimentSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExperimentsResponse' {Maybe [ExperimentSummary]
experiments :: Maybe [ExperimentSummary]
$sel:experiments:ListExperimentsResponse' :: ListExperimentsResponse -> Maybe [ExperimentSummary]
experiments} -> Maybe [ExperimentSummary]
experiments) (\s :: ListExperimentsResponse
s@ListExperimentsResponse' {} Maybe [ExperimentSummary]
a -> ListExperimentsResponse
s {$sel:experiments:ListExperimentsResponse' :: Maybe [ExperimentSummary]
experiments = Maybe [ExperimentSummary]
a} :: ListExperimentsResponse) ((Maybe [ExperimentSummary] -> f (Maybe [ExperimentSummary]))
 -> ListExperimentsResponse -> f ListExperimentsResponse)
-> ((Maybe [ExperimentSummary] -> f (Maybe [ExperimentSummary]))
    -> Maybe [ExperimentSummary] -> f (Maybe [ExperimentSummary]))
-> (Maybe [ExperimentSummary] -> f (Maybe [ExperimentSummary]))
-> ListExperimentsResponse
-> f ListExperimentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ExperimentSummary]
  [ExperimentSummary]
  [ExperimentSummary]
  [ExperimentSummary]
-> Iso
     (Maybe [ExperimentSummary])
     (Maybe [ExperimentSummary])
     (Maybe [ExperimentSummary])
     (Maybe [ExperimentSummary])
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
  [ExperimentSummary]
  [ExperimentSummary]
  [ExperimentSummary]
  [ExperimentSummary]
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.
listExperimentsResponse_nextToken :: Lens.Lens' ListExperimentsResponse (Prelude.Maybe Prelude.Text)
listExperimentsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListExperimentsResponse -> f ListExperimentsResponse
listExperimentsResponse_nextToken = (ListExperimentsResponse -> Maybe Text)
-> (ListExperimentsResponse
    -> Maybe Text -> ListExperimentsResponse)
-> Lens
     ListExperimentsResponse
     ListExperimentsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExperimentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListExperimentsResponse' :: ListExperimentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListExperimentsResponse
s@ListExperimentsResponse' {} Maybe Text
a -> ListExperimentsResponse
s {$sel:nextToken:ListExperimentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListExperimentsResponse)

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

instance Prelude.NFData ListExperimentsResponse