{-# 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.OverridePullRequestApprovalRules
-- 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)
--
-- Sets aside (overrides) all approval rule requirements for a specified
-- pull request.
module Amazonka.CodeCommit.OverridePullRequestApprovalRules
  ( -- * Creating a Request
    OverridePullRequestApprovalRules (..),
    newOverridePullRequestApprovalRules,

    -- * Request Lenses
    overridePullRequestApprovalRules_pullRequestId,
    overridePullRequestApprovalRules_revisionId,
    overridePullRequestApprovalRules_overrideStatus,

    -- * Destructuring the Response
    OverridePullRequestApprovalRulesResponse (..),
    newOverridePullRequestApprovalRulesResponse,
  )
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:/ 'newOverridePullRequestApprovalRules' smart constructor.
data OverridePullRequestApprovalRules = OverridePullRequestApprovalRules'
  { -- | The system-generated ID of the pull request for which you want to
    -- override all approval rule requirements. To get this information, use
    -- GetPullRequest.
    OverridePullRequestApprovalRules -> Text
pullRequestId :: Prelude.Text,
    -- | The system-generated ID of the most recent revision of the pull request.
    -- You cannot override approval rules for anything but the most recent
    -- revision of a pull request. To get the revision ID, use GetPullRequest.
    OverridePullRequestApprovalRules -> Text
revisionId :: Prelude.Text,
    -- | Whether you want to set aside approval rule requirements for the pull
    -- request (OVERRIDE) or revoke a previous override and apply approval rule
    -- requirements (REVOKE). REVOKE status is not stored.
    OverridePullRequestApprovalRules -> OverrideStatus
overrideStatus :: OverrideStatus
  }
  deriving (OverridePullRequestApprovalRules
-> OverridePullRequestApprovalRules -> Bool
(OverridePullRequestApprovalRules
 -> OverridePullRequestApprovalRules -> Bool)
-> (OverridePullRequestApprovalRules
    -> OverridePullRequestApprovalRules -> Bool)
-> Eq OverridePullRequestApprovalRules
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OverridePullRequestApprovalRules
-> OverridePullRequestApprovalRules -> Bool
$c/= :: OverridePullRequestApprovalRules
-> OverridePullRequestApprovalRules -> Bool
== :: OverridePullRequestApprovalRules
-> OverridePullRequestApprovalRules -> Bool
$c== :: OverridePullRequestApprovalRules
-> OverridePullRequestApprovalRules -> Bool
Prelude.Eq, ReadPrec [OverridePullRequestApprovalRules]
ReadPrec OverridePullRequestApprovalRules
Int -> ReadS OverridePullRequestApprovalRules
ReadS [OverridePullRequestApprovalRules]
(Int -> ReadS OverridePullRequestApprovalRules)
-> ReadS [OverridePullRequestApprovalRules]
-> ReadPrec OverridePullRequestApprovalRules
-> ReadPrec [OverridePullRequestApprovalRules]
-> Read OverridePullRequestApprovalRules
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OverridePullRequestApprovalRules]
$creadListPrec :: ReadPrec [OverridePullRequestApprovalRules]
readPrec :: ReadPrec OverridePullRequestApprovalRules
$creadPrec :: ReadPrec OverridePullRequestApprovalRules
readList :: ReadS [OverridePullRequestApprovalRules]
$creadList :: ReadS [OverridePullRequestApprovalRules]
readsPrec :: Int -> ReadS OverridePullRequestApprovalRules
$creadsPrec :: Int -> ReadS OverridePullRequestApprovalRules
Prelude.Read, Int -> OverridePullRequestApprovalRules -> ShowS
[OverridePullRequestApprovalRules] -> ShowS
OverridePullRequestApprovalRules -> String
(Int -> OverridePullRequestApprovalRules -> ShowS)
-> (OverridePullRequestApprovalRules -> String)
-> ([OverridePullRequestApprovalRules] -> ShowS)
-> Show OverridePullRequestApprovalRules
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OverridePullRequestApprovalRules] -> ShowS
$cshowList :: [OverridePullRequestApprovalRules] -> ShowS
show :: OverridePullRequestApprovalRules -> String
$cshow :: OverridePullRequestApprovalRules -> String
showsPrec :: Int -> OverridePullRequestApprovalRules -> ShowS
$cshowsPrec :: Int -> OverridePullRequestApprovalRules -> ShowS
Prelude.Show, (forall x.
 OverridePullRequestApprovalRules
 -> Rep OverridePullRequestApprovalRules x)
-> (forall x.
    Rep OverridePullRequestApprovalRules x
    -> OverridePullRequestApprovalRules)
-> Generic OverridePullRequestApprovalRules
forall x.
Rep OverridePullRequestApprovalRules x
-> OverridePullRequestApprovalRules
forall x.
OverridePullRequestApprovalRules
-> Rep OverridePullRequestApprovalRules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OverridePullRequestApprovalRules x
-> OverridePullRequestApprovalRules
$cfrom :: forall x.
OverridePullRequestApprovalRules
-> Rep OverridePullRequestApprovalRules x
Prelude.Generic)

-- |
-- Create a value of 'OverridePullRequestApprovalRules' 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:
--
-- 'pullRequestId', 'overridePullRequestApprovalRules_pullRequestId' - The system-generated ID of the pull request for which you want to
-- override all approval rule requirements. To get this information, use
-- GetPullRequest.
--
-- 'revisionId', 'overridePullRequestApprovalRules_revisionId' - The system-generated ID of the most recent revision of the pull request.
-- You cannot override approval rules for anything but the most recent
-- revision of a pull request. To get the revision ID, use GetPullRequest.
--
-- 'overrideStatus', 'overridePullRequestApprovalRules_overrideStatus' - Whether you want to set aside approval rule requirements for the pull
-- request (OVERRIDE) or revoke a previous override and apply approval rule
-- requirements (REVOKE). REVOKE status is not stored.
newOverridePullRequestApprovalRules ::
  -- | 'pullRequestId'
  Prelude.Text ->
  -- | 'revisionId'
  Prelude.Text ->
  -- | 'overrideStatus'
  OverrideStatus ->
  OverridePullRequestApprovalRules
newOverridePullRequestApprovalRules :: Text -> Text -> OverrideStatus -> OverridePullRequestApprovalRules
newOverridePullRequestApprovalRules
  Text
pPullRequestId_
  Text
pRevisionId_
  OverrideStatus
pOverrideStatus_ =
    OverridePullRequestApprovalRules' :: Text -> Text -> OverrideStatus -> OverridePullRequestApprovalRules
OverridePullRequestApprovalRules'
      { $sel:pullRequestId:OverridePullRequestApprovalRules' :: Text
pullRequestId =
          Text
pPullRequestId_,
        $sel:revisionId:OverridePullRequestApprovalRules' :: Text
revisionId = Text
pRevisionId_,
        $sel:overrideStatus:OverridePullRequestApprovalRules' :: OverrideStatus
overrideStatus = OverrideStatus
pOverrideStatus_
      }

-- | The system-generated ID of the pull request for which you want to
-- override all approval rule requirements. To get this information, use
-- GetPullRequest.
overridePullRequestApprovalRules_pullRequestId :: Lens.Lens' OverridePullRequestApprovalRules Prelude.Text
overridePullRequestApprovalRules_pullRequestId :: (Text -> f Text)
-> OverridePullRequestApprovalRules
-> f OverridePullRequestApprovalRules
overridePullRequestApprovalRules_pullRequestId = (OverridePullRequestApprovalRules -> Text)
-> (OverridePullRequestApprovalRules
    -> Text -> OverridePullRequestApprovalRules)
-> Lens
     OverridePullRequestApprovalRules
     OverridePullRequestApprovalRules
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OverridePullRequestApprovalRules' {Text
pullRequestId :: Text
$sel:pullRequestId:OverridePullRequestApprovalRules' :: OverridePullRequestApprovalRules -> Text
pullRequestId} -> Text
pullRequestId) (\s :: OverridePullRequestApprovalRules
s@OverridePullRequestApprovalRules' {} Text
a -> OverridePullRequestApprovalRules
s {$sel:pullRequestId:OverridePullRequestApprovalRules' :: Text
pullRequestId = Text
a} :: OverridePullRequestApprovalRules)

-- | The system-generated ID of the most recent revision of the pull request.
-- You cannot override approval rules for anything but the most recent
-- revision of a pull request. To get the revision ID, use GetPullRequest.
overridePullRequestApprovalRules_revisionId :: Lens.Lens' OverridePullRequestApprovalRules Prelude.Text
overridePullRequestApprovalRules_revisionId :: (Text -> f Text)
-> OverridePullRequestApprovalRules
-> f OverridePullRequestApprovalRules
overridePullRequestApprovalRules_revisionId = (OverridePullRequestApprovalRules -> Text)
-> (OverridePullRequestApprovalRules
    -> Text -> OverridePullRequestApprovalRules)
-> Lens
     OverridePullRequestApprovalRules
     OverridePullRequestApprovalRules
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OverridePullRequestApprovalRules' {Text
revisionId :: Text
$sel:revisionId:OverridePullRequestApprovalRules' :: OverridePullRequestApprovalRules -> Text
revisionId} -> Text
revisionId) (\s :: OverridePullRequestApprovalRules
s@OverridePullRequestApprovalRules' {} Text
a -> OverridePullRequestApprovalRules
s {$sel:revisionId:OverridePullRequestApprovalRules' :: Text
revisionId = Text
a} :: OverridePullRequestApprovalRules)

-- | Whether you want to set aside approval rule requirements for the pull
-- request (OVERRIDE) or revoke a previous override and apply approval rule
-- requirements (REVOKE). REVOKE status is not stored.
overridePullRequestApprovalRules_overrideStatus :: Lens.Lens' OverridePullRequestApprovalRules OverrideStatus
overridePullRequestApprovalRules_overrideStatus :: (OverrideStatus -> f OverrideStatus)
-> OverridePullRequestApprovalRules
-> f OverridePullRequestApprovalRules
overridePullRequestApprovalRules_overrideStatus = (OverridePullRequestApprovalRules -> OverrideStatus)
-> (OverridePullRequestApprovalRules
    -> OverrideStatus -> OverridePullRequestApprovalRules)
-> Lens
     OverridePullRequestApprovalRules
     OverridePullRequestApprovalRules
     OverrideStatus
     OverrideStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OverridePullRequestApprovalRules' {OverrideStatus
overrideStatus :: OverrideStatus
$sel:overrideStatus:OverridePullRequestApprovalRules' :: OverridePullRequestApprovalRules -> OverrideStatus
overrideStatus} -> OverrideStatus
overrideStatus) (\s :: OverridePullRequestApprovalRules
s@OverridePullRequestApprovalRules' {} OverrideStatus
a -> OverridePullRequestApprovalRules
s {$sel:overrideStatus:OverridePullRequestApprovalRules' :: OverrideStatus
overrideStatus = OverrideStatus
a} :: OverridePullRequestApprovalRules)

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

instance
  Prelude.Hashable
    OverridePullRequestApprovalRules

instance
  Prelude.NFData
    OverridePullRequestApprovalRules

instance
  Core.ToHeaders
    OverridePullRequestApprovalRules
  where
  toHeaders :: OverridePullRequestApprovalRules -> [Header]
toHeaders =
    [Header] -> OverridePullRequestApprovalRules -> [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.OverridePullRequestApprovalRules" ::
                          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 OverridePullRequestApprovalRules where
  toJSON :: OverridePullRequestApprovalRules -> Value
toJSON OverridePullRequestApprovalRules' {Text
OverrideStatus
overrideStatus :: OverrideStatus
revisionId :: Text
pullRequestId :: Text
$sel:overrideStatus:OverridePullRequestApprovalRules' :: OverridePullRequestApprovalRules -> OverrideStatus
$sel:revisionId:OverridePullRequestApprovalRules' :: OverridePullRequestApprovalRules -> Text
$sel:pullRequestId:OverridePullRequestApprovalRules' :: OverridePullRequestApprovalRules -> 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
"pullRequestId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
pullRequestId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"revisionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
revisionId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"overrideStatus" Text -> OverrideStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= OverrideStatus
overrideStatus)
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    OverridePullRequestApprovalRulesResponse