{-# 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.SMS.TerminateApp
-- 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)
--
-- Terminates the stack for the specified application.
module Amazonka.SMS.TerminateApp
  ( -- * Creating a Request
    TerminateApp (..),
    newTerminateApp,

    -- * Request Lenses
    terminateApp_appId,

    -- * Destructuring the Response
    TerminateAppResponse (..),
    newTerminateAppResponse,

    -- * Response Lenses
    terminateAppResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SMS.Types

-- | /See:/ 'newTerminateApp' smart constructor.
data TerminateApp = TerminateApp'
  { -- | The ID of the application.
    TerminateApp -> Maybe Text
appId :: Prelude.Maybe Prelude.Text
  }
  deriving (TerminateApp -> TerminateApp -> Bool
(TerminateApp -> TerminateApp -> Bool)
-> (TerminateApp -> TerminateApp -> Bool) -> Eq TerminateApp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TerminateApp -> TerminateApp -> Bool
$c/= :: TerminateApp -> TerminateApp -> Bool
== :: TerminateApp -> TerminateApp -> Bool
$c== :: TerminateApp -> TerminateApp -> Bool
Prelude.Eq, ReadPrec [TerminateApp]
ReadPrec TerminateApp
Int -> ReadS TerminateApp
ReadS [TerminateApp]
(Int -> ReadS TerminateApp)
-> ReadS [TerminateApp]
-> ReadPrec TerminateApp
-> ReadPrec [TerminateApp]
-> Read TerminateApp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TerminateApp]
$creadListPrec :: ReadPrec [TerminateApp]
readPrec :: ReadPrec TerminateApp
$creadPrec :: ReadPrec TerminateApp
readList :: ReadS [TerminateApp]
$creadList :: ReadS [TerminateApp]
readsPrec :: Int -> ReadS TerminateApp
$creadsPrec :: Int -> ReadS TerminateApp
Prelude.Read, Int -> TerminateApp -> ShowS
[TerminateApp] -> ShowS
TerminateApp -> String
(Int -> TerminateApp -> ShowS)
-> (TerminateApp -> String)
-> ([TerminateApp] -> ShowS)
-> Show TerminateApp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TerminateApp] -> ShowS
$cshowList :: [TerminateApp] -> ShowS
show :: TerminateApp -> String
$cshow :: TerminateApp -> String
showsPrec :: Int -> TerminateApp -> ShowS
$cshowsPrec :: Int -> TerminateApp -> ShowS
Prelude.Show, (forall x. TerminateApp -> Rep TerminateApp x)
-> (forall x. Rep TerminateApp x -> TerminateApp)
-> Generic TerminateApp
forall x. Rep TerminateApp x -> TerminateApp
forall x. TerminateApp -> Rep TerminateApp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TerminateApp x -> TerminateApp
$cfrom :: forall x. TerminateApp -> Rep TerminateApp x
Prelude.Generic)

-- |
-- Create a value of 'TerminateApp' 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:
--
-- 'appId', 'terminateApp_appId' - The ID of the application.
newTerminateApp ::
  TerminateApp
newTerminateApp :: TerminateApp
newTerminateApp =
  TerminateApp' :: Maybe Text -> TerminateApp
TerminateApp' {$sel:appId:TerminateApp' :: Maybe Text
appId = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The ID of the application.
terminateApp_appId :: Lens.Lens' TerminateApp (Prelude.Maybe Prelude.Text)
terminateApp_appId :: (Maybe Text -> f (Maybe Text)) -> TerminateApp -> f TerminateApp
terminateApp_appId = (TerminateApp -> Maybe Text)
-> (TerminateApp -> Maybe Text -> TerminateApp)
-> Lens TerminateApp TerminateApp (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TerminateApp' {Maybe Text
appId :: Maybe Text
$sel:appId:TerminateApp' :: TerminateApp -> Maybe Text
appId} -> Maybe Text
appId) (\s :: TerminateApp
s@TerminateApp' {} Maybe Text
a -> TerminateApp
s {$sel:appId:TerminateApp' :: Maybe Text
appId = Maybe Text
a} :: TerminateApp)

instance Core.AWSRequest TerminateApp where
  type AWSResponse TerminateApp = TerminateAppResponse
  request :: TerminateApp -> Request TerminateApp
request = Service -> TerminateApp -> Request TerminateApp
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy TerminateApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TerminateApp)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse TerminateApp))
-> Logger
-> Service
-> Proxy TerminateApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse TerminateApp)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> TerminateAppResponse
TerminateAppResponse'
            (Int -> TerminateAppResponse)
-> Either String Int -> Either String TerminateAppResponse
forall (f :: * -> *) a b. Functor 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 TerminateApp

instance Prelude.NFData TerminateApp

instance Core.ToHeaders TerminateApp where
  toHeaders :: TerminateApp -> ResponseHeaders
toHeaders =
    ResponseHeaders -> TerminateApp -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSServerMigrationService_V2016_10_24.TerminateApp" ::
                          Prelude.ByteString
                      ),
            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.ToJSON TerminateApp where
  toJSON :: TerminateApp -> Value
toJSON TerminateApp' {Maybe Text
appId :: Maybe Text
$sel:appId:TerminateApp' :: TerminateApp -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"appId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
appId]
      )

instance Core.ToPath TerminateApp where
  toPath :: TerminateApp -> ByteString
toPath = ByteString -> TerminateApp -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData TerminateAppResponse