{-# 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-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)
--
-- 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.Lens as Lens
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
(UpdatePullRequestApprovalState
 -> UpdatePullRequestApprovalState -> Bool)
-> (UpdatePullRequestApprovalState
    -> UpdatePullRequestApprovalState -> Bool)
-> Eq UpdatePullRequestApprovalState
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]
(Int -> ReadS UpdatePullRequestApprovalState)
-> ReadS [UpdatePullRequestApprovalState]
-> ReadPrec UpdatePullRequestApprovalState
-> ReadPrec [UpdatePullRequestApprovalState]
-> Read 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
(Int -> UpdatePullRequestApprovalState -> ShowS)
-> (UpdatePullRequestApprovalState -> String)
-> ([UpdatePullRequestApprovalState] -> ShowS)
-> Show UpdatePullRequestApprovalState
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.
 UpdatePullRequestApprovalState
 -> Rep UpdatePullRequestApprovalState x)
-> (forall x.
    Rep UpdatePullRequestApprovalState x
    -> UpdatePullRequestApprovalState)
-> Generic UpdatePullRequestApprovalState
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' :: Text -> Text -> ApprovalState -> UpdatePullRequestApprovalState
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 :: (Text -> f Text)
-> UpdatePullRequestApprovalState
-> f UpdatePullRequestApprovalState
updatePullRequestApprovalState_pullRequestId = (UpdatePullRequestApprovalState -> Text)
-> (UpdatePullRequestApprovalState
    -> Text -> UpdatePullRequestApprovalState)
-> Lens
     UpdatePullRequestApprovalState
     UpdatePullRequestApprovalState
     Text
     Text
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 :: (Text -> f Text)
-> UpdatePullRequestApprovalState
-> f UpdatePullRequestApprovalState
updatePullRequestApprovalState_revisionId = (UpdatePullRequestApprovalState -> Text)
-> (UpdatePullRequestApprovalState
    -> Text -> UpdatePullRequestApprovalState)
-> Lens
     UpdatePullRequestApprovalState
     UpdatePullRequestApprovalState
     Text
     Text
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 :: (ApprovalState -> f ApprovalState)
-> UpdatePullRequestApprovalState
-> f UpdatePullRequestApprovalState
updatePullRequestApprovalState_approvalState = (UpdatePullRequestApprovalState -> ApprovalState)
-> (UpdatePullRequestApprovalState
    -> ApprovalState -> UpdatePullRequestApprovalState)
-> Lens
     UpdatePullRequestApprovalState
     UpdatePullRequestApprovalState
     ApprovalState
     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 :: UpdatePullRequestApprovalState
-> Request UpdatePullRequestApprovalState
request = Service
-> UpdatePullRequestApprovalState
-> Request UpdatePullRequestApprovalState
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdatePullRequestApprovalState
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse UpdatePullRequestApprovalState)))
response =
    AWSResponse UpdatePullRequestApprovalState
-> Logger
-> Service
-> Proxy UpdatePullRequestApprovalState
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse UpdatePullRequestApprovalState)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse UpdatePullRequestApprovalState
UpdatePullRequestApprovalStateResponse
UpdatePullRequestApprovalStateResponse'

instance
  Prelude.Hashable
    UpdatePullRequestApprovalState

instance
  Prelude.NFData
    UpdatePullRequestApprovalState

instance
  Core.ToHeaders
    UpdatePullRequestApprovalState
  where
  toHeaders :: UpdatePullRequestApprovalState -> [Header]
toHeaders =
    [Header] -> UpdatePullRequestApprovalState -> [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.UpdatePullRequestApprovalState" ::
                          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 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
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
"approvalState" Text -> ApprovalState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ApprovalState
approvalState)
          ]
      )

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

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

-- | /See:/ 'newUpdatePullRequestApprovalStateResponse' smart constructor.
data UpdatePullRequestApprovalStateResponse = UpdatePullRequestApprovalStateResponse'
  {
  }
  deriving (UpdatePullRequestApprovalStateResponse
-> UpdatePullRequestApprovalStateResponse -> Bool
(UpdatePullRequestApprovalStateResponse
 -> UpdatePullRequestApprovalStateResponse -> Bool)
-> (UpdatePullRequestApprovalStateResponse
    -> UpdatePullRequestApprovalStateResponse -> Bool)
-> Eq UpdatePullRequestApprovalStateResponse
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]
(Int -> ReadS UpdatePullRequestApprovalStateResponse)
-> ReadS [UpdatePullRequestApprovalStateResponse]
-> ReadPrec UpdatePullRequestApprovalStateResponse
-> ReadPrec [UpdatePullRequestApprovalStateResponse]
-> Read 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
(Int -> UpdatePullRequestApprovalStateResponse -> ShowS)
-> (UpdatePullRequestApprovalStateResponse -> String)
-> ([UpdatePullRequestApprovalStateResponse] -> ShowS)
-> Show UpdatePullRequestApprovalStateResponse
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.
 UpdatePullRequestApprovalStateResponse
 -> Rep UpdatePullRequestApprovalStateResponse x)
-> (forall x.
    Rep UpdatePullRequestApprovalStateResponse x
    -> UpdatePullRequestApprovalStateResponse)
-> Generic UpdatePullRequestApprovalStateResponse
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