{-# 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.DeleteEnvironmentTemplate
-- 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)
--
-- If no other major or minor versions of an environment template exist,
-- delete the environment template.
module Amazonka.Proton.DeleteEnvironmentTemplate
  ( -- * Creating a Request
    DeleteEnvironmentTemplate (..),
    newDeleteEnvironmentTemplate,

    -- * Request Lenses
    deleteEnvironmentTemplate_name,

    -- * Destructuring the Response
    DeleteEnvironmentTemplateResponse (..),
    newDeleteEnvironmentTemplateResponse,

    -- * Response Lenses
    deleteEnvironmentTemplateResponse_environmentTemplate,
    deleteEnvironmentTemplateResponse_httpStatus,
  )
where

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

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

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

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

instance Core.AWSRequest DeleteEnvironmentTemplate where
  type
    AWSResponse DeleteEnvironmentTemplate =
      DeleteEnvironmentTemplateResponse
  request :: DeleteEnvironmentTemplate -> Request DeleteEnvironmentTemplate
request = Service
-> DeleteEnvironmentTemplate -> Request DeleteEnvironmentTemplate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteEnvironmentTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEnvironmentTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteEnvironmentTemplate))
-> Logger
-> Service
-> Proxy DeleteEnvironmentTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteEnvironmentTemplate)))
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 ->
          Maybe EnvironmentTemplate
-> Int -> DeleteEnvironmentTemplateResponse
DeleteEnvironmentTemplateResponse'
            (Maybe EnvironmentTemplate
 -> Int -> DeleteEnvironmentTemplateResponse)
-> Either String (Maybe EnvironmentTemplate)
-> Either String (Int -> DeleteEnvironmentTemplateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe EnvironmentTemplate)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"environmentTemplate")
            Either String (Int -> DeleteEnvironmentTemplateResponse)
-> Either String Int
-> Either String DeleteEnvironmentTemplateResponse
forall (f :: * -> *) a b. Applicative f => 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 DeleteEnvironmentTemplate

instance Prelude.NFData DeleteEnvironmentTemplate

instance Core.ToHeaders DeleteEnvironmentTemplate where
  toHeaders :: DeleteEnvironmentTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteEnvironmentTemplate -> 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
"AwsProton20200720.DeleteEnvironmentTemplate" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

-- | /See:/ 'newDeleteEnvironmentTemplateResponse' smart constructor.
data DeleteEnvironmentTemplateResponse = DeleteEnvironmentTemplateResponse'
  { -- | The environment template detail data that\'s returned by AWS Proton.
    DeleteEnvironmentTemplateResponse -> Maybe EnvironmentTemplate
environmentTemplate :: Prelude.Maybe EnvironmentTemplate,
    -- | The response's http status code.
    DeleteEnvironmentTemplateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteEnvironmentTemplateResponse
-> DeleteEnvironmentTemplateResponse -> Bool
(DeleteEnvironmentTemplateResponse
 -> DeleteEnvironmentTemplateResponse -> Bool)
-> (DeleteEnvironmentTemplateResponse
    -> DeleteEnvironmentTemplateResponse -> Bool)
-> Eq DeleteEnvironmentTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEnvironmentTemplateResponse
-> DeleteEnvironmentTemplateResponse -> Bool
$c/= :: DeleteEnvironmentTemplateResponse
-> DeleteEnvironmentTemplateResponse -> Bool
== :: DeleteEnvironmentTemplateResponse
-> DeleteEnvironmentTemplateResponse -> Bool
$c== :: DeleteEnvironmentTemplateResponse
-> DeleteEnvironmentTemplateResponse -> Bool
Prelude.Eq, Int -> DeleteEnvironmentTemplateResponse -> ShowS
[DeleteEnvironmentTemplateResponse] -> ShowS
DeleteEnvironmentTemplateResponse -> String
(Int -> DeleteEnvironmentTemplateResponse -> ShowS)
-> (DeleteEnvironmentTemplateResponse -> String)
-> ([DeleteEnvironmentTemplateResponse] -> ShowS)
-> Show DeleteEnvironmentTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEnvironmentTemplateResponse] -> ShowS
$cshowList :: [DeleteEnvironmentTemplateResponse] -> ShowS
show :: DeleteEnvironmentTemplateResponse -> String
$cshow :: DeleteEnvironmentTemplateResponse -> String
showsPrec :: Int -> DeleteEnvironmentTemplateResponse -> ShowS
$cshowsPrec :: Int -> DeleteEnvironmentTemplateResponse -> ShowS
Prelude.Show, (forall x.
 DeleteEnvironmentTemplateResponse
 -> Rep DeleteEnvironmentTemplateResponse x)
-> (forall x.
    Rep DeleteEnvironmentTemplateResponse x
    -> DeleteEnvironmentTemplateResponse)
-> Generic DeleteEnvironmentTemplateResponse
forall x.
Rep DeleteEnvironmentTemplateResponse x
-> DeleteEnvironmentTemplateResponse
forall x.
DeleteEnvironmentTemplateResponse
-> Rep DeleteEnvironmentTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteEnvironmentTemplateResponse x
-> DeleteEnvironmentTemplateResponse
$cfrom :: forall x.
DeleteEnvironmentTemplateResponse
-> Rep DeleteEnvironmentTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEnvironmentTemplateResponse' 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:
--
-- 'environmentTemplate', 'deleteEnvironmentTemplateResponse_environmentTemplate' - The environment template detail data that\'s returned by AWS Proton.
--
-- 'httpStatus', 'deleteEnvironmentTemplateResponse_httpStatus' - The response's http status code.
newDeleteEnvironmentTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteEnvironmentTemplateResponse
newDeleteEnvironmentTemplateResponse :: Int -> DeleteEnvironmentTemplateResponse
newDeleteEnvironmentTemplateResponse Int
pHttpStatus_ =
  DeleteEnvironmentTemplateResponse' :: Maybe EnvironmentTemplate
-> Int -> DeleteEnvironmentTemplateResponse
DeleteEnvironmentTemplateResponse'
    { $sel:environmentTemplate:DeleteEnvironmentTemplateResponse' :: Maybe EnvironmentTemplate
environmentTemplate =
        Maybe EnvironmentTemplate
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteEnvironmentTemplateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The environment template detail data that\'s returned by AWS Proton.
deleteEnvironmentTemplateResponse_environmentTemplate :: Lens.Lens' DeleteEnvironmentTemplateResponse (Prelude.Maybe EnvironmentTemplate)
deleteEnvironmentTemplateResponse_environmentTemplate :: (Maybe EnvironmentTemplate -> f (Maybe EnvironmentTemplate))
-> DeleteEnvironmentTemplateResponse
-> f DeleteEnvironmentTemplateResponse
deleteEnvironmentTemplateResponse_environmentTemplate = (DeleteEnvironmentTemplateResponse -> Maybe EnvironmentTemplate)
-> (DeleteEnvironmentTemplateResponse
    -> Maybe EnvironmentTemplate -> DeleteEnvironmentTemplateResponse)
-> Lens
     DeleteEnvironmentTemplateResponse
     DeleteEnvironmentTemplateResponse
     (Maybe EnvironmentTemplate)
     (Maybe EnvironmentTemplate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEnvironmentTemplateResponse' {Maybe EnvironmentTemplate
environmentTemplate :: Maybe EnvironmentTemplate
$sel:environmentTemplate:DeleteEnvironmentTemplateResponse' :: DeleteEnvironmentTemplateResponse -> Maybe EnvironmentTemplate
environmentTemplate} -> Maybe EnvironmentTemplate
environmentTemplate) (\s :: DeleteEnvironmentTemplateResponse
s@DeleteEnvironmentTemplateResponse' {} Maybe EnvironmentTemplate
a -> DeleteEnvironmentTemplateResponse
s {$sel:environmentTemplate:DeleteEnvironmentTemplateResponse' :: Maybe EnvironmentTemplate
environmentTemplate = Maybe EnvironmentTemplate
a} :: DeleteEnvironmentTemplateResponse)

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

instance
  Prelude.NFData
    DeleteEnvironmentTemplateResponse