{-# 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.CodeCommit.DeleteApprovalRuleTemplate
-- 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 specified approval rule template. Deleting a template does not
-- remove approval rules on pull requests already created with the
-- template.
module Amazonka.CodeCommit.DeleteApprovalRuleTemplate
  ( -- * Creating a Request
    DeleteApprovalRuleTemplate (..),
    newDeleteApprovalRuleTemplate,

    -- * Request Lenses
    deleteApprovalRuleTemplate_approvalRuleTemplateName,

    -- * Destructuring the Response
    DeleteApprovalRuleTemplateResponse (..),
    newDeleteApprovalRuleTemplateResponse,

    -- * Response Lenses
    deleteApprovalRuleTemplateResponse_httpStatus,
    deleteApprovalRuleTemplateResponse_approvalRuleTemplateId,
  )
where

import Amazonka.CodeCommit.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

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

-- |
-- Create a value of 'DeleteApprovalRuleTemplate' 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:
--
-- 'approvalRuleTemplateName', 'deleteApprovalRuleTemplate_approvalRuleTemplateName' - The name of the approval rule template to delete.
newDeleteApprovalRuleTemplate ::
  -- | 'approvalRuleTemplateName'
  Prelude.Text ->
  DeleteApprovalRuleTemplate
newDeleteApprovalRuleTemplate :: Text -> DeleteApprovalRuleTemplate
newDeleteApprovalRuleTemplate
  Text
pApprovalRuleTemplateName_ =
    DeleteApprovalRuleTemplate' :: Text -> DeleteApprovalRuleTemplate
DeleteApprovalRuleTemplate'
      { $sel:approvalRuleTemplateName:DeleteApprovalRuleTemplate' :: Text
approvalRuleTemplateName =
          Text
pApprovalRuleTemplateName_
      }

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

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

instance Prelude.Hashable DeleteApprovalRuleTemplate

instance Prelude.NFData DeleteApprovalRuleTemplate

instance Core.ToHeaders DeleteApprovalRuleTemplate where
  toHeaders :: DeleteApprovalRuleTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteApprovalRuleTemplate -> 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
"CodeCommit_20150413.DeleteApprovalRuleTemplate" ::
                          Prelude.ByteString
                      ),
            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.ToJSON DeleteApprovalRuleTemplate where
  toJSON :: DeleteApprovalRuleTemplate -> Value
toJSON DeleteApprovalRuleTemplate' {Text
approvalRuleTemplateName :: Text
$sel:approvalRuleTemplateName:DeleteApprovalRuleTemplate' :: DeleteApprovalRuleTemplate -> 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
"approvalRuleTemplateName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
approvalRuleTemplateName
              )
          ]
      )

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

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

-- | /See:/ 'newDeleteApprovalRuleTemplateResponse' smart constructor.
data DeleteApprovalRuleTemplateResponse = DeleteApprovalRuleTemplateResponse'
  { -- | The response's http status code.
    DeleteApprovalRuleTemplateResponse -> Int
httpStatus :: Prelude.Int,
    -- | The system-generated ID of the deleted approval rule template. If the
    -- template has been previously deleted, the only response is a 200 OK.
    DeleteApprovalRuleTemplateResponse -> Text
approvalRuleTemplateId :: Prelude.Text
  }
  deriving (DeleteApprovalRuleTemplateResponse
-> DeleteApprovalRuleTemplateResponse -> Bool
(DeleteApprovalRuleTemplateResponse
 -> DeleteApprovalRuleTemplateResponse -> Bool)
-> (DeleteApprovalRuleTemplateResponse
    -> DeleteApprovalRuleTemplateResponse -> Bool)
-> Eq DeleteApprovalRuleTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteApprovalRuleTemplateResponse
-> DeleteApprovalRuleTemplateResponse -> Bool
$c/= :: DeleteApprovalRuleTemplateResponse
-> DeleteApprovalRuleTemplateResponse -> Bool
== :: DeleteApprovalRuleTemplateResponse
-> DeleteApprovalRuleTemplateResponse -> Bool
$c== :: DeleteApprovalRuleTemplateResponse
-> DeleteApprovalRuleTemplateResponse -> Bool
Prelude.Eq, ReadPrec [DeleteApprovalRuleTemplateResponse]
ReadPrec DeleteApprovalRuleTemplateResponse
Int -> ReadS DeleteApprovalRuleTemplateResponse
ReadS [DeleteApprovalRuleTemplateResponse]
(Int -> ReadS DeleteApprovalRuleTemplateResponse)
-> ReadS [DeleteApprovalRuleTemplateResponse]
-> ReadPrec DeleteApprovalRuleTemplateResponse
-> ReadPrec [DeleteApprovalRuleTemplateResponse]
-> Read DeleteApprovalRuleTemplateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteApprovalRuleTemplateResponse]
$creadListPrec :: ReadPrec [DeleteApprovalRuleTemplateResponse]
readPrec :: ReadPrec DeleteApprovalRuleTemplateResponse
$creadPrec :: ReadPrec DeleteApprovalRuleTemplateResponse
readList :: ReadS [DeleteApprovalRuleTemplateResponse]
$creadList :: ReadS [DeleteApprovalRuleTemplateResponse]
readsPrec :: Int -> ReadS DeleteApprovalRuleTemplateResponse
$creadsPrec :: Int -> ReadS DeleteApprovalRuleTemplateResponse
Prelude.Read, Int -> DeleteApprovalRuleTemplateResponse -> ShowS
[DeleteApprovalRuleTemplateResponse] -> ShowS
DeleteApprovalRuleTemplateResponse -> String
(Int -> DeleteApprovalRuleTemplateResponse -> ShowS)
-> (DeleteApprovalRuleTemplateResponse -> String)
-> ([DeleteApprovalRuleTemplateResponse] -> ShowS)
-> Show DeleteApprovalRuleTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteApprovalRuleTemplateResponse] -> ShowS
$cshowList :: [DeleteApprovalRuleTemplateResponse] -> ShowS
show :: DeleteApprovalRuleTemplateResponse -> String
$cshow :: DeleteApprovalRuleTemplateResponse -> String
showsPrec :: Int -> DeleteApprovalRuleTemplateResponse -> ShowS
$cshowsPrec :: Int -> DeleteApprovalRuleTemplateResponse -> ShowS
Prelude.Show, (forall x.
 DeleteApprovalRuleTemplateResponse
 -> Rep DeleteApprovalRuleTemplateResponse x)
-> (forall x.
    Rep DeleteApprovalRuleTemplateResponse x
    -> DeleteApprovalRuleTemplateResponse)
-> Generic DeleteApprovalRuleTemplateResponse
forall x.
Rep DeleteApprovalRuleTemplateResponse x
-> DeleteApprovalRuleTemplateResponse
forall x.
DeleteApprovalRuleTemplateResponse
-> Rep DeleteApprovalRuleTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteApprovalRuleTemplateResponse x
-> DeleteApprovalRuleTemplateResponse
$cfrom :: forall x.
DeleteApprovalRuleTemplateResponse
-> Rep DeleteApprovalRuleTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteApprovalRuleTemplateResponse' 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', 'deleteApprovalRuleTemplateResponse_httpStatus' - The response's http status code.
--
-- 'approvalRuleTemplateId', 'deleteApprovalRuleTemplateResponse_approvalRuleTemplateId' - The system-generated ID of the deleted approval rule template. If the
-- template has been previously deleted, the only response is a 200 OK.
newDeleteApprovalRuleTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'approvalRuleTemplateId'
  Prelude.Text ->
  DeleteApprovalRuleTemplateResponse
newDeleteApprovalRuleTemplateResponse :: Int -> Text -> DeleteApprovalRuleTemplateResponse
newDeleteApprovalRuleTemplateResponse
  Int
pHttpStatus_
  Text
pApprovalRuleTemplateId_ =
    DeleteApprovalRuleTemplateResponse' :: Int -> Text -> DeleteApprovalRuleTemplateResponse
DeleteApprovalRuleTemplateResponse'
      { $sel:httpStatus:DeleteApprovalRuleTemplateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:approvalRuleTemplateId:DeleteApprovalRuleTemplateResponse' :: Text
approvalRuleTemplateId =
          Text
pApprovalRuleTemplateId_
      }

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

-- | The system-generated ID of the deleted approval rule template. If the
-- template has been previously deleted, the only response is a 200 OK.
deleteApprovalRuleTemplateResponse_approvalRuleTemplateId :: Lens.Lens' DeleteApprovalRuleTemplateResponse Prelude.Text
deleteApprovalRuleTemplateResponse_approvalRuleTemplateId :: (Text -> f Text)
-> DeleteApprovalRuleTemplateResponse
-> f DeleteApprovalRuleTemplateResponse
deleteApprovalRuleTemplateResponse_approvalRuleTemplateId = (DeleteApprovalRuleTemplateResponse -> Text)
-> (DeleteApprovalRuleTemplateResponse
    -> Text -> DeleteApprovalRuleTemplateResponse)
-> Lens
     DeleteApprovalRuleTemplateResponse
     DeleteApprovalRuleTemplateResponse
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApprovalRuleTemplateResponse' {Text
approvalRuleTemplateId :: Text
$sel:approvalRuleTemplateId:DeleteApprovalRuleTemplateResponse' :: DeleteApprovalRuleTemplateResponse -> Text
approvalRuleTemplateId} -> Text
approvalRuleTemplateId) (\s :: DeleteApprovalRuleTemplateResponse
s@DeleteApprovalRuleTemplateResponse' {} Text
a -> DeleteApprovalRuleTemplateResponse
s {$sel:approvalRuleTemplateId:DeleteApprovalRuleTemplateResponse' :: Text
approvalRuleTemplateId = Text
a} :: DeleteApprovalRuleTemplateResponse)

instance
  Prelude.NFData
    DeleteApprovalRuleTemplateResponse