{-# 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.Amplify.DeleteBackendEnvironment
-- 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 a backend environment for an Amplify app.
module Amazonka.Amplify.DeleteBackendEnvironment
  ( -- * Creating a Request
    DeleteBackendEnvironment (..),
    newDeleteBackendEnvironment,

    -- * Request Lenses
    deleteBackendEnvironment_appId,
    deleteBackendEnvironment_environmentName,

    -- * Destructuring the Response
    DeleteBackendEnvironmentResponse (..),
    newDeleteBackendEnvironmentResponse,

    -- * Response Lenses
    deleteBackendEnvironmentResponse_httpStatus,
    deleteBackendEnvironmentResponse_backendEnvironment,
  )
where

import Amazonka.Amplify.Types
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

-- | The request structure for the delete backend environment request.
--
-- /See:/ 'newDeleteBackendEnvironment' smart constructor.
data DeleteBackendEnvironment = DeleteBackendEnvironment'
  { -- | The unique ID of an Amplify app.
    DeleteBackendEnvironment -> Text
appId :: Prelude.Text,
    -- | The name of a backend environment of an Amplify app.
    DeleteBackendEnvironment -> Text
environmentName :: Prelude.Text
  }
  deriving (DeleteBackendEnvironment -> DeleteBackendEnvironment -> Bool
(DeleteBackendEnvironment -> DeleteBackendEnvironment -> Bool)
-> (DeleteBackendEnvironment -> DeleteBackendEnvironment -> Bool)
-> Eq DeleteBackendEnvironment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBackendEnvironment -> DeleteBackendEnvironment -> Bool
$c/= :: DeleteBackendEnvironment -> DeleteBackendEnvironment -> Bool
== :: DeleteBackendEnvironment -> DeleteBackendEnvironment -> Bool
$c== :: DeleteBackendEnvironment -> DeleteBackendEnvironment -> Bool
Prelude.Eq, ReadPrec [DeleteBackendEnvironment]
ReadPrec DeleteBackendEnvironment
Int -> ReadS DeleteBackendEnvironment
ReadS [DeleteBackendEnvironment]
(Int -> ReadS DeleteBackendEnvironment)
-> ReadS [DeleteBackendEnvironment]
-> ReadPrec DeleteBackendEnvironment
-> ReadPrec [DeleteBackendEnvironment]
-> Read DeleteBackendEnvironment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBackendEnvironment]
$creadListPrec :: ReadPrec [DeleteBackendEnvironment]
readPrec :: ReadPrec DeleteBackendEnvironment
$creadPrec :: ReadPrec DeleteBackendEnvironment
readList :: ReadS [DeleteBackendEnvironment]
$creadList :: ReadS [DeleteBackendEnvironment]
readsPrec :: Int -> ReadS DeleteBackendEnvironment
$creadsPrec :: Int -> ReadS DeleteBackendEnvironment
Prelude.Read, Int -> DeleteBackendEnvironment -> ShowS
[DeleteBackendEnvironment] -> ShowS
DeleteBackendEnvironment -> String
(Int -> DeleteBackendEnvironment -> ShowS)
-> (DeleteBackendEnvironment -> String)
-> ([DeleteBackendEnvironment] -> ShowS)
-> Show DeleteBackendEnvironment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBackendEnvironment] -> ShowS
$cshowList :: [DeleteBackendEnvironment] -> ShowS
show :: DeleteBackendEnvironment -> String
$cshow :: DeleteBackendEnvironment -> String
showsPrec :: Int -> DeleteBackendEnvironment -> ShowS
$cshowsPrec :: Int -> DeleteBackendEnvironment -> ShowS
Prelude.Show, (forall x.
 DeleteBackendEnvironment -> Rep DeleteBackendEnvironment x)
-> (forall x.
    Rep DeleteBackendEnvironment x -> DeleteBackendEnvironment)
-> Generic DeleteBackendEnvironment
forall x.
Rep DeleteBackendEnvironment x -> DeleteBackendEnvironment
forall x.
DeleteBackendEnvironment -> Rep DeleteBackendEnvironment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteBackendEnvironment x -> DeleteBackendEnvironment
$cfrom :: forall x.
DeleteBackendEnvironment -> Rep DeleteBackendEnvironment x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBackendEnvironment' 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', 'deleteBackendEnvironment_appId' - The unique ID of an Amplify app.
--
-- 'environmentName', 'deleteBackendEnvironment_environmentName' - The name of a backend environment of an Amplify app.
newDeleteBackendEnvironment ::
  -- | 'appId'
  Prelude.Text ->
  -- | 'environmentName'
  Prelude.Text ->
  DeleteBackendEnvironment
newDeleteBackendEnvironment :: Text -> Text -> DeleteBackendEnvironment
newDeleteBackendEnvironment Text
pAppId_ Text
pEnvironmentName_ =
  DeleteBackendEnvironment' :: Text -> Text -> DeleteBackendEnvironment
DeleteBackendEnvironment'
    { $sel:appId:DeleteBackendEnvironment' :: Text
appId = Text
pAppId_,
      $sel:environmentName:DeleteBackendEnvironment' :: Text
environmentName = Text
pEnvironmentName_
    }

-- | The unique ID of an Amplify app.
deleteBackendEnvironment_appId :: Lens.Lens' DeleteBackendEnvironment Prelude.Text
deleteBackendEnvironment_appId :: (Text -> f Text)
-> DeleteBackendEnvironment -> f DeleteBackendEnvironment
deleteBackendEnvironment_appId = (DeleteBackendEnvironment -> Text)
-> (DeleteBackendEnvironment -> Text -> DeleteBackendEnvironment)
-> Lens DeleteBackendEnvironment DeleteBackendEnvironment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBackendEnvironment' {Text
appId :: Text
$sel:appId:DeleteBackendEnvironment' :: DeleteBackendEnvironment -> Text
appId} -> Text
appId) (\s :: DeleteBackendEnvironment
s@DeleteBackendEnvironment' {} Text
a -> DeleteBackendEnvironment
s {$sel:appId:DeleteBackendEnvironment' :: Text
appId = Text
a} :: DeleteBackendEnvironment)

-- | The name of a backend environment of an Amplify app.
deleteBackendEnvironment_environmentName :: Lens.Lens' DeleteBackendEnvironment Prelude.Text
deleteBackendEnvironment_environmentName :: (Text -> f Text)
-> DeleteBackendEnvironment -> f DeleteBackendEnvironment
deleteBackendEnvironment_environmentName = (DeleteBackendEnvironment -> Text)
-> (DeleteBackendEnvironment -> Text -> DeleteBackendEnvironment)
-> Lens DeleteBackendEnvironment DeleteBackendEnvironment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBackendEnvironment' {Text
environmentName :: Text
$sel:environmentName:DeleteBackendEnvironment' :: DeleteBackendEnvironment -> Text
environmentName} -> Text
environmentName) (\s :: DeleteBackendEnvironment
s@DeleteBackendEnvironment' {} Text
a -> DeleteBackendEnvironment
s {$sel:environmentName:DeleteBackendEnvironment' :: Text
environmentName = Text
a} :: DeleteBackendEnvironment)

instance Core.AWSRequest DeleteBackendEnvironment where
  type
    AWSResponse DeleteBackendEnvironment =
      DeleteBackendEnvironmentResponse
  request :: DeleteBackendEnvironment -> Request DeleteBackendEnvironment
request = Service
-> DeleteBackendEnvironment -> Request DeleteBackendEnvironment
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteBackendEnvironment
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteBackendEnvironment)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteBackendEnvironment))
-> Logger
-> Service
-> Proxy DeleteBackendEnvironment
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteBackendEnvironment)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> BackendEnvironment -> DeleteBackendEnvironmentResponse
DeleteBackendEnvironmentResponse'
            (Int -> BackendEnvironment -> DeleteBackendEnvironmentResponse)
-> Either String Int
-> Either
     String (BackendEnvironment -> DeleteBackendEnvironmentResponse)
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))
            Either
  String (BackendEnvironment -> DeleteBackendEnvironmentResponse)
-> Either String BackendEnvironment
-> Either String DeleteBackendEnvironmentResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String BackendEnvironment
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"backendEnvironment")
      )

instance Prelude.Hashable DeleteBackendEnvironment

instance Prelude.NFData DeleteBackendEnvironment

instance Core.ToHeaders DeleteBackendEnvironment where
  toHeaders :: DeleteBackendEnvironment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteBackendEnvironment -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DeleteBackendEnvironment where
  toPath :: DeleteBackendEnvironment -> ByteString
toPath DeleteBackendEnvironment' {Text
environmentName :: Text
appId :: Text
$sel:environmentName:DeleteBackendEnvironment' :: DeleteBackendEnvironment -> Text
$sel:appId:DeleteBackendEnvironment' :: DeleteBackendEnvironment -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/apps/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
appId,
        ByteString
"/backendenvironments/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
environmentName
      ]

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

-- | The result structure of the delete backend environment result.
--
-- /See:/ 'newDeleteBackendEnvironmentResponse' smart constructor.
data DeleteBackendEnvironmentResponse = DeleteBackendEnvironmentResponse'
  { -- | The response's http status code.
    DeleteBackendEnvironmentResponse -> Int
httpStatus :: Prelude.Int,
    -- | Describes the backend environment for an Amplify app.
    DeleteBackendEnvironmentResponse -> BackendEnvironment
backendEnvironment :: BackendEnvironment
  }
  deriving (DeleteBackendEnvironmentResponse
-> DeleteBackendEnvironmentResponse -> Bool
(DeleteBackendEnvironmentResponse
 -> DeleteBackendEnvironmentResponse -> Bool)
-> (DeleteBackendEnvironmentResponse
    -> DeleteBackendEnvironmentResponse -> Bool)
-> Eq DeleteBackendEnvironmentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBackendEnvironmentResponse
-> DeleteBackendEnvironmentResponse -> Bool
$c/= :: DeleteBackendEnvironmentResponse
-> DeleteBackendEnvironmentResponse -> Bool
== :: DeleteBackendEnvironmentResponse
-> DeleteBackendEnvironmentResponse -> Bool
$c== :: DeleteBackendEnvironmentResponse
-> DeleteBackendEnvironmentResponse -> Bool
Prelude.Eq, ReadPrec [DeleteBackendEnvironmentResponse]
ReadPrec DeleteBackendEnvironmentResponse
Int -> ReadS DeleteBackendEnvironmentResponse
ReadS [DeleteBackendEnvironmentResponse]
(Int -> ReadS DeleteBackendEnvironmentResponse)
-> ReadS [DeleteBackendEnvironmentResponse]
-> ReadPrec DeleteBackendEnvironmentResponse
-> ReadPrec [DeleteBackendEnvironmentResponse]
-> Read DeleteBackendEnvironmentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBackendEnvironmentResponse]
$creadListPrec :: ReadPrec [DeleteBackendEnvironmentResponse]
readPrec :: ReadPrec DeleteBackendEnvironmentResponse
$creadPrec :: ReadPrec DeleteBackendEnvironmentResponse
readList :: ReadS [DeleteBackendEnvironmentResponse]
$creadList :: ReadS [DeleteBackendEnvironmentResponse]
readsPrec :: Int -> ReadS DeleteBackendEnvironmentResponse
$creadsPrec :: Int -> ReadS DeleteBackendEnvironmentResponse
Prelude.Read, Int -> DeleteBackendEnvironmentResponse -> ShowS
[DeleteBackendEnvironmentResponse] -> ShowS
DeleteBackendEnvironmentResponse -> String
(Int -> DeleteBackendEnvironmentResponse -> ShowS)
-> (DeleteBackendEnvironmentResponse -> String)
-> ([DeleteBackendEnvironmentResponse] -> ShowS)
-> Show DeleteBackendEnvironmentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBackendEnvironmentResponse] -> ShowS
$cshowList :: [DeleteBackendEnvironmentResponse] -> ShowS
show :: DeleteBackendEnvironmentResponse -> String
$cshow :: DeleteBackendEnvironmentResponse -> String
showsPrec :: Int -> DeleteBackendEnvironmentResponse -> ShowS
$cshowsPrec :: Int -> DeleteBackendEnvironmentResponse -> ShowS
Prelude.Show, (forall x.
 DeleteBackendEnvironmentResponse
 -> Rep DeleteBackendEnvironmentResponse x)
-> (forall x.
    Rep DeleteBackendEnvironmentResponse x
    -> DeleteBackendEnvironmentResponse)
-> Generic DeleteBackendEnvironmentResponse
forall x.
Rep DeleteBackendEnvironmentResponse x
-> DeleteBackendEnvironmentResponse
forall x.
DeleteBackendEnvironmentResponse
-> Rep DeleteBackendEnvironmentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteBackendEnvironmentResponse x
-> DeleteBackendEnvironmentResponse
$cfrom :: forall x.
DeleteBackendEnvironmentResponse
-> Rep DeleteBackendEnvironmentResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBackendEnvironmentResponse' 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', 'deleteBackendEnvironmentResponse_httpStatus' - The response's http status code.
--
-- 'backendEnvironment', 'deleteBackendEnvironmentResponse_backendEnvironment' - Describes the backend environment for an Amplify app.
newDeleteBackendEnvironmentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'backendEnvironment'
  BackendEnvironment ->
  DeleteBackendEnvironmentResponse
newDeleteBackendEnvironmentResponse :: Int -> BackendEnvironment -> DeleteBackendEnvironmentResponse
newDeleteBackendEnvironmentResponse
  Int
pHttpStatus_
  BackendEnvironment
pBackendEnvironment_ =
    DeleteBackendEnvironmentResponse' :: Int -> BackendEnvironment -> DeleteBackendEnvironmentResponse
DeleteBackendEnvironmentResponse'
      { $sel:httpStatus:DeleteBackendEnvironmentResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:backendEnvironment:DeleteBackendEnvironmentResponse' :: BackendEnvironment
backendEnvironment = BackendEnvironment
pBackendEnvironment_
      }

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

-- | Describes the backend environment for an Amplify app.
deleteBackendEnvironmentResponse_backendEnvironment :: Lens.Lens' DeleteBackendEnvironmentResponse BackendEnvironment
deleteBackendEnvironmentResponse_backendEnvironment :: (BackendEnvironment -> f BackendEnvironment)
-> DeleteBackendEnvironmentResponse
-> f DeleteBackendEnvironmentResponse
deleteBackendEnvironmentResponse_backendEnvironment = (DeleteBackendEnvironmentResponse -> BackendEnvironment)
-> (DeleteBackendEnvironmentResponse
    -> BackendEnvironment -> DeleteBackendEnvironmentResponse)
-> Lens
     DeleteBackendEnvironmentResponse
     DeleteBackendEnvironmentResponse
     BackendEnvironment
     BackendEnvironment
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBackendEnvironmentResponse' {BackendEnvironment
backendEnvironment :: BackendEnvironment
$sel:backendEnvironment:DeleteBackendEnvironmentResponse' :: DeleteBackendEnvironmentResponse -> BackendEnvironment
backendEnvironment} -> BackendEnvironment
backendEnvironment) (\s :: DeleteBackendEnvironmentResponse
s@DeleteBackendEnvironmentResponse' {} BackendEnvironment
a -> DeleteBackendEnvironmentResponse
s {$sel:backendEnvironment:DeleteBackendEnvironmentResponse' :: BackendEnvironment
backendEnvironment = BackendEnvironment
a} :: DeleteBackendEnvironmentResponse)

instance
  Prelude.NFData
    DeleteBackendEnvironmentResponse