{-# 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-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)
module Amazonka.WorkDocs.Types.Comment where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 status of the comment.
    Comment -> Maybe CommentStatusType
status :: Prelude.Maybe CommentStatusType,
    -- | The text of the comment.
    Comment -> Maybe (Sensitive Text)
text :: Prelude.Maybe (Core.Sensitive 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 root comment in the thread.
    Comment -> Maybe Text
threadId :: Prelude.Maybe Prelude.Text,
    -- | 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 Core.POSIX,
    -- | 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 ID of the parent comment.
    Comment -> Maybe Text
parentId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the comment.
    Comment -> Text
commentId :: Prelude.Text
  }
  deriving (Comment -> Comment -> Bool
(Comment -> Comment -> Bool)
-> (Comment -> Comment -> Bool) -> Eq Comment
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
(Int -> Comment -> ShowS)
-> (Comment -> String) -> ([Comment] -> ShowS) -> Show Comment
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. Comment -> Rep Comment x)
-> (forall x. Rep Comment x -> Comment) -> Generic Comment
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:
--
-- 'status', 'comment_status' - The status of the comment.
--
-- 'text', 'comment_text' - The text of the comment.
--
-- '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.
--
-- 'threadId', 'comment_threadId' - The ID of the root comment in the thread.
--
-- 'contributor', 'comment_contributor' - The details of the user who made the comment.
--
-- 'createdTimestamp', 'comment_createdTimestamp' - The time that the comment was created.
--
-- '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.
--
-- 'parentId', 'comment_parentId' - The ID of the parent comment.
--
-- 'commentId', 'comment_commentId' - The ID of the comment.
newComment ::
  -- | 'commentId'
  Prelude.Text ->
  Comment
newComment :: Text -> Comment
newComment Text
pCommentId_ =
  Comment' :: Maybe CommentStatusType
-> Maybe (Sensitive Text)
-> Maybe CommentVisibilityType
-> Maybe Text
-> Maybe User
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Text
-> Comment
Comment'
    { $sel:status:Comment' :: Maybe CommentStatusType
status = Maybe CommentStatusType
forall a. Maybe a
Prelude.Nothing,
      $sel:text:Comment' :: Maybe (Sensitive Text)
text = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:visibility:Comment' :: Maybe CommentVisibilityType
visibility = Maybe CommentVisibilityType
forall a. Maybe a
Prelude.Nothing,
      $sel:threadId:Comment' :: Maybe Text
threadId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contributor:Comment' :: Maybe User
contributor = Maybe User
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTimestamp:Comment' :: Maybe POSIX
createdTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:recipientId:Comment' :: Maybe Text
recipientId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parentId:Comment' :: Maybe Text
parentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:commentId:Comment' :: Text
commentId = Text
pCommentId_
    }

-- | The status of the comment.
comment_status :: Lens.Lens' Comment (Prelude.Maybe CommentStatusType)
comment_status :: (Maybe CommentStatusType -> f (Maybe CommentStatusType))
-> Comment -> f Comment
comment_status = (Comment -> Maybe CommentStatusType)
-> (Comment -> Maybe CommentStatusType -> Comment)
-> Lens
     Comment Comment (Maybe CommentStatusType) (Maybe CommentStatusType)
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 :: (Maybe Text -> f (Maybe Text)) -> Comment -> f Comment
comment_text = (Comment -> Maybe (Sensitive Text))
-> (Comment -> Maybe (Sensitive Text) -> Comment)
-> Lens
     Comment Comment (Maybe (Sensitive Text)) (Maybe (Sensitive 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) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> Comment -> f Comment)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> Comment
-> f Comment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | 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 :: (Maybe CommentVisibilityType -> f (Maybe CommentVisibilityType))
-> Comment -> f Comment
comment_visibility = (Comment -> Maybe CommentVisibilityType)
-> (Comment -> Maybe CommentVisibilityType -> Comment)
-> Lens
     Comment
     Comment
     (Maybe CommentVisibilityType)
     (Maybe CommentVisibilityType)
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 root comment in the thread.
comment_threadId :: Lens.Lens' Comment (Prelude.Maybe Prelude.Text)
comment_threadId :: (Maybe Text -> f (Maybe Text)) -> Comment -> f Comment
comment_threadId = (Comment -> Maybe Text)
-> (Comment -> Maybe Text -> Comment)
-> Lens Comment Comment (Maybe Text) (Maybe Text)
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 details of the user who made the comment.
comment_contributor :: Lens.Lens' Comment (Prelude.Maybe User)
comment_contributor :: (Maybe User -> f (Maybe User)) -> Comment -> f Comment
comment_contributor = (Comment -> Maybe User)
-> (Comment -> Maybe User -> Comment)
-> Lens Comment Comment (Maybe User) (Maybe User)
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 :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Comment -> f Comment
comment_createdTimestamp = (Comment -> Maybe POSIX)
-> (Comment -> Maybe POSIX -> Comment)
-> Lens Comment Comment (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> Comment -> f Comment)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Comment
-> f Comment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Comment -> f Comment
comment_recipientId = (Comment -> Maybe Text)
-> (Comment -> Maybe Text -> Comment)
-> Lens Comment Comment (Maybe Text) (Maybe Text)
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 ID of the parent comment.
comment_parentId :: Lens.Lens' Comment (Prelude.Maybe Prelude.Text)
comment_parentId :: (Maybe Text -> f (Maybe Text)) -> Comment -> f Comment
comment_parentId = (Comment -> Maybe Text)
-> (Comment -> Maybe Text -> Comment)
-> Lens Comment Comment (Maybe Text) (Maybe Text)
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)

-- | The ID of the comment.
comment_commentId :: Lens.Lens' Comment Prelude.Text
comment_commentId :: (Text -> f Text) -> Comment -> f Comment
comment_commentId = (Comment -> Text)
-> (Comment -> Text -> Comment) -> Lens Comment Comment Text Text
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 Core.FromJSON Comment where
  parseJSON :: Value -> Parser Comment
parseJSON =
    String -> (Object -> Parser Comment) -> Value -> Parser Comment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Comment"
      ( \Object
x ->
          Maybe CommentStatusType
-> Maybe (Sensitive Text)
-> Maybe CommentVisibilityType
-> Maybe Text
-> Maybe User
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Text
-> Comment
Comment'
            (Maybe CommentStatusType
 -> Maybe (Sensitive Text)
 -> Maybe CommentVisibilityType
 -> Maybe Text
 -> Maybe User
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Text
 -> Comment)
-> Parser (Maybe CommentStatusType)
-> Parser
     (Maybe (Sensitive Text)
      -> Maybe CommentVisibilityType
      -> Maybe Text
      -> Maybe User
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Comment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CommentStatusType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe (Sensitive Text)
   -> Maybe CommentVisibilityType
   -> Maybe Text
   -> Maybe User
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Comment)
-> Parser (Maybe (Sensitive Text))
-> Parser
     (Maybe CommentVisibilityType
      -> Maybe Text
      -> Maybe User
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Comment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Text")
            Parser
  (Maybe CommentVisibilityType
   -> Maybe Text
   -> Maybe User
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Comment)
-> Parser (Maybe CommentVisibilityType)
-> Parser
     (Maybe Text
      -> Maybe User
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Comment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CommentVisibilityType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Visibility")
            Parser
  (Maybe Text
   -> Maybe User
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Comment)
-> Parser (Maybe Text)
-> Parser
     (Maybe User
      -> Maybe POSIX -> Maybe Text -> Maybe Text -> Text -> Comment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ThreadId")
            Parser
  (Maybe User
   -> Maybe POSIX -> Maybe Text -> Maybe Text -> Text -> Comment)
-> Parser (Maybe User)
-> Parser
     (Maybe POSIX -> Maybe Text -> Maybe Text -> Text -> Comment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe User)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Contributor")
            Parser (Maybe POSIX -> Maybe Text -> Maybe Text -> Text -> Comment)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> Text -> Comment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreatedTimestamp")
            Parser (Maybe Text -> Maybe Text -> Text -> Comment)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Text -> Comment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RecipientId")
            Parser (Maybe Text -> Text -> Comment)
-> Parser (Maybe Text) -> Parser (Text -> Comment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ParentId")
            Parser (Text -> Comment) -> Parser Text -> Parser Comment
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CommentId")
      )

instance Prelude.Hashable Comment

instance Prelude.NFData Comment