{-# 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.StopApp
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stops the given custom app and shuts down all of its allocated compute
-- resources.
module Amazonka.SimSpaceWeaver.StopApp
  ( -- * Creating a Request
    StopApp (..),
    newStopApp,

    -- * Request Lenses
    stopApp_app,
    stopApp_domain,
    stopApp_simulation,

    -- * Destructuring the Response
    StopAppResponse (..),
    newStopAppResponse,

    -- * Response Lenses
    stopAppResponse_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:/ 'newStopApp' smart constructor.
data StopApp = StopApp'
  { -- | The name of the app.
    StopApp -> Text
app :: Prelude.Text,
    -- | The name of the domain of the app.
    StopApp -> Text
domain :: Prelude.Text,
    -- | The name of the simulation of the app.
    StopApp -> Text
simulation :: Prelude.Text
  }
  deriving (StopApp -> StopApp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopApp -> StopApp -> Bool
$c/= :: StopApp -> StopApp -> Bool
== :: StopApp -> StopApp -> Bool
$c== :: StopApp -> StopApp -> Bool
Prelude.Eq, ReadPrec [StopApp]
ReadPrec StopApp
Int -> ReadS StopApp
ReadS [StopApp]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopApp]
$creadListPrec :: ReadPrec [StopApp]
readPrec :: ReadPrec StopApp
$creadPrec :: ReadPrec StopApp
readList :: ReadS [StopApp]
$creadList :: ReadS [StopApp]
readsPrec :: Int -> ReadS StopApp
$creadsPrec :: Int -> ReadS StopApp
Prelude.Read, Int -> StopApp -> ShowS
[StopApp] -> ShowS
StopApp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopApp] -> ShowS
$cshowList :: [StopApp] -> ShowS
show :: StopApp -> String
$cshow :: StopApp -> String
showsPrec :: Int -> StopApp -> ShowS
$cshowsPrec :: Int -> StopApp -> ShowS
Prelude.Show, forall x. Rep StopApp x -> StopApp
forall x. StopApp -> Rep StopApp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopApp x -> StopApp
$cfrom :: forall x. StopApp -> Rep StopApp x
Prelude.Generic)

-- |
-- Create a value of 'StopApp' 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:
--
-- 'app', 'stopApp_app' - The name of the app.
--
-- 'domain', 'stopApp_domain' - The name of the domain of the app.
--
-- 'simulation', 'stopApp_simulation' - The name of the simulation of the app.
newStopApp ::
  -- | 'app'
  Prelude.Text ->
  -- | 'domain'
  Prelude.Text ->
  -- | 'simulation'
  Prelude.Text ->
  StopApp
newStopApp :: Text -> Text -> Text -> StopApp
newStopApp Text
pApp_ Text
pDomain_ Text
pSimulation_ =
  StopApp'
    { $sel:app:StopApp' :: Text
app = Text
pApp_,
      $sel:domain:StopApp' :: Text
domain = Text
pDomain_,
      $sel:simulation:StopApp' :: Text
simulation = Text
pSimulation_
    }

-- | The name of the app.
stopApp_app :: Lens.Lens' StopApp Prelude.Text
stopApp_app :: Lens' StopApp Text
stopApp_app = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopApp' {Text
app :: Text
$sel:app:StopApp' :: StopApp -> Text
app} -> Text
app) (\s :: StopApp
s@StopApp' {} Text
a -> StopApp
s {$sel:app:StopApp' :: Text
app = Text
a} :: StopApp)

-- | The name of the domain of the app.
stopApp_domain :: Lens.Lens' StopApp Prelude.Text
stopApp_domain :: Lens' StopApp Text
stopApp_domain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopApp' {Text
domain :: Text
$sel:domain:StopApp' :: StopApp -> Text
domain} -> Text
domain) (\s :: StopApp
s@StopApp' {} Text
a -> StopApp
s {$sel:domain:StopApp' :: Text
domain = Text
a} :: StopApp)

-- | The name of the simulation of the app.
stopApp_simulation :: Lens.Lens' StopApp Prelude.Text
stopApp_simulation :: Lens' StopApp Text
stopApp_simulation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopApp' {Text
simulation :: Text
$sel:simulation:StopApp' :: StopApp -> Text
simulation} -> Text
simulation) (\s :: StopApp
s@StopApp' {} Text
a -> StopApp
s {$sel:simulation:StopApp' :: Text
simulation = Text
a} :: StopApp)

instance Core.AWSRequest StopApp where
  type AWSResponse StopApp = StopAppResponse
  request :: (Service -> Service) -> StopApp -> Request StopApp
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StopApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopApp)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StopAppResponse
StopAppResponse'
            forall (f :: * -> *) a b. Functor 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 StopApp where
  hashWithSalt :: Int -> StopApp -> Int
hashWithSalt Int
_salt StopApp' {Text
simulation :: Text
domain :: Text
app :: Text
$sel:simulation:StopApp' :: StopApp -> Text
$sel:domain:StopApp' :: StopApp -> Text
$sel:app:StopApp' :: StopApp -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
app
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domain
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
simulation

instance Prelude.NFData StopApp where
  rnf :: StopApp -> ()
rnf StopApp' {Text
simulation :: Text
domain :: Text
app :: Text
$sel:simulation:StopApp' :: StopApp -> Text
$sel:domain:StopApp' :: StopApp -> Text
$sel:app:StopApp' :: StopApp -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
app
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
simulation

instance Data.ToHeaders StopApp where
  toHeaders :: StopApp -> 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.ToJSON StopApp where
  toJSON :: StopApp -> Value
toJSON StopApp' {Text
simulation :: Text
domain :: Text
app :: Text
$sel:simulation:StopApp' :: StopApp -> Text
$sel:domain:StopApp' :: StopApp -> Text
$sel:app:StopApp' :: StopApp -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"App" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
app),
            forall a. a -> Maybe a
Prelude.Just (Key
"Domain" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
domain),
            forall a. a -> Maybe a
Prelude.Just (Key
"Simulation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
simulation)
          ]
      )

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

instance Data.ToQuery StopApp where
  toQuery :: StopApp -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newStopAppResponse' smart constructor.
data StopAppResponse = StopAppResponse'
  { -- | The response's http status code.
    StopAppResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopAppResponse -> StopAppResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopAppResponse -> StopAppResponse -> Bool
$c/= :: StopAppResponse -> StopAppResponse -> Bool
== :: StopAppResponse -> StopAppResponse -> Bool
$c== :: StopAppResponse -> StopAppResponse -> Bool
Prelude.Eq, ReadPrec [StopAppResponse]
ReadPrec StopAppResponse
Int -> ReadS StopAppResponse
ReadS [StopAppResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopAppResponse]
$creadListPrec :: ReadPrec [StopAppResponse]
readPrec :: ReadPrec StopAppResponse
$creadPrec :: ReadPrec StopAppResponse
readList :: ReadS [StopAppResponse]
$creadList :: ReadS [StopAppResponse]
readsPrec :: Int -> ReadS StopAppResponse
$creadsPrec :: Int -> ReadS StopAppResponse
Prelude.Read, Int -> StopAppResponse -> ShowS
[StopAppResponse] -> ShowS
StopAppResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopAppResponse] -> ShowS
$cshowList :: [StopAppResponse] -> ShowS
show :: StopAppResponse -> String
$cshow :: StopAppResponse -> String
showsPrec :: Int -> StopAppResponse -> ShowS
$cshowsPrec :: Int -> StopAppResponse -> ShowS
Prelude.Show, forall x. Rep StopAppResponse x -> StopAppResponse
forall x. StopAppResponse -> Rep StopAppResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopAppResponse x -> StopAppResponse
$cfrom :: forall x. StopAppResponse -> Rep StopAppResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopAppResponse' 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:
--
-- 'httpStatus', 'stopAppResponse_httpStatus' - The response's http status code.
newStopAppResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopAppResponse
newStopAppResponse :: Int -> StopAppResponse
newStopAppResponse Int
pHttpStatus_ =
  StopAppResponse' {$sel:httpStatus:StopAppResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData StopAppResponse where
  rnf :: StopAppResponse -> ()
rnf StopAppResponse' {Int
httpStatus :: Int
$sel:httpStatus:StopAppResponse' :: StopAppResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus