{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.WorkDocs.Types.Comment
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.WorkDocs.Types.Comment where

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 Amazonka.WorkDocs.Types.CommentStatusType
import Amazonka.WorkDocs.Types.CommentVisibilityType
import Amazonka.WorkDocs.Types.User

-- | Describes a comment.
--
-- /See:/ 'newComment' smart constructor.
data Comment = Comment'
  { -- | The details of the user who made the comment.
    Comment -> Maybe User
contributor :: Prelude.Maybe User,
    -- | The time that the comment was created.
    Comment -> Maybe POSIX
createdTimestamp :: Prelude.Maybe Data.POSIX,
    -- | The ID of the parent comment.
    Comment -> Maybe Text
parentId :: Prelude.Maybe Prelude.Text,
    -- | If the comment is a reply to another user\'s comment, this field
    -- contains the user ID of the user being replied to.
    Comment -> Maybe Text
recipientId :: Prelude.Maybe Prelude.Text,
    -- | The status of the comment.
    Comment -> Maybe CommentStatusType
status :: Prelude.Maybe CommentStatusType,
    -- | The text of the comment.
    Comment -> Maybe (Sensitive Text)
text :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The ID of the root comment in the thread.
    Comment -> Maybe Text
threadId :: Prelude.Maybe Prelude.Text,
    -- | The visibility of the comment. Options are either PRIVATE, where the
    -- comment is visible only to the comment author and document owner and
    -- co-owners, or PUBLIC, where the comment is visible to document owners,
    -- co-owners, and contributors.
    Comment -> Maybe CommentVisibilityType
visibility :: Prelude.Maybe CommentVisibilityType,
    -- | The ID of the comment.
    Comment -> Text
commentId :: Prelude.Text
  }
  deriving (Comment -> Comment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Comment -> Comment -> Bool
$c/= :: Comment -> Comment -> Bool
== :: Comment -> Comment -> Bool
$c== :: Comment -> Comment -> Bool
Prelude.Eq, Int -> Comment -> ShowS
[Comment] -> ShowS
Comment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Comment] -> ShowS
$cshowList :: [Comment] -> ShowS
show :: Comment -> String
$cshow :: Comment -> String
showsPrec :: Int -> Comment -> ShowS
$cshowsPrec :: Int -> Comment -> ShowS
Prelude.Show, forall x. Rep Comment x -> Comment
forall x. Comment -> Rep Comment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Comment x -> Comment
$cfrom :: forall x. Comment -> Rep Comment x
Prelude.Generic)

-- |
-- Create a value of 'Comment' 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:
--
-- 'contributor', 'comment_contributor' - The details of the user who made the comment.
--
-- 'createdTimestamp', 'comment_createdTimestamp' - The time that the comment was created.
--
-- 'parentId', 'comment_parentId' - The ID of the parent comment.
--
-- 'recipientId', 'comment_recipientId' - If the comment is a reply to another user\'s comment, this field
-- contains the user ID of the user being replied to.
--
-- 'status', 'comment_status' - The status of the comment.
--
-- 'text', 'comment_text' - The text of the comment.
--
-- 'threadId', 'comment_threadId' - The ID of the root comment in the thread.
--
-- 'visibility', 'comment_visibility' - The visibility of the comment. Options are either PRIVATE, where the
-- comment is visible only to the comment author and document owner and
-- co-owners, or PUBLIC, where the comment is visible to document owners,
-- co-owners, and contributors.
--
-- 'commentId', 'comment_commentId' - The ID of the comment.
newComment ::
  -- | 'commentId'
  Prelude.Text ->
  Comment
newComment :: Text -> Comment
newComment Text
pCommentId_ =
  Comment'
    { $sel:contributor:Comment' :: Maybe User
contributor = forall a. Maybe a
Prelude.Nothing,
      $sel:createdTimestamp:Comment' :: Maybe POSIX
createdTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:parentId:Comment' :: Maybe Text
parentId = forall a. Maybe a
Prelude.Nothing,
      $sel:recipientId:Comment' :: Maybe Text
recipientId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Comment' :: Maybe CommentStatusType
status = forall a. Maybe a
Prelude.Nothing,
      $sel:text:Comment' :: Maybe (Sensitive Text)
text = forall a. Maybe a
Prelude.Nothing,
      $sel:threadId:Comment' :: Maybe Text
threadId = forall a. Maybe a
Prelude.Nothing,
      $sel:visibility:Comment' :: Maybe CommentVisibilityType
visibility = forall a. Maybe a
Prelude.Nothing,
      $sel:commentId:Comment' :: Text
commentId = Text
pCommentId_
    }

-- | The details of the user who made the comment.
comment_contributor :: Lens.Lens' Comment (Prelude.Maybe User)
comment_contributor :: Lens' Comment (Maybe User)
comment_contributor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Maybe User
contributor :: Maybe User
$sel:contributor:Comment' :: Comment -> Maybe User
contributor} -> Maybe User
contributor) (\s :: Comment
s@Comment' {} Maybe User
a -> Comment
s {$sel:contributor:Comment' :: Maybe User
contributor = Maybe User
a} :: Comment)

-- | The time that the comment was created.
comment_createdTimestamp :: Lens.Lens' Comment (Prelude.Maybe Prelude.UTCTime)
comment_createdTimestamp :: Lens' Comment (Maybe UTCTime)
comment_createdTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Maybe POSIX
createdTimestamp :: Maybe POSIX
$sel:createdTimestamp:Comment' :: Comment -> Maybe POSIX
createdTimestamp} -> Maybe POSIX
createdTimestamp) (\s :: Comment
s@Comment' {} Maybe POSIX
a -> Comment
s {$sel:createdTimestamp:Comment' :: Maybe POSIX
createdTimestamp = Maybe POSIX
a} :: Comment) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The ID of the parent comment.
comment_parentId :: Lens.Lens' Comment (Prelude.Maybe Prelude.Text)
comment_parentId :: Lens' Comment (Maybe Text)
comment_parentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Maybe Text
parentId :: Maybe Text
$sel:parentId:Comment' :: Comment -> Maybe Text
parentId} -> Maybe Text
parentId) (\s :: Comment
s@Comment' {} Maybe Text
a -> Comment
s {$sel:parentId:Comment' :: Maybe Text
parentId = Maybe Text
a} :: Comment)

-- | If the comment is a reply to another user\'s comment, this field
-- contains the user ID of the user being replied to.
comment_recipientId :: Lens.Lens' Comment (Prelude.Maybe Prelude.Text)
comment_recipientId :: Lens' Comment (Maybe Text)
comment_recipientId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Maybe Text
recipientId :: Maybe Text
$sel:recipientId:Comment' :: Comment -> Maybe Text
recipientId} -> Maybe Text
recipientId) (\s :: Comment
s@Comment' {} Maybe Text
a -> Comment
s {$sel:recipientId:Comment' :: Maybe Text
recipientId = Maybe Text
a} :: Comment)

-- | The status of the comment.
comment_status :: Lens.Lens' Comment (Prelude.Maybe CommentStatusType)
comment_status :: Lens' Comment (Maybe CommentStatusType)
comment_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Maybe CommentStatusType
status :: Maybe CommentStatusType
$sel:status:Comment' :: Comment -> Maybe CommentStatusType
status} -> Maybe CommentStatusType
status) (\s :: Comment
s@Comment' {} Maybe CommentStatusType
a -> Comment
s {$sel:status:Comment' :: Maybe CommentStatusType
status = Maybe CommentStatusType
a} :: Comment)

-- | The text of the comment.
comment_text :: Lens.Lens' Comment (Prelude.Maybe Prelude.Text)
comment_text :: Lens' Comment (Maybe Text)
comment_text = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Maybe (Sensitive Text)
text :: Maybe (Sensitive Text)
$sel:text:Comment' :: Comment -> Maybe (Sensitive Text)
text} -> Maybe (Sensitive Text)
text) (\s :: Comment
s@Comment' {} Maybe (Sensitive Text)
a -> Comment
s {$sel:text:Comment' :: Maybe (Sensitive Text)
text = Maybe (Sensitive Text)
a} :: Comment) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The ID of the root comment in the thread.
comment_threadId :: Lens.Lens' Comment (Prelude.Maybe Prelude.Text)
comment_threadId :: Lens' Comment (Maybe Text)
comment_threadId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Maybe Text
threadId :: Maybe Text
$sel:threadId:Comment' :: Comment -> Maybe Text
threadId} -> Maybe Text
threadId) (\s :: Comment
s@Comment' {} Maybe Text
a -> Comment
s {$sel:threadId:Comment' :: Maybe Text
threadId = Maybe Text
a} :: Comment)

-- | The visibility of the comment. Options are either PRIVATE, where the
-- comment is visible only to the comment author and document owner and
-- co-owners, or PUBLIC, where the comment is visible to document owners,
-- co-owners, and contributors.
comment_visibility :: Lens.Lens' Comment (Prelude.Maybe CommentVisibilityType)
comment_visibility :: Lens' Comment (Maybe CommentVisibilityType)
comment_visibility = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Maybe CommentVisibilityType
visibility :: Maybe CommentVisibilityType
$sel:visibility:Comment' :: Comment -> Maybe CommentVisibilityType
visibility} -> Maybe CommentVisibilityType
visibility) (\s :: Comment
s@Comment' {} Maybe CommentVisibilityType
a -> Comment
s {$sel:visibility:Comment' :: Maybe CommentVisibilityType
visibility = Maybe CommentVisibilityType
a} :: Comment)

-- | The ID of the comment.
comment_commentId :: Lens.Lens' Comment Prelude.Text
comment_commentId :: Lens' Comment Text
comment_commentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Comment' {Text
commentId :: Text
$sel:commentId:Comment' :: Comment -> Text
commentId} -> Text
commentId) (\s :: Comment
s@Comment' {} Text
a -> Comment
s {$sel:commentId:Comment' :: Text
commentId = Text
a} :: Comment)

instance Data.FromJSON Comment where
  parseJSON :: Value -> Parser Comment
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Comment"
      ( \Object
x ->
          Maybe User
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe CommentStatusType
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe CommentVisibilityType
-> Text
-> Comment
Comment'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Contributor")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreatedTimestamp")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ParentId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RecipientId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Text")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ThreadId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Visibility")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"CommentId")
      )

instance Prelude.Hashable Comment where
  hashWithSalt :: Int -> Comment -> Int
hashWithSalt Int
_salt Comment' {Maybe Text
Maybe (Sensitive Text)
Maybe POSIX
Maybe CommentStatusType
Maybe CommentVisibilityType
Maybe User
Text
commentId :: Text
visibility :: Maybe CommentVisibilityType
threadId :: Maybe Text
text :: Maybe (Sensitive Text)
status :: Maybe CommentStatusType
recipientId :: Maybe Text
parentId :: Maybe Text
createdTimestamp :: Maybe POSIX
contributor :: Maybe User
$sel:commentId:Comment' :: Comment -> Text
$sel:visibility:Comment' :: Comment -> Maybe CommentVisibilityType
$sel:threadId:Comment' :: Comment -> Maybe Text
$sel:text:Comment' :: Comment -> Maybe (Sensitive Text)
$sel:status:Comment' :: Comment -> Maybe CommentStatusType
$sel:recipientId:Comment' :: Comment -> Maybe Text
$sel:parentId:Comment' :: Comment -> Maybe Text
$sel:createdTimestamp:Comment' :: Comment -> Maybe POSIX
$sel:contributor:Comment' :: Comment -> Maybe User
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe User
contributor
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parentId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recipientId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CommentStatusType
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
text
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
threadId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CommentVisibilityType
visibility
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
commentId

instance Prelude.NFData Comment where
  rnf :: Comment -> ()
rnf Comment' {Maybe Text
Maybe (Sensitive Text)
Maybe POSIX
Maybe CommentStatusType
Maybe CommentVisibilityType
Maybe User
Text
commentId :: Text
visibility :: Maybe CommentVisibilityType
threadId :: Maybe Text
text :: Maybe (Sensitive Text)
status :: Maybe CommentStatusType
recipientId :: Maybe Text
parentId :: Maybe Text
createdTimestamp :: Maybe POSIX
contributor :: Maybe User
$sel:commentId:Comment' :: Comment -> Text
$sel:visibility:Comment' :: Comment -> Maybe CommentVisibilityType
$sel:threadId:Comment' :: Comment -> Maybe Text
$sel:text:Comment' :: Comment -> Maybe (Sensitive Text)
$sel:status:Comment' :: Comment -> Maybe CommentStatusType
$sel:recipientId:Comment' :: Comment -> Maybe Text
$sel:parentId:Comment' :: Comment -> Maybe Text
$sel:createdTimestamp:Comment' :: Comment -> Maybe POSIX
$sel:contributor:Comment' :: Comment -> Maybe User
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe User
contributor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parentId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recipientId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CommentStatusType
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
text
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
threadId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CommentVisibilityType
visibility
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
commentId