{-# 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.UpdatePullRequestApprovalState
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the state of a user\'s approval on a pull request. The user is
-- derived from the signed-in account when the request is made.
module Amazonka.CodeCommit.UpdatePullRequestApprovalState
  ( -- * Creating a Request
    UpdatePullRequestApprovalState (..),
    newUpdatePullRequestApprovalState,

    -- * Request Lenses
    updatePullRequestApprovalState_pullRequestId,
    updatePullRequestApprovalState_revisionId,
    updatePullRequestApprovalState_approvalState,

    -- * Destructuring the Response
    UpdatePullRequestApprovalStateResponse (..),
    newUpdatePullRequestApprovalStateResponse,
  )
where

import Amazonka.CodeCommit.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdatePullRequestApprovalState' smart constructor.
data UpdatePullRequestApprovalState = UpdatePullRequestApprovalState'
  { -- | The system-generated ID of the pull request.
    UpdatePullRequestApprovalState -> Text
pullRequestId :: Prelude.Text,
    -- | The system-generated ID of the revision.
    UpdatePullRequestApprovalState -> Text
revisionId :: Prelude.Text,
    -- | The approval state to associate with the user on the pull request.
    UpdatePullRequestApprovalState -> ApprovalState
approvalState :: ApprovalState
  }
  deriving (UpdatePullRequestApprovalState
-> UpdatePullRequestApprovalState -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePullRequestApprovalState
-> UpdatePullRequestApprovalState -> Bool
$c/= :: UpdatePullRequestApprovalState
-> UpdatePullRequestApprovalState -> Bool
== :: UpdatePullRequestApprovalState
-> UpdatePullRequestApprovalState -> Bool
$c== :: UpdatePullRequestApprovalState
-> UpdatePullRequestApprovalState -> Bool
Prelude.Eq, ReadPrec [UpdatePullRequestApprovalState]
ReadPrec UpdatePullRequestApprovalState
Int -> ReadS UpdatePullRequestApprovalState
ReadS [UpdatePullRequestApprovalState]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePullRequestApprovalState]
$creadListPrec :: ReadPrec [UpdatePullRequestApprovalState]
readPrec :: ReadPrec UpdatePullRequestApprovalState
$creadPrec :: ReadPrec UpdatePullRequestApprovalState
readList :: ReadS [UpdatePullRequestApprovalState]
$creadList :: ReadS [UpdatePullRequestApprovalState]
readsPrec :: Int -> ReadS UpdatePullRequestApprovalState
$creadsPrec :: Int -> ReadS UpdatePullRequestApprovalState
Prelude.Read, Int -> UpdatePullRequestApprovalState -> ShowS
[UpdatePullRequestApprovalState] -> ShowS
UpdatePullRequestApprovalState -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePullRequestApprovalState] -> ShowS
$cshowList :: [UpdatePullRequestApprovalState] -> ShowS
show :: UpdatePullRequestApprovalState -> String
$cshow :: UpdatePullRequestApprovalState -> String
showsPrec :: Int -> UpdatePullRequestApprovalState -> ShowS
$cshowsPrec :: Int -> UpdatePullRequestApprovalState -> ShowS
Prelude.Show, forall x.
Rep UpdatePullRequestApprovalState x
-> UpdatePullRequestApprovalState
forall x.
UpdatePullRequestApprovalState
-> Rep UpdatePullRequestApprovalState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePullRequestApprovalState x
-> UpdatePullRequestApprovalState
$cfrom :: forall x.
UpdatePullRequestApprovalState
-> Rep UpdatePullRequestApprovalState x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePullRequestApprovalState' 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', 'updatePullRequestApprovalState_pullRequestId' - The system-generated ID of the pull request.
--
-- 'revisionId', 'updatePullRequestApprovalState_revisionId' - The system-generated ID of the revision.
--
-- 'approvalState', 'updatePullRequestApprovalState_approvalState' - The approval state to associate with the user on the pull request.
newUpdatePullRequestApprovalState ::
  -- | 'pullRequestId'
  Prelude.Text ->
  -- | 'revisionId'
  Prelude.Text ->
  -- | 'approvalState'
  ApprovalState ->
  UpdatePullRequestApprovalState
newUpdatePullRequestApprovalState :: Text -> Text -> ApprovalState -> UpdatePullRequestApprovalState
newUpdatePullRequestApprovalState
  Text
pPullRequestId_
  Text
pRevisionId_
  ApprovalState
pApprovalState_ =
    UpdatePullRequestApprovalState'
      { $sel:pullRequestId:UpdatePullRequestApprovalState' :: Text
pullRequestId =
          Text
pPullRequestId_,
        $sel:revisionId:UpdatePullRequestApprovalState' :: Text
revisionId = Text
pRevisionId_,
        $sel:approvalState:UpdatePullRequestApprovalState' :: ApprovalState
approvalState = ApprovalState
pApprovalState_
      }

-- | The system-generated ID of the pull request.
updatePullRequestApprovalState_pullRequestId :: Lens.Lens' UpdatePullRequestApprovalState Prelude.Text
updatePullRequestApprovalState_pullRequestId :: Lens' UpdatePullRequestApprovalState Text
updatePullRequestApprovalState_pullRequestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePullRequestApprovalState' {Text
pullRequestId :: Text
$sel:pullRequestId:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> Text
pullRequestId} -> Text
pullRequestId) (\s :: UpdatePullRequestApprovalState
s@UpdatePullRequestApprovalState' {} Text
a -> UpdatePullRequestApprovalState
s {$sel:pullRequestId:UpdatePullRequestApprovalState' :: Text
pullRequestId = Text
a} :: UpdatePullRequestApprovalState)

-- | The system-generated ID of the revision.
updatePullRequestApprovalState_revisionId :: Lens.Lens' UpdatePullRequestApprovalState Prelude.Text
updatePullRequestApprovalState_revisionId :: Lens' UpdatePullRequestApprovalState Text
updatePullRequestApprovalState_revisionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePullRequestApprovalState' {Text
revisionId :: Text
$sel:revisionId:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> Text
revisionId} -> Text
revisionId) (\s :: UpdatePullRequestApprovalState
s@UpdatePullRequestApprovalState' {} Text
a -> UpdatePullRequestApprovalState
s {$sel:revisionId:UpdatePullRequestApprovalState' :: Text
revisionId = Text
a} :: UpdatePullRequestApprovalState)

-- | The approval state to associate with the user on the pull request.
updatePullRequestApprovalState_approvalState :: Lens.Lens' UpdatePullRequestApprovalState ApprovalState
updatePullRequestApprovalState_approvalState :: Lens' UpdatePullRequestApprovalState ApprovalState
updatePullRequestApprovalState_approvalState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePullRequestApprovalState' {ApprovalState
approvalState :: ApprovalState
$sel:approvalState:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> ApprovalState
approvalState} -> ApprovalState
approvalState) (\s :: UpdatePullRequestApprovalState
s@UpdatePullRequestApprovalState' {} ApprovalState
a -> UpdatePullRequestApprovalState
s {$sel:approvalState:UpdatePullRequestApprovalState' :: ApprovalState
approvalState = ApprovalState
a} :: UpdatePullRequestApprovalState)

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

instance
  Prelude.Hashable
    UpdatePullRequestApprovalState
  where
  hashWithSalt :: Int -> UpdatePullRequestApprovalState -> Int
hashWithSalt
    Int
_salt
    UpdatePullRequestApprovalState' {Text
ApprovalState
approvalState :: ApprovalState
revisionId :: Text
pullRequestId :: Text
$sel:approvalState:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> ApprovalState
$sel:revisionId:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> Text
$sel:pullRequestId:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
pullRequestId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
revisionId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ApprovalState
approvalState

instance
  Prelude.NFData
    UpdatePullRequestApprovalState
  where
  rnf :: UpdatePullRequestApprovalState -> ()
rnf UpdatePullRequestApprovalState' {Text
ApprovalState
approvalState :: ApprovalState
revisionId :: Text
pullRequestId :: Text
$sel:approvalState:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> ApprovalState
$sel:revisionId:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> Text
$sel:pullRequestId:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
pullRequestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
revisionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ApprovalState
approvalState

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

instance Data.ToJSON UpdatePullRequestApprovalState where
  toJSON :: UpdatePullRequestApprovalState -> Value
toJSON UpdatePullRequestApprovalState' {Text
ApprovalState
approvalState :: ApprovalState
revisionId :: Text
pullRequestId :: Text
$sel:approvalState:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> ApprovalState
$sel:revisionId:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> Text
$sel:pullRequestId:UpdatePullRequestApprovalState' :: UpdatePullRequestApprovalState -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"pullRequestId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
pullRequestId),
            forall a. a -> Maybe a
Prelude.Just (Key
"revisionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
revisionId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"approvalState" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ApprovalState
approvalState)
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    UpdatePullRequestApprovalStateResponse
  where
  rnf :: UpdatePullRequestApprovalStateResponse -> ()
rnf UpdatePullRequestApprovalStateResponse
_ = ()