{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ '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
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]
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
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. 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' {$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 :: Lens' DeleteCommentContent Text
deleteCommentContent_commentId = 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 :: (Service -> Service)
-> DeleteCommentContent -> Request DeleteCommentContent
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 DeleteCommentContent
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCommentContent)))
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 ->
          Maybe Comment -> Int -> DeleteCommentContentResponse
DeleteCommentContentResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"comment")
            forall (f :: * -> *) a b. Applicative f => 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))
      )

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

instance Prelude.NFData DeleteCommentContent where
  rnf :: DeleteCommentContent -> ()
rnf DeleteCommentContent' {Text
commentId :: Text
$sel:commentId:DeleteCommentContent' :: DeleteCommentContent -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
commentId

instance Data.ToHeaders DeleteCommentContent where
  toHeaders :: DeleteCommentContent -> 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.DeleteCommentContent" ::
                          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 DeleteCommentContent where
  toJSON :: DeleteCommentContent -> Value
toJSON DeleteCommentContent' {Text
commentId :: Text
$sel:commentId:DeleteCommentContent' :: DeleteCommentContent -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"commentId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
commentId)]
      )

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

instance Data.ToQuery DeleteCommentContent where
  toQuery :: DeleteCommentContent -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:comment:DeleteCommentContentResponse' :: Maybe Comment
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 :: Lens' DeleteCommentContentResponse (Maybe Comment)
deleteCommentContentResponse_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 :: Lens' DeleteCommentContentResponse Int
deleteCommentContentResponse_httpStatus = 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 where
  rnf :: DeleteCommentContentResponse -> ()
rnf DeleteCommentContentResponse' {Int
Maybe Comment
httpStatus :: Int
comment :: Maybe Comment
$sel:httpStatus:DeleteCommentContentResponse' :: DeleteCommentContentResponse -> Int
$sel:comment:DeleteCommentContentResponse' :: DeleteCommentContentResponse -> Maybe Comment
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Comment
comment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus