{-# 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.DeleteCommentContent
-- 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)
--
-- Deletes the content of a comment made on a change, file, or commit in a
-- repository.
module Amazonka.CodeCommit.DeleteCommentContent
  ( -- * Creating a Request
    DeleteCommentContent (..),
    newDeleteCommentContent,

    -- * Request Lenses
    deleteCommentContent_commentId,

    -- * Destructuring the Response
    DeleteCommentContentResponse (..),
    newDeleteCommentContentResponse,

    -- * Response Lenses
    deleteCommentContentResponse_comment,
    deleteCommentContentResponse_httpStatus,
  )
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:/ 'newDeleteCommentContent' smart constructor.
data DeleteCommentContent = DeleteCommentContent'
  { -- | The unique, system-generated ID of the comment. To get this ID, use
    -- GetCommentsForComparedCommit or GetCommentsForPullRequest.
    DeleteCommentContent -> Text
commentId :: Prelude.Text
  }
  deriving (DeleteCommentContent -> DeleteCommentContent -> Bool
(DeleteCommentContent -> DeleteCommentContent -> Bool)
-> (DeleteCommentContent -> DeleteCommentContent -> Bool)
-> Eq DeleteCommentContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCommentContent -> DeleteCommentContent -> Bool
$c/= :: DeleteCommentContent -> DeleteCommentContent -> Bool
== :: DeleteCommentContent -> DeleteCommentContent -> Bool
$c== :: DeleteCommentContent -> DeleteCommentContent -> Bool
Prelude.Eq, ReadPrec [DeleteCommentContent]
ReadPrec DeleteCommentContent
Int -> ReadS DeleteCommentContent
ReadS [DeleteCommentContent]
(Int -> ReadS DeleteCommentContent)
-> ReadS [DeleteCommentContent]
-> ReadPrec DeleteCommentContent
-> ReadPrec [DeleteCommentContent]
-> Read DeleteCommentContent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCommentContent]
$creadListPrec :: ReadPrec [DeleteCommentContent]
readPrec :: ReadPrec DeleteCommentContent
$creadPrec :: ReadPrec DeleteCommentContent
readList :: ReadS [DeleteCommentContent]
$creadList :: ReadS [DeleteCommentContent]
readsPrec :: Int -> ReadS DeleteCommentContent
$creadsPrec :: Int -> ReadS DeleteCommentContent
Prelude.Read, Int -> DeleteCommentContent -> ShowS
[DeleteCommentContent] -> ShowS
DeleteCommentContent -> String
(Int -> DeleteCommentContent -> ShowS)
-> (DeleteCommentContent -> String)
-> ([DeleteCommentContent] -> ShowS)
-> Show DeleteCommentContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCommentContent] -> ShowS
$cshowList :: [DeleteCommentContent] -> ShowS
show :: DeleteCommentContent -> String
$cshow :: DeleteCommentContent -> String
showsPrec :: Int -> DeleteCommentContent -> ShowS
$cshowsPrec :: Int -> DeleteCommentContent -> ShowS
Prelude.Show, (forall x. DeleteCommentContent -> Rep DeleteCommentContent x)
-> (forall x. Rep DeleteCommentContent x -> DeleteCommentContent)
-> Generic DeleteCommentContent
forall x. Rep DeleteCommentContent x -> DeleteCommentContent
forall x. DeleteCommentContent -> Rep DeleteCommentContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCommentContent x -> DeleteCommentContent
$cfrom :: forall x. DeleteCommentContent -> Rep DeleteCommentContent x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCommentContent' 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:
--
-- 'commentId', 'deleteCommentContent_commentId' - The unique, system-generated ID of the comment. To get this ID, use
-- GetCommentsForComparedCommit or GetCommentsForPullRequest.
newDeleteCommentContent ::
  -- | 'commentId'
  Prelude.Text ->
  DeleteCommentContent
newDeleteCommentContent :: Text -> DeleteCommentContent
newDeleteCommentContent Text
pCommentId_ =
  DeleteCommentContent' :: Text -> DeleteCommentContent
DeleteCommentContent' {$sel:commentId:DeleteCommentContent' :: Text
commentId = Text
pCommentId_}

-- | The unique, system-generated ID of the comment. To get this ID, use
-- GetCommentsForComparedCommit or GetCommentsForPullRequest.
deleteCommentContent_commentId :: Lens.Lens' DeleteCommentContent Prelude.Text
deleteCommentContent_commentId :: (Text -> f Text) -> DeleteCommentContent -> f DeleteCommentContent
deleteCommentContent_commentId = (DeleteCommentContent -> Text)
-> (DeleteCommentContent -> Text -> DeleteCommentContent)
-> Lens DeleteCommentContent DeleteCommentContent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCommentContent' {Text
commentId :: Text
$sel:commentId:DeleteCommentContent' :: DeleteCommentContent -> Text
commentId} -> Text
commentId) (\s :: DeleteCommentContent
s@DeleteCommentContent' {} Text
a -> DeleteCommentContent
s {$sel:commentId:DeleteCommentContent' :: Text
commentId = Text
a} :: DeleteCommentContent)

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

instance Prelude.Hashable DeleteCommentContent

instance Prelude.NFData DeleteCommentContent

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

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

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

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

-- |
-- Create a value of 'DeleteCommentContentResponse' 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:
--
-- 'comment', 'deleteCommentContentResponse_comment' - Information about the comment you just deleted.
--
-- 'httpStatus', 'deleteCommentContentResponse_httpStatus' - The response's http status code.
newDeleteCommentContentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteCommentContentResponse
newDeleteCommentContentResponse :: Int -> DeleteCommentContentResponse
newDeleteCommentContentResponse Int
pHttpStatus_ =
  DeleteCommentContentResponse' :: Maybe Comment -> Int -> DeleteCommentContentResponse
DeleteCommentContentResponse'
    { $sel:comment:DeleteCommentContentResponse' :: Maybe Comment
comment =
        Maybe Comment
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteCommentContentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the comment you just deleted.
deleteCommentContentResponse_comment :: Lens.Lens' DeleteCommentContentResponse (Prelude.Maybe Comment)
deleteCommentContentResponse_comment :: (Maybe Comment -> f (Maybe Comment))
-> DeleteCommentContentResponse -> f DeleteCommentContentResponse
deleteCommentContentResponse_comment = (DeleteCommentContentResponse -> Maybe Comment)
-> (DeleteCommentContentResponse
    -> Maybe Comment -> DeleteCommentContentResponse)
-> Lens
     DeleteCommentContentResponse
     DeleteCommentContentResponse
     (Maybe Comment)
     (Maybe Comment)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCommentContentResponse' {Maybe Comment
comment :: Maybe Comment
$sel:comment:DeleteCommentContentResponse' :: DeleteCommentContentResponse -> Maybe Comment
comment} -> Maybe Comment
comment) (\s :: DeleteCommentContentResponse
s@DeleteCommentContentResponse' {} Maybe Comment
a -> DeleteCommentContentResponse
s {$sel:comment:DeleteCommentContentResponse' :: Maybe Comment
comment = Maybe Comment
a} :: DeleteCommentContentResponse)

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

instance Prelude.NFData DeleteCommentContentResponse