{-# 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.UpdatePullRequestDescription
-- 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)
--
-- Replaces the contents of the description of a pull request.
module Amazonka.CodeCommit.UpdatePullRequestDescription
  ( -- * Creating a Request
    UpdatePullRequestDescription (..),
    newUpdatePullRequestDescription,

    -- * Request Lenses
    updatePullRequestDescription_pullRequestId,
    updatePullRequestDescription_description,

    -- * Destructuring the Response
    UpdatePullRequestDescriptionResponse (..),
    newUpdatePullRequestDescriptionResponse,

    -- * Response Lenses
    updatePullRequestDescriptionResponse_httpStatus,
    updatePullRequestDescriptionResponse_pullRequest,
  )
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:/ 'newUpdatePullRequestDescription' smart constructor.
data UpdatePullRequestDescription = UpdatePullRequestDescription'
  { -- | The system-generated ID of the pull request. To get this ID, use
    -- ListPullRequests.
    UpdatePullRequestDescription -> Text
pullRequestId :: Prelude.Text,
    -- | The updated content of the description for the pull request. This
    -- content replaces the existing description.
    UpdatePullRequestDescription -> Text
description :: Prelude.Text
  }
  deriving (UpdatePullRequestDescription
-> UpdatePullRequestDescription -> Bool
(UpdatePullRequestDescription
 -> UpdatePullRequestDescription -> Bool)
-> (UpdatePullRequestDescription
    -> UpdatePullRequestDescription -> Bool)
-> Eq UpdatePullRequestDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePullRequestDescription
-> UpdatePullRequestDescription -> Bool
$c/= :: UpdatePullRequestDescription
-> UpdatePullRequestDescription -> Bool
== :: UpdatePullRequestDescription
-> UpdatePullRequestDescription -> Bool
$c== :: UpdatePullRequestDescription
-> UpdatePullRequestDescription -> Bool
Prelude.Eq, ReadPrec [UpdatePullRequestDescription]
ReadPrec UpdatePullRequestDescription
Int -> ReadS UpdatePullRequestDescription
ReadS [UpdatePullRequestDescription]
(Int -> ReadS UpdatePullRequestDescription)
-> ReadS [UpdatePullRequestDescription]
-> ReadPrec UpdatePullRequestDescription
-> ReadPrec [UpdatePullRequestDescription]
-> Read UpdatePullRequestDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePullRequestDescription]
$creadListPrec :: ReadPrec [UpdatePullRequestDescription]
readPrec :: ReadPrec UpdatePullRequestDescription
$creadPrec :: ReadPrec UpdatePullRequestDescription
readList :: ReadS [UpdatePullRequestDescription]
$creadList :: ReadS [UpdatePullRequestDescription]
readsPrec :: Int -> ReadS UpdatePullRequestDescription
$creadsPrec :: Int -> ReadS UpdatePullRequestDescription
Prelude.Read, Int -> UpdatePullRequestDescription -> ShowS
[UpdatePullRequestDescription] -> ShowS
UpdatePullRequestDescription -> String
(Int -> UpdatePullRequestDescription -> ShowS)
-> (UpdatePullRequestDescription -> String)
-> ([UpdatePullRequestDescription] -> ShowS)
-> Show UpdatePullRequestDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePullRequestDescription] -> ShowS
$cshowList :: [UpdatePullRequestDescription] -> ShowS
show :: UpdatePullRequestDescription -> String
$cshow :: UpdatePullRequestDescription -> String
showsPrec :: Int -> UpdatePullRequestDescription -> ShowS
$cshowsPrec :: Int -> UpdatePullRequestDescription -> ShowS
Prelude.Show, (forall x.
 UpdatePullRequestDescription -> Rep UpdatePullRequestDescription x)
-> (forall x.
    Rep UpdatePullRequestDescription x -> UpdatePullRequestDescription)
-> Generic UpdatePullRequestDescription
forall x.
Rep UpdatePullRequestDescription x -> UpdatePullRequestDescription
forall x.
UpdatePullRequestDescription -> Rep UpdatePullRequestDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePullRequestDescription x -> UpdatePullRequestDescription
$cfrom :: forall x.
UpdatePullRequestDescription -> Rep UpdatePullRequestDescription x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePullRequestDescription' 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', 'updatePullRequestDescription_pullRequestId' - The system-generated ID of the pull request. To get this ID, use
-- ListPullRequests.
--
-- 'description', 'updatePullRequestDescription_description' - The updated content of the description for the pull request. This
-- content replaces the existing description.
newUpdatePullRequestDescription ::
  -- | 'pullRequestId'
  Prelude.Text ->
  -- | 'description'
  Prelude.Text ->
  UpdatePullRequestDescription
newUpdatePullRequestDescription :: Text -> Text -> UpdatePullRequestDescription
newUpdatePullRequestDescription
  Text
pPullRequestId_
  Text
pDescription_ =
    UpdatePullRequestDescription' :: Text -> Text -> UpdatePullRequestDescription
UpdatePullRequestDescription'
      { $sel:pullRequestId:UpdatePullRequestDescription' :: Text
pullRequestId =
          Text
pPullRequestId_,
        $sel:description:UpdatePullRequestDescription' :: Text
description = Text
pDescription_
      }

-- | The system-generated ID of the pull request. To get this ID, use
-- ListPullRequests.
updatePullRequestDescription_pullRequestId :: Lens.Lens' UpdatePullRequestDescription Prelude.Text
updatePullRequestDescription_pullRequestId :: (Text -> f Text)
-> UpdatePullRequestDescription -> f UpdatePullRequestDescription
updatePullRequestDescription_pullRequestId = (UpdatePullRequestDescription -> Text)
-> (UpdatePullRequestDescription
    -> Text -> UpdatePullRequestDescription)
-> Lens
     UpdatePullRequestDescription UpdatePullRequestDescription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePullRequestDescription' {Text
pullRequestId :: Text
$sel:pullRequestId:UpdatePullRequestDescription' :: UpdatePullRequestDescription -> Text
pullRequestId} -> Text
pullRequestId) (\s :: UpdatePullRequestDescription
s@UpdatePullRequestDescription' {} Text
a -> UpdatePullRequestDescription
s {$sel:pullRequestId:UpdatePullRequestDescription' :: Text
pullRequestId = Text
a} :: UpdatePullRequestDescription)

-- | The updated content of the description for the pull request. This
-- content replaces the existing description.
updatePullRequestDescription_description :: Lens.Lens' UpdatePullRequestDescription Prelude.Text
updatePullRequestDescription_description :: (Text -> f Text)
-> UpdatePullRequestDescription -> f UpdatePullRequestDescription
updatePullRequestDescription_description = (UpdatePullRequestDescription -> Text)
-> (UpdatePullRequestDescription
    -> Text -> UpdatePullRequestDescription)
-> Lens
     UpdatePullRequestDescription UpdatePullRequestDescription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePullRequestDescription' {Text
description :: Text
$sel:description:UpdatePullRequestDescription' :: UpdatePullRequestDescription -> Text
description} -> Text
description) (\s :: UpdatePullRequestDescription
s@UpdatePullRequestDescription' {} Text
a -> UpdatePullRequestDescription
s {$sel:description:UpdatePullRequestDescription' :: Text
description = Text
a} :: UpdatePullRequestDescription)

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

instance
  Prelude.Hashable
    UpdatePullRequestDescription

instance Prelude.NFData UpdatePullRequestDescription

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

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

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

-- | /See:/ 'newUpdatePullRequestDescriptionResponse' smart constructor.
data UpdatePullRequestDescriptionResponse = UpdatePullRequestDescriptionResponse'
  { -- | The response's http status code.
    UpdatePullRequestDescriptionResponse -> Int
httpStatus :: Prelude.Int,
    -- | Information about the updated pull request.
    UpdatePullRequestDescriptionResponse -> PullRequest
pullRequest :: PullRequest
  }
  deriving (UpdatePullRequestDescriptionResponse
-> UpdatePullRequestDescriptionResponse -> Bool
(UpdatePullRequestDescriptionResponse
 -> UpdatePullRequestDescriptionResponse -> Bool)
-> (UpdatePullRequestDescriptionResponse
    -> UpdatePullRequestDescriptionResponse -> Bool)
-> Eq UpdatePullRequestDescriptionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePullRequestDescriptionResponse
-> UpdatePullRequestDescriptionResponse -> Bool
$c/= :: UpdatePullRequestDescriptionResponse
-> UpdatePullRequestDescriptionResponse -> Bool
== :: UpdatePullRequestDescriptionResponse
-> UpdatePullRequestDescriptionResponse -> Bool
$c== :: UpdatePullRequestDescriptionResponse
-> UpdatePullRequestDescriptionResponse -> Bool
Prelude.Eq, ReadPrec [UpdatePullRequestDescriptionResponse]
ReadPrec UpdatePullRequestDescriptionResponse
Int -> ReadS UpdatePullRequestDescriptionResponse
ReadS [UpdatePullRequestDescriptionResponse]
(Int -> ReadS UpdatePullRequestDescriptionResponse)
-> ReadS [UpdatePullRequestDescriptionResponse]
-> ReadPrec UpdatePullRequestDescriptionResponse
-> ReadPrec [UpdatePullRequestDescriptionResponse]
-> Read UpdatePullRequestDescriptionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePullRequestDescriptionResponse]
$creadListPrec :: ReadPrec [UpdatePullRequestDescriptionResponse]
readPrec :: ReadPrec UpdatePullRequestDescriptionResponse
$creadPrec :: ReadPrec UpdatePullRequestDescriptionResponse
readList :: ReadS [UpdatePullRequestDescriptionResponse]
$creadList :: ReadS [UpdatePullRequestDescriptionResponse]
readsPrec :: Int -> ReadS UpdatePullRequestDescriptionResponse
$creadsPrec :: Int -> ReadS UpdatePullRequestDescriptionResponse
Prelude.Read, Int -> UpdatePullRequestDescriptionResponse -> ShowS
[UpdatePullRequestDescriptionResponse] -> ShowS
UpdatePullRequestDescriptionResponse -> String
(Int -> UpdatePullRequestDescriptionResponse -> ShowS)
-> (UpdatePullRequestDescriptionResponse -> String)
-> ([UpdatePullRequestDescriptionResponse] -> ShowS)
-> Show UpdatePullRequestDescriptionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePullRequestDescriptionResponse] -> ShowS
$cshowList :: [UpdatePullRequestDescriptionResponse] -> ShowS
show :: UpdatePullRequestDescriptionResponse -> String
$cshow :: UpdatePullRequestDescriptionResponse -> String
showsPrec :: Int -> UpdatePullRequestDescriptionResponse -> ShowS
$cshowsPrec :: Int -> UpdatePullRequestDescriptionResponse -> ShowS
Prelude.Show, (forall x.
 UpdatePullRequestDescriptionResponse
 -> Rep UpdatePullRequestDescriptionResponse x)
-> (forall x.
    Rep UpdatePullRequestDescriptionResponse x
    -> UpdatePullRequestDescriptionResponse)
-> Generic UpdatePullRequestDescriptionResponse
forall x.
Rep UpdatePullRequestDescriptionResponse x
-> UpdatePullRequestDescriptionResponse
forall x.
UpdatePullRequestDescriptionResponse
-> Rep UpdatePullRequestDescriptionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePullRequestDescriptionResponse x
-> UpdatePullRequestDescriptionResponse
$cfrom :: forall x.
UpdatePullRequestDescriptionResponse
-> Rep UpdatePullRequestDescriptionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePullRequestDescriptionResponse' 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', 'updatePullRequestDescriptionResponse_httpStatus' - The response's http status code.
--
-- 'pullRequest', 'updatePullRequestDescriptionResponse_pullRequest' - Information about the updated pull request.
newUpdatePullRequestDescriptionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'pullRequest'
  PullRequest ->
  UpdatePullRequestDescriptionResponse
newUpdatePullRequestDescriptionResponse :: Int -> PullRequest -> UpdatePullRequestDescriptionResponse
newUpdatePullRequestDescriptionResponse
  Int
pHttpStatus_
  PullRequest
pPullRequest_ =
    UpdatePullRequestDescriptionResponse' :: Int -> PullRequest -> UpdatePullRequestDescriptionResponse
UpdatePullRequestDescriptionResponse'
      { $sel:httpStatus:UpdatePullRequestDescriptionResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:pullRequest:UpdatePullRequestDescriptionResponse' :: PullRequest
pullRequest = PullRequest
pPullRequest_
      }

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

-- | Information about the updated pull request.
updatePullRequestDescriptionResponse_pullRequest :: Lens.Lens' UpdatePullRequestDescriptionResponse PullRequest
updatePullRequestDescriptionResponse_pullRequest :: (PullRequest -> f PullRequest)
-> UpdatePullRequestDescriptionResponse
-> f UpdatePullRequestDescriptionResponse
updatePullRequestDescriptionResponse_pullRequest = (UpdatePullRequestDescriptionResponse -> PullRequest)
-> (UpdatePullRequestDescriptionResponse
    -> PullRequest -> UpdatePullRequestDescriptionResponse)
-> Lens
     UpdatePullRequestDescriptionResponse
     UpdatePullRequestDescriptionResponse
     PullRequest
     PullRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePullRequestDescriptionResponse' {PullRequest
pullRequest :: PullRequest
$sel:pullRequest:UpdatePullRequestDescriptionResponse' :: UpdatePullRequestDescriptionResponse -> PullRequest
pullRequest} -> PullRequest
pullRequest) (\s :: UpdatePullRequestDescriptionResponse
s@UpdatePullRequestDescriptionResponse' {} PullRequest
a -> UpdatePullRequestDescriptionResponse
s {$sel:pullRequest:UpdatePullRequestDescriptionResponse' :: PullRequest
pullRequest = PullRequest
a} :: UpdatePullRequestDescriptionResponse)

instance
  Prelude.NFData
    UpdatePullRequestDescriptionResponse