{-# 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.ResilienceHub.DeleteApp
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes an AWS Resilience Hub application. This is a destructive action
-- that can\'t be undone.
module Amazonka.ResilienceHub.DeleteApp
  ( -- * Creating a Request
    DeleteApp (..),
    newDeleteApp,

    -- * Request Lenses
    deleteApp_clientToken,
    deleteApp_forceDelete,
    deleteApp_appArn,

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

    -- * Response Lenses
    deleteAppResponse_httpStatus,
    deleteAppResponse_appArn,
  )
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 Amazonka.ResilienceHub.Types
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteApp' smart constructor.
data DeleteApp = DeleteApp'
  { -- | Used for an idempotency token. A client token is a unique,
    -- case-sensitive string of up to 64 ASCII characters. You should not reuse
    -- the same client token for other API requests.
    DeleteApp -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | A boolean option to force the deletion of a Resilience Hub application.
    DeleteApp -> Maybe Bool
forceDelete :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) of the application. The format for this
    -- ARN is: arn:@partition@:resiliencehub:@region@:@account@:app\/@app-id@.
    -- For more information about ARNs, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- in the /AWS General Reference/.
    DeleteApp -> Text
appArn :: Prelude.Text
  }
  deriving (DeleteApp -> DeleteApp -> Bool
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]
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
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. 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:
--
-- 'clientToken', 'deleteApp_clientToken' - Used for an idempotency token. A client token is a unique,
-- case-sensitive string of up to 64 ASCII characters. You should not reuse
-- the same client token for other API requests.
--
-- 'forceDelete', 'deleteApp_forceDelete' - A boolean option to force the deletion of a Resilience Hub application.
--
-- 'appArn', 'deleteApp_appArn' - The Amazon Resource Name (ARN) of the application. The format for this
-- ARN is: arn:@partition@:resiliencehub:@region@:@account@:app\/@app-id@.
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /AWS General Reference/.
newDeleteApp ::
  -- | 'appArn'
  Prelude.Text ->
  DeleteApp
newDeleteApp :: Text -> DeleteApp
newDeleteApp Text
pAppArn_ =
  DeleteApp'
    { $sel:clientToken:DeleteApp' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:forceDelete:DeleteApp' :: Maybe Bool
forceDelete = forall a. Maybe a
Prelude.Nothing,
      $sel:appArn:DeleteApp' :: Text
appArn = Text
pAppArn_
    }

-- | Used for an idempotency token. A client token is a unique,
-- case-sensitive string of up to 64 ASCII characters. You should not reuse
-- the same client token for other API requests.
deleteApp_clientToken :: Lens.Lens' DeleteApp (Prelude.Maybe Prelude.Text)
deleteApp_clientToken :: Lens' DeleteApp (Maybe Text)
deleteApp_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApp' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DeleteApp' :: DeleteApp -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DeleteApp
s@DeleteApp' {} Maybe Text
a -> DeleteApp
s {$sel:clientToken:DeleteApp' :: Maybe Text
clientToken = Maybe Text
a} :: DeleteApp)

-- | A boolean option to force the deletion of a Resilience Hub application.
deleteApp_forceDelete :: Lens.Lens' DeleteApp (Prelude.Maybe Prelude.Bool)
deleteApp_forceDelete :: Lens' DeleteApp (Maybe Bool)
deleteApp_forceDelete = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApp' {Maybe Bool
forceDelete :: Maybe Bool
$sel:forceDelete:DeleteApp' :: DeleteApp -> Maybe Bool
forceDelete} -> Maybe Bool
forceDelete) (\s :: DeleteApp
s@DeleteApp' {} Maybe Bool
a -> DeleteApp
s {$sel:forceDelete:DeleteApp' :: Maybe Bool
forceDelete = Maybe Bool
a} :: DeleteApp)

-- | The Amazon Resource Name (ARN) of the application. The format for this
-- ARN is: arn:@partition@:resiliencehub:@region@:@account@:app\/@app-id@.
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /AWS General Reference/.
deleteApp_appArn :: Lens.Lens' DeleteApp Prelude.Text
deleteApp_appArn :: Lens' DeleteApp Text
deleteApp_appArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApp' {Text
appArn :: Text
$sel:appArn:DeleteApp' :: DeleteApp -> Text
appArn} -> Text
appArn) (\s :: DeleteApp
s@DeleteApp' {} Text
a -> DeleteApp
s {$sel:appArn:DeleteApp' :: Text
appArn = Text
a} :: DeleteApp)

instance Core.AWSRequest DeleteApp where
  type AWSResponse DeleteApp = DeleteAppResponse
  request :: (Service -> Service) -> DeleteApp -> Request DeleteApp
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 DeleteApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteApp)))
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 ->
          Int -> Text -> DeleteAppResponse
DeleteAppResponse'
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"appArn")
      )

instance Prelude.Hashable DeleteApp where
  hashWithSalt :: Int -> DeleteApp -> Int
hashWithSalt Int
_salt DeleteApp' {Maybe Bool
Maybe Text
Text
appArn :: Text
forceDelete :: Maybe Bool
clientToken :: Maybe Text
$sel:appArn:DeleteApp' :: DeleteApp -> Text
$sel:forceDelete:DeleteApp' :: DeleteApp -> Maybe Bool
$sel:clientToken:DeleteApp' :: DeleteApp -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
forceDelete
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appArn

instance Prelude.NFData DeleteApp where
  rnf :: DeleteApp -> ()
rnf DeleteApp' {Maybe Bool
Maybe Text
Text
appArn :: Text
forceDelete :: Maybe Bool
clientToken :: Maybe Text
$sel:appArn:DeleteApp' :: DeleteApp -> Text
$sel:forceDelete:DeleteApp' :: DeleteApp -> Maybe Bool
$sel:clientToken:DeleteApp' :: DeleteApp -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
forceDelete
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
appArn

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

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

instance Data.ToQuery DeleteApp where
  toQuery :: DeleteApp -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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,
    -- | The Amazon Resource Name (ARN) of the application. The format for this
    -- ARN is: arn:@partition@:resiliencehub:@region@:@account@:app\/@app-id@.
    -- For more information about ARNs, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- in the /AWS General Reference/.
    DeleteAppResponse -> Text
appArn :: Prelude.Text
  }
  deriving (DeleteAppResponse -> DeleteAppResponse -> Bool
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]
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
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. 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.
--
-- 'appArn', 'deleteAppResponse_appArn' - The Amazon Resource Name (ARN) of the application. The format for this
-- ARN is: arn:@partition@:resiliencehub:@region@:@account@:app\/@app-id@.
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /AWS General Reference/.
newDeleteAppResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'appArn'
  Prelude.Text ->
  DeleteAppResponse
newDeleteAppResponse :: Int -> Text -> DeleteAppResponse
newDeleteAppResponse Int
pHttpStatus_ Text
pAppArn_ =
  DeleteAppResponse'
    { $sel:httpStatus:DeleteAppResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:appArn:DeleteAppResponse' :: Text
appArn = Text
pAppArn_
    }

-- | The response's http status code.
deleteAppResponse_httpStatus :: Lens.Lens' DeleteAppResponse Prelude.Int
deleteAppResponse_httpStatus :: Lens' DeleteAppResponse Int
deleteAppResponse_httpStatus = 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)

-- | The Amazon Resource Name (ARN) of the application. The format for this
-- ARN is: arn:@partition@:resiliencehub:@region@:@account@:app\/@app-id@.
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the /AWS General Reference/.
deleteAppResponse_appArn :: Lens.Lens' DeleteAppResponse Prelude.Text
deleteAppResponse_appArn :: Lens' DeleteAppResponse Text
deleteAppResponse_appArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAppResponse' {Text
appArn :: Text
$sel:appArn:DeleteAppResponse' :: DeleteAppResponse -> Text
appArn} -> Text
appArn) (\s :: DeleteAppResponse
s@DeleteAppResponse' {} Text
a -> DeleteAppResponse
s {$sel:appArn:DeleteAppResponse' :: Text
appArn = Text
a} :: DeleteAppResponse)

instance Prelude.NFData DeleteAppResponse where
  rnf :: DeleteAppResponse -> ()
rnf DeleteAppResponse' {Int
Text
appArn :: Text
httpStatus :: Int
$sel:appArn:DeleteAppResponse' :: DeleteAppResponse -> Text
$sel:httpStatus:DeleteAppResponse' :: DeleteAppResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
appArn