{-# 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.DeleteServiceTemplate
-- 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 the service template exist,
-- delete the service template.
module Amazonka.Proton.DeleteServiceTemplate
  ( -- * Creating a Request
    DeleteServiceTemplate (..),
    newDeleteServiceTemplate,

    -- * Request Lenses
    deleteServiceTemplate_name,

    -- * Destructuring the Response
    DeleteServiceTemplateResponse (..),
    newDeleteServiceTemplateResponse,

    -- * Response Lenses
    deleteServiceTemplateResponse_serviceTemplate,
    deleteServiceTemplateResponse_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:/ 'newDeleteServiceTemplate' smart constructor.
data DeleteServiceTemplate = DeleteServiceTemplate'
  { -- | The name of the service template to delete.
    DeleteServiceTemplate -> Text
name :: Prelude.Text
  }
  deriving (DeleteServiceTemplate -> DeleteServiceTemplate -> Bool
(DeleteServiceTemplate -> DeleteServiceTemplate -> Bool)
-> (DeleteServiceTemplate -> DeleteServiceTemplate -> Bool)
-> Eq DeleteServiceTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteServiceTemplate -> DeleteServiceTemplate -> Bool
$c/= :: DeleteServiceTemplate -> DeleteServiceTemplate -> Bool
== :: DeleteServiceTemplate -> DeleteServiceTemplate -> Bool
$c== :: DeleteServiceTemplate -> DeleteServiceTemplate -> Bool
Prelude.Eq, ReadPrec [DeleteServiceTemplate]
ReadPrec DeleteServiceTemplate
Int -> ReadS DeleteServiceTemplate
ReadS [DeleteServiceTemplate]
(Int -> ReadS DeleteServiceTemplate)
-> ReadS [DeleteServiceTemplate]
-> ReadPrec DeleteServiceTemplate
-> ReadPrec [DeleteServiceTemplate]
-> Read DeleteServiceTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteServiceTemplate]
$creadListPrec :: ReadPrec [DeleteServiceTemplate]
readPrec :: ReadPrec DeleteServiceTemplate
$creadPrec :: ReadPrec DeleteServiceTemplate
readList :: ReadS [DeleteServiceTemplate]
$creadList :: ReadS [DeleteServiceTemplate]
readsPrec :: Int -> ReadS DeleteServiceTemplate
$creadsPrec :: Int -> ReadS DeleteServiceTemplate
Prelude.Read, Int -> DeleteServiceTemplate -> ShowS
[DeleteServiceTemplate] -> ShowS
DeleteServiceTemplate -> String
(Int -> DeleteServiceTemplate -> ShowS)
-> (DeleteServiceTemplate -> String)
-> ([DeleteServiceTemplate] -> ShowS)
-> Show DeleteServiceTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteServiceTemplate] -> ShowS
$cshowList :: [DeleteServiceTemplate] -> ShowS
show :: DeleteServiceTemplate -> String
$cshow :: DeleteServiceTemplate -> String
showsPrec :: Int -> DeleteServiceTemplate -> ShowS
$cshowsPrec :: Int -> DeleteServiceTemplate -> ShowS
Prelude.Show, (forall x. DeleteServiceTemplate -> Rep DeleteServiceTemplate x)
-> (forall x. Rep DeleteServiceTemplate x -> DeleteServiceTemplate)
-> Generic DeleteServiceTemplate
forall x. Rep DeleteServiceTemplate x -> DeleteServiceTemplate
forall x. DeleteServiceTemplate -> Rep DeleteServiceTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteServiceTemplate x -> DeleteServiceTemplate
$cfrom :: forall x. DeleteServiceTemplate -> Rep DeleteServiceTemplate x
Prelude.Generic)

-- |
-- Create a value of 'DeleteServiceTemplate' 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', 'deleteServiceTemplate_name' - The name of the service template to delete.
newDeleteServiceTemplate ::
  -- | 'name'
  Prelude.Text ->
  DeleteServiceTemplate
newDeleteServiceTemplate :: Text -> DeleteServiceTemplate
newDeleteServiceTemplate Text
pName_ =
  DeleteServiceTemplate' :: Text -> DeleteServiceTemplate
DeleteServiceTemplate' {$sel:name:DeleteServiceTemplate' :: Text
name = Text
pName_}

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

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

instance Prelude.NFData DeleteServiceTemplate

instance Core.ToHeaders DeleteServiceTemplate where
  toHeaders :: DeleteServiceTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteServiceTemplate -> 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.DeleteServiceTemplate" ::
                          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 DeleteServiceTemplate where
  toJSON :: DeleteServiceTemplate -> Value
toJSON DeleteServiceTemplate' {Text
name :: Text
$sel:name:DeleteServiceTemplate' :: DeleteServiceTemplate -> 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 DeleteServiceTemplate where
  toPath :: DeleteServiceTemplate -> ByteString
toPath = ByteString -> DeleteServiceTemplate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeleteServiceTemplateResponse' 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:
--
-- 'serviceTemplate', 'deleteServiceTemplateResponse_serviceTemplate' - The service template detail data that\'s returned by AWS Proton.
--
-- 'httpStatus', 'deleteServiceTemplateResponse_httpStatus' - The response's http status code.
newDeleteServiceTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteServiceTemplateResponse
newDeleteServiceTemplateResponse :: Int -> DeleteServiceTemplateResponse
newDeleteServiceTemplateResponse Int
pHttpStatus_ =
  DeleteServiceTemplateResponse' :: Maybe ServiceTemplate -> Int -> DeleteServiceTemplateResponse
DeleteServiceTemplateResponse'
    { $sel:serviceTemplate:DeleteServiceTemplateResponse' :: Maybe ServiceTemplate
serviceTemplate =
        Maybe ServiceTemplate
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteServiceTemplateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The service template detail data that\'s returned by AWS Proton.
deleteServiceTemplateResponse_serviceTemplate :: Lens.Lens' DeleteServiceTemplateResponse (Prelude.Maybe ServiceTemplate)
deleteServiceTemplateResponse_serviceTemplate :: (Maybe ServiceTemplate -> f (Maybe ServiceTemplate))
-> DeleteServiceTemplateResponse -> f DeleteServiceTemplateResponse
deleteServiceTemplateResponse_serviceTemplate = (DeleteServiceTemplateResponse -> Maybe ServiceTemplate)
-> (DeleteServiceTemplateResponse
    -> Maybe ServiceTemplate -> DeleteServiceTemplateResponse)
-> Lens
     DeleteServiceTemplateResponse
     DeleteServiceTemplateResponse
     (Maybe ServiceTemplate)
     (Maybe ServiceTemplate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteServiceTemplateResponse' {Maybe ServiceTemplate
serviceTemplate :: Maybe ServiceTemplate
$sel:serviceTemplate:DeleteServiceTemplateResponse' :: DeleteServiceTemplateResponse -> Maybe ServiceTemplate
serviceTemplate} -> Maybe ServiceTemplate
serviceTemplate) (\s :: DeleteServiceTemplateResponse
s@DeleteServiceTemplateResponse' {} Maybe ServiceTemplate
a -> DeleteServiceTemplateResponse
s {$sel:serviceTemplate:DeleteServiceTemplateResponse' :: Maybe ServiceTemplate
serviceTemplate = Maybe ServiceTemplate
a} :: DeleteServiceTemplateResponse)

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

instance Prelude.NFData DeleteServiceTemplateResponse