{-# 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.DeleteApp
-- 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)
--
-- Deletes the specified application. Optionally deletes the launched stack
-- associated with the application and all AWS SMS replication jobs for
-- servers in the application.
module Amazonka.SMS.DeleteApp
  ( -- * Creating a Request
    DeleteApp (..),
    newDeleteApp,

    -- * Request Lenses
    deleteApp_forceTerminateApp,
    deleteApp_appId,
    deleteApp_forceStopAppReplication,

    -- * Destructuring the Response
    DeleteAppResponse (..),
    newDeleteAppResponse,

    -- * Response Lenses
    deleteAppResponse_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:/ 'newDeleteApp' smart constructor.
data DeleteApp = DeleteApp'
  { -- | Indicates whether to terminate the stack corresponding to the
    -- application while deleting the application.
    DeleteApp -> Maybe Bool
forceTerminateApp :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the application.
    DeleteApp -> Maybe Text
appId :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether to stop all replication jobs corresponding to the
    -- servers in the application while deleting the application.
    DeleteApp -> Maybe Bool
forceStopAppReplication :: Prelude.Maybe Prelude.Bool
  }
  deriving (DeleteApp -> DeleteApp -> Bool
(DeleteApp -> DeleteApp -> Bool)
-> (DeleteApp -> DeleteApp -> Bool) -> Eq DeleteApp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteApp -> DeleteApp -> Bool
$c/= :: DeleteApp -> DeleteApp -> Bool
== :: DeleteApp -> DeleteApp -> Bool
$c== :: DeleteApp -> DeleteApp -> Bool
Prelude.Eq, ReadPrec [DeleteApp]
ReadPrec DeleteApp
Int -> ReadS DeleteApp
ReadS [DeleteApp]
(Int -> ReadS DeleteApp)
-> ReadS [DeleteApp]
-> ReadPrec DeleteApp
-> ReadPrec [DeleteApp]
-> Read DeleteApp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteApp]
$creadListPrec :: ReadPrec [DeleteApp]
readPrec :: ReadPrec DeleteApp
$creadPrec :: ReadPrec DeleteApp
readList :: ReadS [DeleteApp]
$creadList :: ReadS [DeleteApp]
readsPrec :: Int -> ReadS DeleteApp
$creadsPrec :: Int -> ReadS DeleteApp
Prelude.Read, Int -> DeleteApp -> ShowS
[DeleteApp] -> ShowS
DeleteApp -> String
(Int -> DeleteApp -> ShowS)
-> (DeleteApp -> String)
-> ([DeleteApp] -> ShowS)
-> Show DeleteApp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteApp] -> ShowS
$cshowList :: [DeleteApp] -> ShowS
show :: DeleteApp -> String
$cshow :: DeleteApp -> String
showsPrec :: Int -> DeleteApp -> ShowS
$cshowsPrec :: Int -> DeleteApp -> ShowS
Prelude.Show, (forall x. DeleteApp -> Rep DeleteApp x)
-> (forall x. Rep DeleteApp x -> DeleteApp) -> Generic DeleteApp
forall x. Rep DeleteApp x -> DeleteApp
forall x. DeleteApp -> Rep DeleteApp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteApp x -> DeleteApp
$cfrom :: forall x. DeleteApp -> Rep DeleteApp x
Prelude.Generic)

-- |
-- Create a value of 'DeleteApp' 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:
--
-- 'forceTerminateApp', 'deleteApp_forceTerminateApp' - Indicates whether to terminate the stack corresponding to the
-- application while deleting the application.
--
-- 'appId', 'deleteApp_appId' - The ID of the application.
--
-- 'forceStopAppReplication', 'deleteApp_forceStopAppReplication' - Indicates whether to stop all replication jobs corresponding to the
-- servers in the application while deleting the application.
newDeleteApp ::
  DeleteApp
newDeleteApp :: DeleteApp
newDeleteApp =
  DeleteApp' :: Maybe Bool -> Maybe Text -> Maybe Bool -> DeleteApp
DeleteApp'
    { $sel:forceTerminateApp:DeleteApp' :: Maybe Bool
forceTerminateApp = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:appId:DeleteApp' :: Maybe Text
appId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:forceStopAppReplication:DeleteApp' :: Maybe Bool
forceStopAppReplication = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether to terminate the stack corresponding to the
-- application while deleting the application.
deleteApp_forceTerminateApp :: Lens.Lens' DeleteApp (Prelude.Maybe Prelude.Bool)
deleteApp_forceTerminateApp :: (Maybe Bool -> f (Maybe Bool)) -> DeleteApp -> f DeleteApp
deleteApp_forceTerminateApp = (DeleteApp -> Maybe Bool)
-> (DeleteApp -> Maybe Bool -> DeleteApp)
-> Lens DeleteApp DeleteApp (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApp' {Maybe Bool
forceTerminateApp :: Maybe Bool
$sel:forceTerminateApp:DeleteApp' :: DeleteApp -> Maybe Bool
forceTerminateApp} -> Maybe Bool
forceTerminateApp) (\s :: DeleteApp
s@DeleteApp' {} Maybe Bool
a -> DeleteApp
s {$sel:forceTerminateApp:DeleteApp' :: Maybe Bool
forceTerminateApp = Maybe Bool
a} :: DeleteApp)

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

-- | Indicates whether to stop all replication jobs corresponding to the
-- servers in the application while deleting the application.
deleteApp_forceStopAppReplication :: Lens.Lens' DeleteApp (Prelude.Maybe Prelude.Bool)
deleteApp_forceStopAppReplication :: (Maybe Bool -> f (Maybe Bool)) -> DeleteApp -> f DeleteApp
deleteApp_forceStopAppReplication = (DeleteApp -> Maybe Bool)
-> (DeleteApp -> Maybe Bool -> DeleteApp)
-> Lens DeleteApp DeleteApp (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApp' {Maybe Bool
forceStopAppReplication :: Maybe Bool
$sel:forceStopAppReplication:DeleteApp' :: DeleteApp -> Maybe Bool
forceStopAppReplication} -> Maybe Bool
forceStopAppReplication) (\s :: DeleteApp
s@DeleteApp' {} Maybe Bool
a -> DeleteApp
s {$sel:forceStopAppReplication:DeleteApp' :: Maybe Bool
forceStopAppReplication = Maybe Bool
a} :: DeleteApp)

instance Core.AWSRequest DeleteApp where
  type AWSResponse DeleteApp = DeleteAppResponse
  request :: DeleteApp -> Request DeleteApp
request = Service -> DeleteApp -> Request DeleteApp
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteApp)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse DeleteApp))
-> Logger
-> Service
-> Proxy DeleteApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteApp)))
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 -> DeleteAppResponse
DeleteAppResponse'
            (Int -> DeleteAppResponse)
-> Either String Int -> Either String DeleteAppResponse
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 DeleteApp

instance Prelude.NFData DeleteApp

instance Core.ToHeaders DeleteApp where
  toHeaders :: DeleteApp -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteApp -> 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.DeleteApp" ::
                          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 DeleteApp where
  toJSON :: DeleteApp -> Value
toJSON DeleteApp' {Maybe Bool
Maybe Text
forceStopAppReplication :: Maybe Bool
appId :: Maybe Text
forceTerminateApp :: Maybe Bool
$sel:forceStopAppReplication:DeleteApp' :: DeleteApp -> Maybe Bool
$sel:appId:DeleteApp' :: DeleteApp -> Maybe Text
$sel:forceTerminateApp:DeleteApp' :: DeleteApp -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"forceTerminateApp" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
forceTerminateApp,
            (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,
            (Text
"forceStopAppReplication" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
forceStopAppReplication
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteAppResponse