{-# 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.CommentMetadata
-- 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.CommentMetadata 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.User

-- | Describes the metadata of a comment.
--
-- /See:/ 'newCommentMetadata' smart constructor.
data CommentMetadata = CommentMetadata'
  { -- | The status of the comment.
    CommentMetadata -> Maybe CommentStatusType
commentStatus :: Prelude.Maybe CommentStatusType,
    -- | The user who made the comment.
    CommentMetadata -> Maybe User
contributor :: Prelude.Maybe User,
    -- | The ID of the comment.
    CommentMetadata -> Maybe Text
commentId :: Prelude.Maybe Prelude.Text,
    -- | The timestamp that the comment was created.
    CommentMetadata -> Maybe POSIX
createdTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The ID of the user being replied to.
    CommentMetadata -> Maybe Text
recipientId :: Prelude.Maybe Prelude.Text
  }
  deriving (CommentMetadata -> CommentMetadata -> Bool
(CommentMetadata -> CommentMetadata -> Bool)
-> (CommentMetadata -> CommentMetadata -> Bool)
-> Eq CommentMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CommentMetadata -> CommentMetadata -> Bool
$c/= :: CommentMetadata -> CommentMetadata -> Bool
== :: CommentMetadata -> CommentMetadata -> Bool
$c== :: CommentMetadata -> CommentMetadata -> Bool
Prelude.Eq, ReadPrec [CommentMetadata]
ReadPrec CommentMetadata
Int -> ReadS CommentMetadata
ReadS [CommentMetadata]
(Int -> ReadS CommentMetadata)
-> ReadS [CommentMetadata]
-> ReadPrec CommentMetadata
-> ReadPrec [CommentMetadata]
-> Read CommentMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CommentMetadata]
$creadListPrec :: ReadPrec [CommentMetadata]
readPrec :: ReadPrec CommentMetadata
$creadPrec :: ReadPrec CommentMetadata
readList :: ReadS [CommentMetadata]
$creadList :: ReadS [CommentMetadata]
readsPrec :: Int -> ReadS CommentMetadata
$creadsPrec :: Int -> ReadS CommentMetadata
Prelude.Read, Int -> CommentMetadata -> ShowS
[CommentMetadata] -> ShowS
CommentMetadata -> String
(Int -> CommentMetadata -> ShowS)
-> (CommentMetadata -> String)
-> ([CommentMetadata] -> ShowS)
-> Show CommentMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CommentMetadata] -> ShowS
$cshowList :: [CommentMetadata] -> ShowS
show :: CommentMetadata -> String
$cshow :: CommentMetadata -> String
showsPrec :: Int -> CommentMetadata -> ShowS
$cshowsPrec :: Int -> CommentMetadata -> ShowS
Prelude.Show, (forall x. CommentMetadata -> Rep CommentMetadata x)
-> (forall x. Rep CommentMetadata x -> CommentMetadata)
-> Generic CommentMetadata
forall x. Rep CommentMetadata x -> CommentMetadata
forall x. CommentMetadata -> Rep CommentMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CommentMetadata x -> CommentMetadata
$cfrom :: forall x. CommentMetadata -> Rep CommentMetadata x
Prelude.Generic)

-- |
-- Create a value of 'CommentMetadata' 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:
--
-- 'commentStatus', 'commentMetadata_commentStatus' - The status of the comment.
--
-- 'contributor', 'commentMetadata_contributor' - The user who made the comment.
--
-- 'commentId', 'commentMetadata_commentId' - The ID of the comment.
--
-- 'createdTimestamp', 'commentMetadata_createdTimestamp' - The timestamp that the comment was created.
--
-- 'recipientId', 'commentMetadata_recipientId' - The ID of the user being replied to.
newCommentMetadata ::
  CommentMetadata
newCommentMetadata :: CommentMetadata
newCommentMetadata =
  CommentMetadata' :: Maybe CommentStatusType
-> Maybe User
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> CommentMetadata
CommentMetadata'
    { $sel:commentStatus:CommentMetadata' :: Maybe CommentStatusType
commentStatus = Maybe CommentStatusType
forall a. Maybe a
Prelude.Nothing,
      $sel:contributor:CommentMetadata' :: Maybe User
contributor = Maybe User
forall a. Maybe a
Prelude.Nothing,
      $sel:commentId:CommentMetadata' :: Maybe Text
commentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTimestamp:CommentMetadata' :: Maybe POSIX
createdTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:recipientId:CommentMetadata' :: Maybe Text
recipientId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

-- | The timestamp that the comment was created.
commentMetadata_createdTimestamp :: Lens.Lens' CommentMetadata (Prelude.Maybe Prelude.UTCTime)
commentMetadata_createdTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CommentMetadata -> f CommentMetadata
commentMetadata_createdTimestamp = (CommentMetadata -> Maybe POSIX)
-> (CommentMetadata -> Maybe POSIX -> CommentMetadata)
-> Lens CommentMetadata CommentMetadata (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentMetadata' {Maybe POSIX
createdTimestamp :: Maybe POSIX
$sel:createdTimestamp:CommentMetadata' :: CommentMetadata -> Maybe POSIX
createdTimestamp} -> Maybe POSIX
createdTimestamp) (\s :: CommentMetadata
s@CommentMetadata' {} Maybe POSIX
a -> CommentMetadata
s {$sel:createdTimestamp:CommentMetadata' :: Maybe POSIX
createdTimestamp = Maybe POSIX
a} :: CommentMetadata) ((Maybe POSIX -> f (Maybe POSIX))
 -> CommentMetadata -> f CommentMetadata)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CommentMetadata
-> f CommentMetadata
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

-- | The ID of the user being replied to.
commentMetadata_recipientId :: Lens.Lens' CommentMetadata (Prelude.Maybe Prelude.Text)
commentMetadata_recipientId :: (Maybe Text -> f (Maybe Text))
-> CommentMetadata -> f CommentMetadata
commentMetadata_recipientId = (CommentMetadata -> Maybe Text)
-> (CommentMetadata -> Maybe Text -> CommentMetadata)
-> Lens CommentMetadata CommentMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentMetadata' {Maybe Text
recipientId :: Maybe Text
$sel:recipientId:CommentMetadata' :: CommentMetadata -> Maybe Text
recipientId} -> Maybe Text
recipientId) (\s :: CommentMetadata
s@CommentMetadata' {} Maybe Text
a -> CommentMetadata
s {$sel:recipientId:CommentMetadata' :: Maybe Text
recipientId = Maybe Text
a} :: CommentMetadata)

instance Core.FromJSON CommentMetadata where
  parseJSON :: Value -> Parser CommentMetadata
parseJSON =
    String
-> (Object -> Parser CommentMetadata)
-> Value
-> Parser CommentMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CommentMetadata"
      ( \Object
x ->
          Maybe CommentStatusType
-> Maybe User
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> CommentMetadata
CommentMetadata'
            (Maybe CommentStatusType
 -> Maybe User
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> CommentMetadata)
-> Parser (Maybe CommentStatusType)
-> Parser
     (Maybe User
      -> Maybe Text -> Maybe POSIX -> Maybe Text -> CommentMetadata)
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
"CommentStatus")
            Parser
  (Maybe User
   -> Maybe Text -> Maybe POSIX -> Maybe Text -> CommentMetadata)
-> Parser (Maybe User)
-> Parser
     (Maybe Text -> Maybe POSIX -> Maybe Text -> CommentMetadata)
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 Text -> Maybe POSIX -> Maybe Text -> CommentMetadata)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> CommentMetadata)
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
"CommentId")
            Parser (Maybe POSIX -> Maybe Text -> CommentMetadata)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> CommentMetadata)
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 -> CommentMetadata)
-> Parser (Maybe Text) -> Parser CommentMetadata
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")
      )

instance Prelude.Hashable CommentMetadata

instance Prelude.NFData CommentMetadata