{-# 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.SimSpaceWeaver.ListSimulations
-- 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 SimSpace Weaver simulations in the Amazon Web Services account
-- used to make the API call.
module Amazonka.SimSpaceWeaver.ListSimulations
  ( -- * Creating a Request
    ListSimulations (..),
    newListSimulations,

    -- * Request Lenses
    listSimulations_maxResults,
    listSimulations_nextToken,

    -- * Destructuring the Response
    ListSimulationsResponse (..),
    newListSimulationsResponse,

    -- * Response Lenses
    listSimulationsResponse_nextToken,
    listSimulationsResponse_simulations,
    listSimulationsResponse_httpStatus,
  )
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.SimSpaceWeaver.Types

-- | /See:/ 'newListSimulations' smart constructor.
data ListSimulations = ListSimulations'
  { -- | The maximum number of simulations to list.
    ListSimulations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | If SimSpace Weaver returns @nextToken@, there are more results
    -- available. The value of @nextToken@ is a unique pagination token for
    -- each page. To retrieve the next page, call the operation again using the
    -- returned token. Keep all other arguments unchanged. If no results
    -- remain, @nextToken@ is set to @null@. Each pagination token expires
    -- after 24 hours. If you provide a token that isn\'t valid, you receive an
    -- /HTTP 400 ValidationException/ error.
    ListSimulations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListSimulations -> ListSimulations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSimulations -> ListSimulations -> Bool
$c/= :: ListSimulations -> ListSimulations -> Bool
== :: ListSimulations -> ListSimulations -> Bool
$c== :: ListSimulations -> ListSimulations -> Bool
Prelude.Eq, ReadPrec [ListSimulations]
ReadPrec ListSimulations
Int -> ReadS ListSimulations
ReadS [ListSimulations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSimulations]
$creadListPrec :: ReadPrec [ListSimulations]
readPrec :: ReadPrec ListSimulations
$creadPrec :: ReadPrec ListSimulations
readList :: ReadS [ListSimulations]
$creadList :: ReadS [ListSimulations]
readsPrec :: Int -> ReadS ListSimulations
$creadsPrec :: Int -> ReadS ListSimulations
Prelude.Read, Int -> ListSimulations -> ShowS
[ListSimulations] -> ShowS
ListSimulations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSimulations] -> ShowS
$cshowList :: [ListSimulations] -> ShowS
show :: ListSimulations -> String
$cshow :: ListSimulations -> String
showsPrec :: Int -> ListSimulations -> ShowS
$cshowsPrec :: Int -> ListSimulations -> ShowS
Prelude.Show, forall x. Rep ListSimulations x -> ListSimulations
forall x. ListSimulations -> Rep ListSimulations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSimulations x -> ListSimulations
$cfrom :: forall x. ListSimulations -> Rep ListSimulations x
Prelude.Generic)

-- |
-- Create a value of 'ListSimulations' 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', 'listSimulations_maxResults' - The maximum number of simulations to list.
--
-- 'nextToken', 'listSimulations_nextToken' - If SimSpace Weaver returns @nextToken@, there are more results
-- available. The value of @nextToken@ is a unique pagination token for
-- each page. To retrieve the next page, call the operation again using the
-- returned token. Keep all other arguments unchanged. If no results
-- remain, @nextToken@ is set to @null@. Each pagination token expires
-- after 24 hours. If you provide a token that isn\'t valid, you receive an
-- /HTTP 400 ValidationException/ error.
newListSimulations ::
  ListSimulations
newListSimulations :: ListSimulations
newListSimulations =
  ListSimulations'
    { $sel:maxResults:ListSimulations' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListSimulations' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of simulations to list.
listSimulations_maxResults :: Lens.Lens' ListSimulations (Prelude.Maybe Prelude.Natural)
listSimulations_maxResults :: Lens' ListSimulations (Maybe Natural)
listSimulations_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSimulations' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListSimulations' :: ListSimulations -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListSimulations
s@ListSimulations' {} Maybe Natural
a -> ListSimulations
s {$sel:maxResults:ListSimulations' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListSimulations)

-- | If SimSpace Weaver returns @nextToken@, there are more results
-- available. The value of @nextToken@ is a unique pagination token for
-- each page. To retrieve the next page, call the operation again using the
-- returned token. Keep all other arguments unchanged. If no results
-- remain, @nextToken@ is set to @null@. Each pagination token expires
-- after 24 hours. If you provide a token that isn\'t valid, you receive an
-- /HTTP 400 ValidationException/ error.
listSimulations_nextToken :: Lens.Lens' ListSimulations (Prelude.Maybe Prelude.Text)
listSimulations_nextToken :: Lens' ListSimulations (Maybe Text)
listSimulations_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSimulations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListSimulations' :: ListSimulations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListSimulations
s@ListSimulations' {} Maybe Text
a -> ListSimulations
s {$sel:nextToken:ListSimulations' :: Maybe Text
nextToken = Maybe Text
a} :: ListSimulations)

instance Core.AWSRequest ListSimulations where
  type
    AWSResponse ListSimulations =
      ListSimulationsResponse
  request :: (Service -> Service) -> ListSimulations -> Request ListSimulations
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 ListSimulations
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListSimulations)))
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
-> Maybe [SimulationMetadata] -> Int -> ListSimulationsResponse
ListSimulationsResponse'
            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Simulations" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListSimulations where
  hashWithSalt :: Int -> ListSimulations -> Int
hashWithSalt Int
_salt ListSimulations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListSimulations' :: ListSimulations -> Maybe Text
$sel:maxResults:ListSimulations' :: ListSimulations -> 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 ListSimulations where
  rnf :: ListSimulations -> ()
rnf ListSimulations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListSimulations' :: ListSimulations -> Maybe Text
$sel:maxResults:ListSimulations' :: ListSimulations -> 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 ListSimulations where
  toHeaders :: ListSimulations -> 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 ListSimulations where
  toPath :: ListSimulations -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/listsimulations"

instance Data.ToQuery ListSimulations where
  toQuery :: ListSimulations -> QueryString
toQuery ListSimulations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListSimulations' :: ListSimulations -> Maybe Text
$sel:maxResults:ListSimulations' :: ListSimulations -> 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:/ 'newListSimulationsResponse' smart constructor.
data ListSimulationsResponse = ListSimulationsResponse'
  { -- | If SimSpace Weaver returns @nextToken@, there are more results
    -- available. The value of @nextToken@ is a unique pagination token for
    -- each page. To retrieve the next page, call the operation again using the
    -- returned token. Keep all other arguments unchanged. If no results
    -- remain, @nextToken@ is set to @null@. Each pagination token expires
    -- after 24 hours. If you provide a token that isn\'t valid, you receive an
    -- /HTTP 400 ValidationException/ error.
    ListSimulationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The list of simulations.
    ListSimulationsResponse -> Maybe [SimulationMetadata]
simulations :: Prelude.Maybe [SimulationMetadata],
    -- | The response's http status code.
    ListSimulationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListSimulationsResponse -> ListSimulationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListSimulationsResponse -> ListSimulationsResponse -> Bool
$c/= :: ListSimulationsResponse -> ListSimulationsResponse -> Bool
== :: ListSimulationsResponse -> ListSimulationsResponse -> Bool
$c== :: ListSimulationsResponse -> ListSimulationsResponse -> Bool
Prelude.Eq, ReadPrec [ListSimulationsResponse]
ReadPrec ListSimulationsResponse
Int -> ReadS ListSimulationsResponse
ReadS [ListSimulationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListSimulationsResponse]
$creadListPrec :: ReadPrec [ListSimulationsResponse]
readPrec :: ReadPrec ListSimulationsResponse
$creadPrec :: ReadPrec ListSimulationsResponse
readList :: ReadS [ListSimulationsResponse]
$creadList :: ReadS [ListSimulationsResponse]
readsPrec :: Int -> ReadS ListSimulationsResponse
$creadsPrec :: Int -> ReadS ListSimulationsResponse
Prelude.Read, Int -> ListSimulationsResponse -> ShowS
[ListSimulationsResponse] -> ShowS
ListSimulationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListSimulationsResponse] -> ShowS
$cshowList :: [ListSimulationsResponse] -> ShowS
show :: ListSimulationsResponse -> String
$cshow :: ListSimulationsResponse -> String
showsPrec :: Int -> ListSimulationsResponse -> ShowS
$cshowsPrec :: Int -> ListSimulationsResponse -> ShowS
Prelude.Show, forall x. Rep ListSimulationsResponse x -> ListSimulationsResponse
forall x. ListSimulationsResponse -> Rep ListSimulationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListSimulationsResponse x -> ListSimulationsResponse
$cfrom :: forall x. ListSimulationsResponse -> Rep ListSimulationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListSimulationsResponse' 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', 'listSimulationsResponse_nextToken' - If SimSpace Weaver returns @nextToken@, there are more results
-- available. The value of @nextToken@ is a unique pagination token for
-- each page. To retrieve the next page, call the operation again using the
-- returned token. Keep all other arguments unchanged. If no results
-- remain, @nextToken@ is set to @null@. Each pagination token expires
-- after 24 hours. If you provide a token that isn\'t valid, you receive an
-- /HTTP 400 ValidationException/ error.
--
-- 'simulations', 'listSimulationsResponse_simulations' - The list of simulations.
--
-- 'httpStatus', 'listSimulationsResponse_httpStatus' - The response's http status code.
newListSimulationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListSimulationsResponse
newListSimulationsResponse :: Int -> ListSimulationsResponse
newListSimulationsResponse Int
pHttpStatus_ =
  ListSimulationsResponse'
    { $sel:nextToken:ListSimulationsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:simulations:ListSimulationsResponse' :: Maybe [SimulationMetadata]
simulations = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListSimulationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If SimSpace Weaver returns @nextToken@, there are more results
-- available. The value of @nextToken@ is a unique pagination token for
-- each page. To retrieve the next page, call the operation again using the
-- returned token. Keep all other arguments unchanged. If no results
-- remain, @nextToken@ is set to @null@. Each pagination token expires
-- after 24 hours. If you provide a token that isn\'t valid, you receive an
-- /HTTP 400 ValidationException/ error.
listSimulationsResponse_nextToken :: Lens.Lens' ListSimulationsResponse (Prelude.Maybe Prelude.Text)
listSimulationsResponse_nextToken :: Lens' ListSimulationsResponse (Maybe Text)
listSimulationsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSimulationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListSimulationsResponse' :: ListSimulationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListSimulationsResponse
s@ListSimulationsResponse' {} Maybe Text
a -> ListSimulationsResponse
s {$sel:nextToken:ListSimulationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListSimulationsResponse)

-- | The list of simulations.
listSimulationsResponse_simulations :: Lens.Lens' ListSimulationsResponse (Prelude.Maybe [SimulationMetadata])
listSimulationsResponse_simulations :: Lens' ListSimulationsResponse (Maybe [SimulationMetadata])
listSimulationsResponse_simulations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSimulationsResponse' {Maybe [SimulationMetadata]
simulations :: Maybe [SimulationMetadata]
$sel:simulations:ListSimulationsResponse' :: ListSimulationsResponse -> Maybe [SimulationMetadata]
simulations} -> Maybe [SimulationMetadata]
simulations) (\s :: ListSimulationsResponse
s@ListSimulationsResponse' {} Maybe [SimulationMetadata]
a -> ListSimulationsResponse
s {$sel:simulations:ListSimulationsResponse' :: Maybe [SimulationMetadata]
simulations = Maybe [SimulationMetadata]
a} :: ListSimulationsResponse) 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 response's http status code.
listSimulationsResponse_httpStatus :: Lens.Lens' ListSimulationsResponse Prelude.Int
listSimulationsResponse_httpStatus :: Lens' ListSimulationsResponse Int
listSimulationsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListSimulationsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListSimulationsResponse' :: ListSimulationsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListSimulationsResponse
s@ListSimulationsResponse' {} Int
a -> ListSimulationsResponse
s {$sel:httpStatus:ListSimulationsResponse' :: Int
httpStatus = Int
a} :: ListSimulationsResponse)

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