{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ '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
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]
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
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.
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'
      { $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 :: Lens' UpdatePullRequestDescription Text
updatePullRequestDescription_pullRequestId = 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 :: Lens' UpdatePullRequestDescription Text
updatePullRequestDescription_description = 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 :: (Service -> Service)
-> UpdatePullRequestDescription
-> Request UpdatePullRequestDescription
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 UpdatePullRequestDescription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdatePullRequestDescription)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> PullRequest -> UpdatePullRequestDescriptionResponse
UpdatePullRequestDescriptionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"pullRequest")
      )

instance
  Prelude.Hashable
    UpdatePullRequestDescription
  where
  hashWithSalt :: Int -> UpdatePullRequestDescription -> Int
hashWithSalt Int
_salt UpdatePullRequestDescription' {Text
description :: Text
pullRequestId :: Text
$sel:description:UpdatePullRequestDescription' :: UpdatePullRequestDescription -> Text
$sel:pullRequestId:UpdatePullRequestDescription' :: UpdatePullRequestDescription -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
pullRequestId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
description

instance Prelude.NFData UpdatePullRequestDescription where
  rnf :: UpdatePullRequestDescription -> ()
rnf UpdatePullRequestDescription' {Text
description :: Text
pullRequestId :: Text
$sel:description:UpdatePullRequestDescription' :: UpdatePullRequestDescription -> Text
$sel:pullRequestId:UpdatePullRequestDescription' :: UpdatePullRequestDescription -> 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
description

instance Data.ToHeaders UpdatePullRequestDescription where
  toHeaders :: UpdatePullRequestDescription -> ResponseHeaders
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 -> ResponseHeaders
Data.=# ( ByteString
"CodeCommit_20150413.UpdatePullRequestDescription" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.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
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
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
description)
          ]
      )

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

instance Data.ToQuery UpdatePullRequestDescription where
  toQuery :: UpdatePullRequestDescription -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
      { $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 :: Lens' UpdatePullRequestDescriptionResponse Int
updatePullRequestDescriptionResponse_httpStatus = 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 :: Lens' UpdatePullRequestDescriptionResponse PullRequest
updatePullRequestDescriptionResponse_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
  where
  rnf :: UpdatePullRequestDescriptionResponse -> ()
rnf UpdatePullRequestDescriptionResponse' {Int
PullRequest
pullRequest :: PullRequest
httpStatus :: Int
$sel:pullRequest:UpdatePullRequestDescriptionResponse' :: UpdatePullRequestDescriptionResponse -> PullRequest
$sel:httpStatus:UpdatePullRequestDescriptionResponse' :: UpdatePullRequestDescriptionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PullRequest
pullRequest