{-# 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.ListApps
-- 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 all custom apps or service apps for the given simulation and
-- domain.
module Amazonka.SimSpaceWeaver.ListApps
  ( -- * Creating a Request
    ListApps (..),
    newListApps,

    -- * Request Lenses
    listApps_domain,
    listApps_maxResults,
    listApps_nextToken,
    listApps_simulation,

    -- * Destructuring the Response
    ListAppsResponse (..),
    newListAppsResponse,

    -- * Response Lenses
    listAppsResponse_apps,
    listAppsResponse_nextToken,
    listAppsResponse_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:/ 'newListApps' smart constructor.
data ListApps = ListApps'
  { -- | The name of the domain that you want to list apps for.
    ListApps -> Maybe Text
domain :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of apps to list.
    ListApps -> 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.
    ListApps -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the simulation that you want to list apps for.
    ListApps -> Text
simulation :: Prelude.Text
  }
  deriving (ListApps -> ListApps -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListApps -> ListApps -> Bool
$c/= :: ListApps -> ListApps -> Bool
== :: ListApps -> ListApps -> Bool
$c== :: ListApps -> ListApps -> Bool
Prelude.Eq, ReadPrec [ListApps]
ReadPrec ListApps
Int -> ReadS ListApps
ReadS [ListApps]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListApps]
$creadListPrec :: ReadPrec [ListApps]
readPrec :: ReadPrec ListApps
$creadPrec :: ReadPrec ListApps
readList :: ReadS [ListApps]
$creadList :: ReadS [ListApps]
readsPrec :: Int -> ReadS ListApps
$creadsPrec :: Int -> ReadS ListApps
Prelude.Read, Int -> ListApps -> ShowS
[ListApps] -> ShowS
ListApps -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListApps] -> ShowS
$cshowList :: [ListApps] -> ShowS
show :: ListApps -> String
$cshow :: ListApps -> String
showsPrec :: Int -> ListApps -> ShowS
$cshowsPrec :: Int -> ListApps -> ShowS
Prelude.Show, forall x. Rep ListApps x -> ListApps
forall x. ListApps -> Rep ListApps x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListApps x -> ListApps
$cfrom :: forall x. ListApps -> Rep ListApps x
Prelude.Generic)

-- |
-- Create a value of 'ListApps' 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:
--
-- 'domain', 'listApps_domain' - The name of the domain that you want to list apps for.
--
-- 'maxResults', 'listApps_maxResults' - The maximum number of apps to list.
--
-- 'nextToken', 'listApps_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.
--
-- 'simulation', 'listApps_simulation' - The name of the simulation that you want to list apps for.
newListApps ::
  -- | 'simulation'
  Prelude.Text ->
  ListApps
newListApps :: Text -> ListApps
newListApps Text
pSimulation_ =
  ListApps'
    { $sel:domain:ListApps' :: Maybe Text
domain = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListApps' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListApps' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:simulation:ListApps' :: Text
simulation = Text
pSimulation_
    }

-- | The name of the domain that you want to list apps for.
listApps_domain :: Lens.Lens' ListApps (Prelude.Maybe Prelude.Text)
listApps_domain :: Lens' ListApps (Maybe Text)
listApps_domain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListApps' {Maybe Text
domain :: Maybe Text
$sel:domain:ListApps' :: ListApps -> Maybe Text
domain} -> Maybe Text
domain) (\s :: ListApps
s@ListApps' {} Maybe Text
a -> ListApps
s {$sel:domain:ListApps' :: Maybe Text
domain = Maybe Text
a} :: ListApps)

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

-- | 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.
listApps_nextToken :: Lens.Lens' ListApps (Prelude.Maybe Prelude.Text)
listApps_nextToken :: Lens' ListApps (Maybe Text)
listApps_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListApps' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListApps' :: ListApps -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListApps
s@ListApps' {} Maybe Text
a -> ListApps
s {$sel:nextToken:ListApps' :: Maybe Text
nextToken = Maybe Text
a} :: ListApps)

-- | The name of the simulation that you want to list apps for.
listApps_simulation :: Lens.Lens' ListApps Prelude.Text
listApps_simulation :: Lens' ListApps Text
listApps_simulation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListApps' {Text
simulation :: Text
$sel:simulation:ListApps' :: ListApps -> Text
simulation} -> Text
simulation) (\s :: ListApps
s@ListApps' {} Text
a -> ListApps
s {$sel:simulation:ListApps' :: Text
simulation = Text
a} :: ListApps)

instance Core.AWSRequest ListApps where
  type AWSResponse ListApps = ListAppsResponse
  request :: (Service -> Service) -> ListApps -> Request ListApps
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 ListApps
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListApps)))
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 [SimulationAppMetadata]
-> Maybe Text -> Int -> ListAppsResponse
ListAppsResponse'
            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
"Apps" 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 ListApps where
  hashWithSalt :: Int -> ListApps -> Int
hashWithSalt Int
_salt ListApps' {Maybe Natural
Maybe Text
Text
simulation :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
domain :: Maybe Text
$sel:simulation:ListApps' :: ListApps -> Text
$sel:nextToken:ListApps' :: ListApps -> Maybe Text
$sel:maxResults:ListApps' :: ListApps -> Maybe Natural
$sel:domain:ListApps' :: ListApps -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
domain
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
simulation

instance Prelude.NFData ListApps where
  rnf :: ListApps -> ()
rnf ListApps' {Maybe Natural
Maybe Text
Text
simulation :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
domain :: Maybe Text
$sel:simulation:ListApps' :: ListApps -> Text
$sel:nextToken:ListApps' :: ListApps -> Maybe Text
$sel:maxResults:ListApps' :: ListApps -> Maybe Natural
$sel:domain:ListApps' :: ListApps -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
domain
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
simulation

instance Data.ToHeaders ListApps where
  toHeaders :: ListApps -> 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 ListApps where
  toPath :: ListApps -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/listapps"

instance Data.ToQuery ListApps where
  toQuery :: ListApps -> QueryString
toQuery ListApps' {Maybe Natural
Maybe Text
Text
simulation :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
domain :: Maybe Text
$sel:simulation:ListApps' :: ListApps -> Text
$sel:nextToken:ListApps' :: ListApps -> Maybe Text
$sel:maxResults:ListApps' :: ListApps -> Maybe Natural
$sel:domain:ListApps' :: ListApps -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"domain" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
domain,
        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,
        ByteString
"simulation" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
simulation
      ]

-- | /See:/ 'newListAppsResponse' smart constructor.
data ListAppsResponse = ListAppsResponse'
  { -- | The list of apps for the given simulation and domain.
    ListAppsResponse -> Maybe [SimulationAppMetadata]
apps :: Prelude.Maybe [SimulationAppMetadata],
    -- | 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.
    ListAppsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAppsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAppsResponse -> ListAppsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAppsResponse -> ListAppsResponse -> Bool
$c/= :: ListAppsResponse -> ListAppsResponse -> Bool
== :: ListAppsResponse -> ListAppsResponse -> Bool
$c== :: ListAppsResponse -> ListAppsResponse -> Bool
Prelude.Eq, ReadPrec [ListAppsResponse]
ReadPrec ListAppsResponse
Int -> ReadS ListAppsResponse
ReadS [ListAppsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAppsResponse]
$creadListPrec :: ReadPrec [ListAppsResponse]
readPrec :: ReadPrec ListAppsResponse
$creadPrec :: ReadPrec ListAppsResponse
readList :: ReadS [ListAppsResponse]
$creadList :: ReadS [ListAppsResponse]
readsPrec :: Int -> ReadS ListAppsResponse
$creadsPrec :: Int -> ReadS ListAppsResponse
Prelude.Read, Int -> ListAppsResponse -> ShowS
[ListAppsResponse] -> ShowS
ListAppsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAppsResponse] -> ShowS
$cshowList :: [ListAppsResponse] -> ShowS
show :: ListAppsResponse -> String
$cshow :: ListAppsResponse -> String
showsPrec :: Int -> ListAppsResponse -> ShowS
$cshowsPrec :: Int -> ListAppsResponse -> ShowS
Prelude.Show, forall x. Rep ListAppsResponse x -> ListAppsResponse
forall x. ListAppsResponse -> Rep ListAppsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAppsResponse x -> ListAppsResponse
$cfrom :: forall x. ListAppsResponse -> Rep ListAppsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAppsResponse' 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:
--
-- 'apps', 'listAppsResponse_apps' - The list of apps for the given simulation and domain.
--
-- 'nextToken', 'listAppsResponse_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.
--
-- 'httpStatus', 'listAppsResponse_httpStatus' - The response's http status code.
newListAppsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAppsResponse
newListAppsResponse :: Int -> ListAppsResponse
newListAppsResponse Int
pHttpStatus_ =
  ListAppsResponse'
    { $sel:apps:ListAppsResponse' :: Maybe [SimulationAppMetadata]
apps = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAppsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAppsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of apps for the given simulation and domain.
listAppsResponse_apps :: Lens.Lens' ListAppsResponse (Prelude.Maybe [SimulationAppMetadata])
listAppsResponse_apps :: Lens' ListAppsResponse (Maybe [SimulationAppMetadata])
listAppsResponse_apps = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppsResponse' {Maybe [SimulationAppMetadata]
apps :: Maybe [SimulationAppMetadata]
$sel:apps:ListAppsResponse' :: ListAppsResponse -> Maybe [SimulationAppMetadata]
apps} -> Maybe [SimulationAppMetadata]
apps) (\s :: ListAppsResponse
s@ListAppsResponse' {} Maybe [SimulationAppMetadata]
a -> ListAppsResponse
s {$sel:apps:ListAppsResponse' :: Maybe [SimulationAppMetadata]
apps = Maybe [SimulationAppMetadata]
a} :: ListAppsResponse) 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

-- | 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.
listAppsResponse_nextToken :: Lens.Lens' ListAppsResponse (Prelude.Maybe Prelude.Text)
listAppsResponse_nextToken :: Lens' ListAppsResponse (Maybe Text)
listAppsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAppsResponse' :: ListAppsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAppsResponse
s@ListAppsResponse' {} Maybe Text
a -> ListAppsResponse
s {$sel:nextToken:ListAppsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAppsResponse)

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

instance Prelude.NFData ListAppsResponse where
  rnf :: ListAppsResponse -> ()
rnf ListAppsResponse' {Int
Maybe [SimulationAppMetadata]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
apps :: Maybe [SimulationAppMetadata]
$sel:httpStatus:ListAppsResponse' :: ListAppsResponse -> Int
$sel:nextToken:ListAppsResponse' :: ListAppsResponse -> Maybe Text
$sel:apps:ListAppsResponse' :: ListAppsResponse -> Maybe [SimulationAppMetadata]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [SimulationAppMetadata]
apps
      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