{-# 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.DisassociateApprovalRuleTemplateFromRepository
-- 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)
--
-- Removes the association between a template and a repository so that
-- approval rules based on the template are not automatically created when
-- pull requests are created in the specified repository. This does not
-- delete any approval rules previously created for pull requests through
-- the template association.
module Amazonka.CodeCommit.DisassociateApprovalRuleTemplateFromRepository
  ( -- * Creating a Request
    DisassociateApprovalRuleTemplateFromRepository (..),
    newDisassociateApprovalRuleTemplateFromRepository,

    -- * Request Lenses
    disassociateApprovalRuleTemplateFromRepository_approvalRuleTemplateName,
    disassociateApprovalRuleTemplateFromRepository_repositoryName,

    -- * Destructuring the Response
    DisassociateApprovalRuleTemplateFromRepositoryResponse (..),
    newDisassociateApprovalRuleTemplateFromRepositoryResponse,
  )
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:/ 'newDisassociateApprovalRuleTemplateFromRepository' smart constructor.
data DisassociateApprovalRuleTemplateFromRepository = DisassociateApprovalRuleTemplateFromRepository'
  { -- | The name of the approval rule template to disassociate from a specified
    -- repository.
    DisassociateApprovalRuleTemplateFromRepository -> Text
approvalRuleTemplateName :: Prelude.Text,
    -- | The name of the repository you want to disassociate from the template.
    DisassociateApprovalRuleTemplateFromRepository -> Text
repositoryName :: Prelude.Text
  }
  deriving (DisassociateApprovalRuleTemplateFromRepository
-> DisassociateApprovalRuleTemplateFromRepository -> Bool
(DisassociateApprovalRuleTemplateFromRepository
 -> DisassociateApprovalRuleTemplateFromRepository -> Bool)
-> (DisassociateApprovalRuleTemplateFromRepository
    -> DisassociateApprovalRuleTemplateFromRepository -> Bool)
-> Eq DisassociateApprovalRuleTemplateFromRepository
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateApprovalRuleTemplateFromRepository
-> DisassociateApprovalRuleTemplateFromRepository -> Bool
$c/= :: DisassociateApprovalRuleTemplateFromRepository
-> DisassociateApprovalRuleTemplateFromRepository -> Bool
== :: DisassociateApprovalRuleTemplateFromRepository
-> DisassociateApprovalRuleTemplateFromRepository -> Bool
$c== :: DisassociateApprovalRuleTemplateFromRepository
-> DisassociateApprovalRuleTemplateFromRepository -> Bool
Prelude.Eq, ReadPrec [DisassociateApprovalRuleTemplateFromRepository]
ReadPrec DisassociateApprovalRuleTemplateFromRepository
Int -> ReadS DisassociateApprovalRuleTemplateFromRepository
ReadS [DisassociateApprovalRuleTemplateFromRepository]
(Int -> ReadS DisassociateApprovalRuleTemplateFromRepository)
-> ReadS [DisassociateApprovalRuleTemplateFromRepository]
-> ReadPrec DisassociateApprovalRuleTemplateFromRepository
-> ReadPrec [DisassociateApprovalRuleTemplateFromRepository]
-> Read DisassociateApprovalRuleTemplateFromRepository
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateApprovalRuleTemplateFromRepository]
$creadListPrec :: ReadPrec [DisassociateApprovalRuleTemplateFromRepository]
readPrec :: ReadPrec DisassociateApprovalRuleTemplateFromRepository
$creadPrec :: ReadPrec DisassociateApprovalRuleTemplateFromRepository
readList :: ReadS [DisassociateApprovalRuleTemplateFromRepository]
$creadList :: ReadS [DisassociateApprovalRuleTemplateFromRepository]
readsPrec :: Int -> ReadS DisassociateApprovalRuleTemplateFromRepository
$creadsPrec :: Int -> ReadS DisassociateApprovalRuleTemplateFromRepository
Prelude.Read, Int -> DisassociateApprovalRuleTemplateFromRepository -> ShowS
[DisassociateApprovalRuleTemplateFromRepository] -> ShowS
DisassociateApprovalRuleTemplateFromRepository -> String
(Int -> DisassociateApprovalRuleTemplateFromRepository -> ShowS)
-> (DisassociateApprovalRuleTemplateFromRepository -> String)
-> ([DisassociateApprovalRuleTemplateFromRepository] -> ShowS)
-> Show DisassociateApprovalRuleTemplateFromRepository
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateApprovalRuleTemplateFromRepository] -> ShowS
$cshowList :: [DisassociateApprovalRuleTemplateFromRepository] -> ShowS
show :: DisassociateApprovalRuleTemplateFromRepository -> String
$cshow :: DisassociateApprovalRuleTemplateFromRepository -> String
showsPrec :: Int -> DisassociateApprovalRuleTemplateFromRepository -> ShowS
$cshowsPrec :: Int -> DisassociateApprovalRuleTemplateFromRepository -> ShowS
Prelude.Show, (forall x.
 DisassociateApprovalRuleTemplateFromRepository
 -> Rep DisassociateApprovalRuleTemplateFromRepository x)
-> (forall x.
    Rep DisassociateApprovalRuleTemplateFromRepository x
    -> DisassociateApprovalRuleTemplateFromRepository)
-> Generic DisassociateApprovalRuleTemplateFromRepository
forall x.
Rep DisassociateApprovalRuleTemplateFromRepository x
-> DisassociateApprovalRuleTemplateFromRepository
forall x.
DisassociateApprovalRuleTemplateFromRepository
-> Rep DisassociateApprovalRuleTemplateFromRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateApprovalRuleTemplateFromRepository x
-> DisassociateApprovalRuleTemplateFromRepository
$cfrom :: forall x.
DisassociateApprovalRuleTemplateFromRepository
-> Rep DisassociateApprovalRuleTemplateFromRepository x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateApprovalRuleTemplateFromRepository' 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', 'disassociateApprovalRuleTemplateFromRepository_approvalRuleTemplateName' - The name of the approval rule template to disassociate from a specified
-- repository.
--
-- 'repositoryName', 'disassociateApprovalRuleTemplateFromRepository_repositoryName' - The name of the repository you want to disassociate from the template.
newDisassociateApprovalRuleTemplateFromRepository ::
  -- | 'approvalRuleTemplateName'
  Prelude.Text ->
  -- | 'repositoryName'
  Prelude.Text ->
  DisassociateApprovalRuleTemplateFromRepository
newDisassociateApprovalRuleTemplateFromRepository :: Text -> Text -> DisassociateApprovalRuleTemplateFromRepository
newDisassociateApprovalRuleTemplateFromRepository
  Text
pApprovalRuleTemplateName_
  Text
pRepositoryName_ =
    DisassociateApprovalRuleTemplateFromRepository' :: Text -> Text -> DisassociateApprovalRuleTemplateFromRepository
DisassociateApprovalRuleTemplateFromRepository'
      { $sel:approvalRuleTemplateName:DisassociateApprovalRuleTemplateFromRepository' :: Text
approvalRuleTemplateName =
          Text
pApprovalRuleTemplateName_,
        $sel:repositoryName:DisassociateApprovalRuleTemplateFromRepository' :: Text
repositoryName =
          Text
pRepositoryName_
      }

-- | The name of the approval rule template to disassociate from a specified
-- repository.
disassociateApprovalRuleTemplateFromRepository_approvalRuleTemplateName :: Lens.Lens' DisassociateApprovalRuleTemplateFromRepository Prelude.Text
disassociateApprovalRuleTemplateFromRepository_approvalRuleTemplateName :: (Text -> f Text)
-> DisassociateApprovalRuleTemplateFromRepository
-> f DisassociateApprovalRuleTemplateFromRepository
disassociateApprovalRuleTemplateFromRepository_approvalRuleTemplateName = (DisassociateApprovalRuleTemplateFromRepository -> Text)
-> (DisassociateApprovalRuleTemplateFromRepository
    -> Text -> DisassociateApprovalRuleTemplateFromRepository)
-> Lens
     DisassociateApprovalRuleTemplateFromRepository
     DisassociateApprovalRuleTemplateFromRepository
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateApprovalRuleTemplateFromRepository' {Text
approvalRuleTemplateName :: Text
$sel:approvalRuleTemplateName:DisassociateApprovalRuleTemplateFromRepository' :: DisassociateApprovalRuleTemplateFromRepository -> Text
approvalRuleTemplateName} -> Text
approvalRuleTemplateName) (\s :: DisassociateApprovalRuleTemplateFromRepository
s@DisassociateApprovalRuleTemplateFromRepository' {} Text
a -> DisassociateApprovalRuleTemplateFromRepository
s {$sel:approvalRuleTemplateName:DisassociateApprovalRuleTemplateFromRepository' :: Text
approvalRuleTemplateName = Text
a} :: DisassociateApprovalRuleTemplateFromRepository)

-- | The name of the repository you want to disassociate from the template.
disassociateApprovalRuleTemplateFromRepository_repositoryName :: Lens.Lens' DisassociateApprovalRuleTemplateFromRepository Prelude.Text
disassociateApprovalRuleTemplateFromRepository_repositoryName :: (Text -> f Text)
-> DisassociateApprovalRuleTemplateFromRepository
-> f DisassociateApprovalRuleTemplateFromRepository
disassociateApprovalRuleTemplateFromRepository_repositoryName = (DisassociateApprovalRuleTemplateFromRepository -> Text)
-> (DisassociateApprovalRuleTemplateFromRepository
    -> Text -> DisassociateApprovalRuleTemplateFromRepository)
-> Lens
     DisassociateApprovalRuleTemplateFromRepository
     DisassociateApprovalRuleTemplateFromRepository
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateApprovalRuleTemplateFromRepository' {Text
repositoryName :: Text
$sel:repositoryName:DisassociateApprovalRuleTemplateFromRepository' :: DisassociateApprovalRuleTemplateFromRepository -> Text
repositoryName} -> Text
repositoryName) (\s :: DisassociateApprovalRuleTemplateFromRepository
s@DisassociateApprovalRuleTemplateFromRepository' {} Text
a -> DisassociateApprovalRuleTemplateFromRepository
s {$sel:repositoryName:DisassociateApprovalRuleTemplateFromRepository' :: Text
repositoryName = Text
a} :: DisassociateApprovalRuleTemplateFromRepository)

instance
  Core.AWSRequest
    DisassociateApprovalRuleTemplateFromRepository
  where
  type
    AWSResponse
      DisassociateApprovalRuleTemplateFromRepository =
      DisassociateApprovalRuleTemplateFromRepositoryResponse
  request :: DisassociateApprovalRuleTemplateFromRepository
-> Request DisassociateApprovalRuleTemplateFromRepository
request = Service
-> DisassociateApprovalRuleTemplateFromRepository
-> Request DisassociateApprovalRuleTemplateFromRepository
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateApprovalRuleTemplateFromRepository
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse DisassociateApprovalRuleTemplateFromRepository)))
response =
    AWSResponse DisassociateApprovalRuleTemplateFromRepository
-> Logger
-> Service
-> Proxy DisassociateApprovalRuleTemplateFromRepository
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse DisassociateApprovalRuleTemplateFromRepository)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse DisassociateApprovalRuleTemplateFromRepository
DisassociateApprovalRuleTemplateFromRepositoryResponse
DisassociateApprovalRuleTemplateFromRepositoryResponse'

instance
  Prelude.Hashable
    DisassociateApprovalRuleTemplateFromRepository

instance
  Prelude.NFData
    DisassociateApprovalRuleTemplateFromRepository

instance
  Core.ToHeaders
    DisassociateApprovalRuleTemplateFromRepository
  where
  toHeaders :: DisassociateApprovalRuleTemplateFromRepository -> [Header]
toHeaders =
    [Header]
-> DisassociateApprovalRuleTemplateFromRepository -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"CodeCommit_20150413.DisassociateApprovalRuleTemplateFromRepository" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance
  Core.ToJSON
    DisassociateApprovalRuleTemplateFromRepository
  where
  toJSON :: DisassociateApprovalRuleTemplateFromRepository -> Value
toJSON
    DisassociateApprovalRuleTemplateFromRepository' {Text
repositoryName :: Text
approvalRuleTemplateName :: Text
$sel:repositoryName:DisassociateApprovalRuleTemplateFromRepository' :: DisassociateApprovalRuleTemplateFromRepository -> Text
$sel:approvalRuleTemplateName:DisassociateApprovalRuleTemplateFromRepository' :: DisassociateApprovalRuleTemplateFromRepository -> 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
                ),
              Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
                (Text
"repositoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryName)
            ]
        )

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

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

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

-- |
-- Create a value of 'DisassociateApprovalRuleTemplateFromRepositoryResponse' 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.
newDisassociateApprovalRuleTemplateFromRepositoryResponse ::
  DisassociateApprovalRuleTemplateFromRepositoryResponse
newDisassociateApprovalRuleTemplateFromRepositoryResponse :: DisassociateApprovalRuleTemplateFromRepositoryResponse
newDisassociateApprovalRuleTemplateFromRepositoryResponse =
  DisassociateApprovalRuleTemplateFromRepositoryResponse
DisassociateApprovalRuleTemplateFromRepositoryResponse'

instance
  Prelude.NFData
    DisassociateApprovalRuleTemplateFromRepositoryResponse