{-# 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.Proton.DeleteEnvironment
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Delete an environment.
module Amazonka.Proton.DeleteEnvironment
  ( -- * Creating a Request
    DeleteEnvironment (..),
    newDeleteEnvironment,

    -- * Request Lenses
    deleteEnvironment_name,

    -- * Destructuring the Response
    DeleteEnvironmentResponse (..),
    newDeleteEnvironmentResponse,

    -- * Response Lenses
    deleteEnvironmentResponse_environment,
    deleteEnvironmentResponse_httpStatus,
  )
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 Amazonka.Proton.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'DeleteEnvironment' 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:
--
-- 'name', 'deleteEnvironment_name' - The name of the environment to delete.
newDeleteEnvironment ::
  -- | 'name'
  Prelude.Text ->
  DeleteEnvironment
newDeleteEnvironment :: Text -> DeleteEnvironment
newDeleteEnvironment Text
pName_ =
  DeleteEnvironment' {$sel:name:DeleteEnvironment' :: Text
name = Text
pName_}

-- | The name of the environment to delete.
deleteEnvironment_name :: Lens.Lens' DeleteEnvironment Prelude.Text
deleteEnvironment_name :: Lens' DeleteEnvironment Text
deleteEnvironment_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEnvironment' {Text
name :: Text
$sel:name:DeleteEnvironment' :: DeleteEnvironment -> Text
name} -> Text
name) (\s :: DeleteEnvironment
s@DeleteEnvironment' {} Text
a -> DeleteEnvironment
s {$sel:name:DeleteEnvironment' :: Text
name = Text
a} :: DeleteEnvironment)

instance Core.AWSRequest DeleteEnvironment where
  type
    AWSResponse DeleteEnvironment =
      DeleteEnvironmentResponse
  request :: (Service -> Service)
-> DeleteEnvironment -> Request DeleteEnvironment
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 DeleteEnvironment
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEnvironment)))
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 ->
          Maybe Environment -> Int -> DeleteEnvironmentResponse
DeleteEnvironmentResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"environment")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable DeleteEnvironment where
  hashWithSalt :: Int -> DeleteEnvironment -> Int
hashWithSalt Int
_salt DeleteEnvironment' {Text
name :: Text
$sel:name:DeleteEnvironment' :: DeleteEnvironment -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DeleteEnvironment where
  rnf :: DeleteEnvironment -> ()
rnf DeleteEnvironment' {Text
name :: Text
$sel:name:DeleteEnvironment' :: DeleteEnvironment -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders DeleteEnvironment where
  toHeaders :: DeleteEnvironment -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AwsProton20200720.DeleteEnvironment" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteEnvironment where
  toJSON :: DeleteEnvironment -> Value
toJSON DeleteEnvironment' {Text
name :: Text
$sel:name:DeleteEnvironment' :: DeleteEnvironment -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)]
      )

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

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

-- | /See:/ 'newDeleteEnvironmentResponse' smart constructor.
data DeleteEnvironmentResponse = DeleteEnvironmentResponse'
  { -- | The detailed data of the environment being deleted.
    DeleteEnvironmentResponse -> Maybe Environment
environment :: Prelude.Maybe Environment,
    -- | The response's http status code.
    DeleteEnvironmentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteEnvironmentResponse -> DeleteEnvironmentResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEnvironmentResponse -> DeleteEnvironmentResponse -> Bool
$c/= :: DeleteEnvironmentResponse -> DeleteEnvironmentResponse -> Bool
== :: DeleteEnvironmentResponse -> DeleteEnvironmentResponse -> Bool
$c== :: DeleteEnvironmentResponse -> DeleteEnvironmentResponse -> Bool
Prelude.Eq, Int -> DeleteEnvironmentResponse -> ShowS
[DeleteEnvironmentResponse] -> ShowS
DeleteEnvironmentResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEnvironmentResponse] -> ShowS
$cshowList :: [DeleteEnvironmentResponse] -> ShowS
show :: DeleteEnvironmentResponse -> String
$cshow :: DeleteEnvironmentResponse -> String
showsPrec :: Int -> DeleteEnvironmentResponse -> ShowS
$cshowsPrec :: Int -> DeleteEnvironmentResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteEnvironmentResponse x -> DeleteEnvironmentResponse
forall x.
DeleteEnvironmentResponse -> Rep DeleteEnvironmentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteEnvironmentResponse x -> DeleteEnvironmentResponse
$cfrom :: forall x.
DeleteEnvironmentResponse -> Rep DeleteEnvironmentResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEnvironmentResponse' 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:
--
-- 'environment', 'deleteEnvironmentResponse_environment' - The detailed data of the environment being deleted.
--
-- 'httpStatus', 'deleteEnvironmentResponse_httpStatus' - The response's http status code.
newDeleteEnvironmentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteEnvironmentResponse
newDeleteEnvironmentResponse :: Int -> DeleteEnvironmentResponse
newDeleteEnvironmentResponse Int
pHttpStatus_ =
  DeleteEnvironmentResponse'
    { $sel:environment:DeleteEnvironmentResponse' :: Maybe Environment
environment =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteEnvironmentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The detailed data of the environment being deleted.
deleteEnvironmentResponse_environment :: Lens.Lens' DeleteEnvironmentResponse (Prelude.Maybe Environment)
deleteEnvironmentResponse_environment :: Lens' DeleteEnvironmentResponse (Maybe Environment)
deleteEnvironmentResponse_environment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEnvironmentResponse' {Maybe Environment
environment :: Maybe Environment
$sel:environment:DeleteEnvironmentResponse' :: DeleteEnvironmentResponse -> Maybe Environment
environment} -> Maybe Environment
environment) (\s :: DeleteEnvironmentResponse
s@DeleteEnvironmentResponse' {} Maybe Environment
a -> DeleteEnvironmentResponse
s {$sel:environment:DeleteEnvironmentResponse' :: Maybe Environment
environment = Maybe Environment
a} :: DeleteEnvironmentResponse)

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

instance Prelude.NFData DeleteEnvironmentResponse where
  rnf :: DeleteEnvironmentResponse -> ()
rnf DeleteEnvironmentResponse' {Int
Maybe Environment
httpStatus :: Int
environment :: Maybe Environment
$sel:httpStatus:DeleteEnvironmentResponse' :: DeleteEnvironmentResponse -> Int
$sel:environment:DeleteEnvironmentResponse' :: DeleteEnvironmentResponse -> Maybe Environment
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Environment
environment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus