{-# 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.UpdatePullRequestTitle
-- 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 title of a pull request.
module Amazonka.CodeCommit.UpdatePullRequestTitle
  ( -- * Creating a Request
    UpdatePullRequestTitle (..),
    newUpdatePullRequestTitle,

    -- * Request Lenses
    updatePullRequestTitle_pullRequestId,
    updatePullRequestTitle_title,

    -- * Destructuring the Response
    UpdatePullRequestTitleResponse (..),
    newUpdatePullRequestTitleResponse,

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

-- |
-- Create a value of 'UpdatePullRequestTitle' 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', 'updatePullRequestTitle_pullRequestId' - The system-generated ID of the pull request. To get this ID, use
-- ListPullRequests.
--
-- 'title', 'updatePullRequestTitle_title' - The updated title of the pull request. This replaces the existing title.
newUpdatePullRequestTitle ::
  -- | 'pullRequestId'
  Prelude.Text ->
  -- | 'title'
  Prelude.Text ->
  UpdatePullRequestTitle
newUpdatePullRequestTitle :: Text -> Text -> UpdatePullRequestTitle
newUpdatePullRequestTitle Text
pPullRequestId_ Text
pTitle_ =
  UpdatePullRequestTitle' :: Text -> Text -> UpdatePullRequestTitle
UpdatePullRequestTitle'
    { $sel:pullRequestId:UpdatePullRequestTitle' :: Text
pullRequestId =
        Text
pPullRequestId_,
      $sel:title:UpdatePullRequestTitle' :: Text
title = Text
pTitle_
    }

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

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

instance Core.AWSRequest UpdatePullRequestTitle where
  type
    AWSResponse UpdatePullRequestTitle =
      UpdatePullRequestTitleResponse
  request :: UpdatePullRequestTitle -> Request UpdatePullRequestTitle
request = Service -> UpdatePullRequestTitle -> Request UpdatePullRequestTitle
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdatePullRequestTitle
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdatePullRequestTitle)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdatePullRequestTitle))
-> Logger
-> Service
-> Proxy UpdatePullRequestTitle
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdatePullRequestTitle)))
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 -> UpdatePullRequestTitleResponse
UpdatePullRequestTitleResponse'
            (Int -> PullRequest -> UpdatePullRequestTitleResponse)
-> Either String Int
-> Either String (PullRequest -> UpdatePullRequestTitleResponse)
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 -> UpdatePullRequestTitleResponse)
-> Either String PullRequest
-> Either String UpdatePullRequestTitleResponse
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 UpdatePullRequestTitle

instance Prelude.NFData UpdatePullRequestTitle

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

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

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

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

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

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

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

instance
  Prelude.NFData
    UpdatePullRequestTitleResponse