{-# 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.ElasticBeanstalk.DeleteApplication
-- 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 along with all associated versions and
-- configurations. The application versions will not be deleted from your
-- Amazon S3 bucket.
--
-- You cannot delete an application that has a running environment.
module Amazonka.ElasticBeanstalk.DeleteApplication
  ( -- * Creating a Request
    DeleteApplication (..),
    newDeleteApplication,

    -- * Request Lenses
    deleteApplication_terminateEnvByForce,
    deleteApplication_applicationName,

    -- * Destructuring the Response
    DeleteApplicationResponse (..),
    newDeleteApplicationResponse,
  )
where

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

-- | Request to delete an application.
--
-- /See:/ 'newDeleteApplication' smart constructor.
data DeleteApplication = DeleteApplication'
  { -- | When set to true, running environments will be terminated before
    -- deleting the application.
    DeleteApplication -> Maybe Bool
terminateEnvByForce :: Prelude.Maybe Prelude.Bool,
    -- | The name of the application to delete.
    DeleteApplication -> Text
applicationName :: Prelude.Text
  }
  deriving (DeleteApplication -> DeleteApplication -> Bool
(DeleteApplication -> DeleteApplication -> Bool)
-> (DeleteApplication -> DeleteApplication -> Bool)
-> Eq DeleteApplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteApplication -> DeleteApplication -> Bool
$c/= :: DeleteApplication -> DeleteApplication -> Bool
== :: DeleteApplication -> DeleteApplication -> Bool
$c== :: DeleteApplication -> DeleteApplication -> Bool
Prelude.Eq, ReadPrec [DeleteApplication]
ReadPrec DeleteApplication
Int -> ReadS DeleteApplication
ReadS [DeleteApplication]
(Int -> ReadS DeleteApplication)
-> ReadS [DeleteApplication]
-> ReadPrec DeleteApplication
-> ReadPrec [DeleteApplication]
-> Read DeleteApplication
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteApplication]
$creadListPrec :: ReadPrec [DeleteApplication]
readPrec :: ReadPrec DeleteApplication
$creadPrec :: ReadPrec DeleteApplication
readList :: ReadS [DeleteApplication]
$creadList :: ReadS [DeleteApplication]
readsPrec :: Int -> ReadS DeleteApplication
$creadsPrec :: Int -> ReadS DeleteApplication
Prelude.Read, Int -> DeleteApplication -> ShowS
[DeleteApplication] -> ShowS
DeleteApplication -> String
(Int -> DeleteApplication -> ShowS)
-> (DeleteApplication -> String)
-> ([DeleteApplication] -> ShowS)
-> Show DeleteApplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteApplication] -> ShowS
$cshowList :: [DeleteApplication] -> ShowS
show :: DeleteApplication -> String
$cshow :: DeleteApplication -> String
showsPrec :: Int -> DeleteApplication -> ShowS
$cshowsPrec :: Int -> DeleteApplication -> ShowS
Prelude.Show, (forall x. DeleteApplication -> Rep DeleteApplication x)
-> (forall x. Rep DeleteApplication x -> DeleteApplication)
-> Generic DeleteApplication
forall x. Rep DeleteApplication x -> DeleteApplication
forall x. DeleteApplication -> Rep DeleteApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteApplication x -> DeleteApplication
$cfrom :: forall x. DeleteApplication -> Rep DeleteApplication x
Prelude.Generic)

-- |
-- Create a value of 'DeleteApplication' 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:
--
-- 'terminateEnvByForce', 'deleteApplication_terminateEnvByForce' - When set to true, running environments will be terminated before
-- deleting the application.
--
-- 'applicationName', 'deleteApplication_applicationName' - The name of the application to delete.
newDeleteApplication ::
  -- | 'applicationName'
  Prelude.Text ->
  DeleteApplication
newDeleteApplication :: Text -> DeleteApplication
newDeleteApplication Text
pApplicationName_ =
  DeleteApplication' :: Maybe Bool -> Text -> DeleteApplication
DeleteApplication'
    { $sel:terminateEnvByForce:DeleteApplication' :: Maybe Bool
terminateEnvByForce =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationName:DeleteApplication' :: Text
applicationName = Text
pApplicationName_
    }

-- | When set to true, running environments will be terminated before
-- deleting the application.
deleteApplication_terminateEnvByForce :: Lens.Lens' DeleteApplication (Prelude.Maybe Prelude.Bool)
deleteApplication_terminateEnvByForce :: (Maybe Bool -> f (Maybe Bool))
-> DeleteApplication -> f DeleteApplication
deleteApplication_terminateEnvByForce = (DeleteApplication -> Maybe Bool)
-> (DeleteApplication -> Maybe Bool -> DeleteApplication)
-> Lens
     DeleteApplication DeleteApplication (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApplication' {Maybe Bool
terminateEnvByForce :: Maybe Bool
$sel:terminateEnvByForce:DeleteApplication' :: DeleteApplication -> Maybe Bool
terminateEnvByForce} -> Maybe Bool
terminateEnvByForce) (\s :: DeleteApplication
s@DeleteApplication' {} Maybe Bool
a -> DeleteApplication
s {$sel:terminateEnvByForce:DeleteApplication' :: Maybe Bool
terminateEnvByForce = Maybe Bool
a} :: DeleteApplication)

-- | The name of the application to delete.
deleteApplication_applicationName :: Lens.Lens' DeleteApplication Prelude.Text
deleteApplication_applicationName :: (Text -> f Text) -> DeleteApplication -> f DeleteApplication
deleteApplication_applicationName = (DeleteApplication -> Text)
-> (DeleteApplication -> Text -> DeleteApplication)
-> Lens DeleteApplication DeleteApplication Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApplication' {Text
applicationName :: Text
$sel:applicationName:DeleteApplication' :: DeleteApplication -> Text
applicationName} -> Text
applicationName) (\s :: DeleteApplication
s@DeleteApplication' {} Text
a -> DeleteApplication
s {$sel:applicationName:DeleteApplication' :: Text
applicationName = Text
a} :: DeleteApplication)

instance Core.AWSRequest DeleteApplication where
  type
    AWSResponse DeleteApplication =
      DeleteApplicationResponse
  request :: DeleteApplication -> Request DeleteApplication
request = Service -> DeleteApplication -> Request DeleteApplication
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteApplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteApplication)))
response =
    AWSResponse DeleteApplication
-> Logger
-> Service
-> Proxy DeleteApplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteApplication)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteApplication
DeleteApplicationResponse
DeleteApplicationResponse'

instance Prelude.Hashable DeleteApplication

instance Prelude.NFData DeleteApplication

instance Core.ToHeaders DeleteApplication where
  toHeaders :: DeleteApplication -> [Header]
toHeaders = [Header] -> DeleteApplication -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery DeleteApplication where
  toQuery :: DeleteApplication -> QueryString
toQuery DeleteApplication' {Maybe Bool
Text
applicationName :: Text
terminateEnvByForce :: Maybe Bool
$sel:applicationName:DeleteApplication' :: DeleteApplication -> Text
$sel:terminateEnvByForce:DeleteApplication' :: DeleteApplication -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeleteApplication" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"TerminateEnvByForce" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
terminateEnvByForce,
        ByteString
"ApplicationName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
applicationName
      ]

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

-- |
-- Create a value of 'DeleteApplicationResponse' 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.
newDeleteApplicationResponse ::
  DeleteApplicationResponse
newDeleteApplicationResponse :: DeleteApplicationResponse
newDeleteApplicationResponse =
  DeleteApplicationResponse
DeleteApplicationResponse'

instance Prelude.NFData DeleteApplicationResponse