{-# 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.AuditManager.Types.ControlComment
-- 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.AuditManager.Types.ControlComment where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A comment posted by a user on a control. This includes the author\'s
-- name, the comment text, and a timestamp.
--
-- /See:/ 'newControlComment' smart constructor.
data ControlComment = ControlComment'
  { -- | The name of the user who authored the comment.
    ControlComment -> Maybe Text
authorName :: Prelude.Maybe Prelude.Text,
    -- | The time when the comment was posted.
    ControlComment -> Maybe POSIX
postedDate :: Prelude.Maybe Core.POSIX,
    -- | The body text of a control comment.
    ControlComment -> Maybe Text
commentBody :: Prelude.Maybe Prelude.Text
  }
  deriving (ControlComment -> ControlComment -> Bool
(ControlComment -> ControlComment -> Bool)
-> (ControlComment -> ControlComment -> Bool) -> Eq ControlComment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ControlComment -> ControlComment -> Bool
$c/= :: ControlComment -> ControlComment -> Bool
== :: ControlComment -> ControlComment -> Bool
$c== :: ControlComment -> ControlComment -> Bool
Prelude.Eq, ReadPrec [ControlComment]
ReadPrec ControlComment
Int -> ReadS ControlComment
ReadS [ControlComment]
(Int -> ReadS ControlComment)
-> ReadS [ControlComment]
-> ReadPrec ControlComment
-> ReadPrec [ControlComment]
-> Read ControlComment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ControlComment]
$creadListPrec :: ReadPrec [ControlComment]
readPrec :: ReadPrec ControlComment
$creadPrec :: ReadPrec ControlComment
readList :: ReadS [ControlComment]
$creadList :: ReadS [ControlComment]
readsPrec :: Int -> ReadS ControlComment
$creadsPrec :: Int -> ReadS ControlComment
Prelude.Read, Int -> ControlComment -> ShowS
[ControlComment] -> ShowS
ControlComment -> String
(Int -> ControlComment -> ShowS)
-> (ControlComment -> String)
-> ([ControlComment] -> ShowS)
-> Show ControlComment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ControlComment] -> ShowS
$cshowList :: [ControlComment] -> ShowS
show :: ControlComment -> String
$cshow :: ControlComment -> String
showsPrec :: Int -> ControlComment -> ShowS
$cshowsPrec :: Int -> ControlComment -> ShowS
Prelude.Show, (forall x. ControlComment -> Rep ControlComment x)
-> (forall x. Rep ControlComment x -> ControlComment)
-> Generic ControlComment
forall x. Rep ControlComment x -> ControlComment
forall x. ControlComment -> Rep ControlComment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ControlComment x -> ControlComment
$cfrom :: forall x. ControlComment -> Rep ControlComment x
Prelude.Generic)

-- |
-- Create a value of 'ControlComment' 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:
--
-- 'authorName', 'controlComment_authorName' - The name of the user who authored the comment.
--
-- 'postedDate', 'controlComment_postedDate' - The time when the comment was posted.
--
-- 'commentBody', 'controlComment_commentBody' - The body text of a control comment.
newControlComment ::
  ControlComment
newControlComment :: ControlComment
newControlComment =
  ControlComment' :: Maybe Text -> Maybe POSIX -> Maybe Text -> ControlComment
ControlComment'
    { $sel:authorName:ControlComment' :: Maybe Text
authorName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:postedDate:ControlComment' :: Maybe POSIX
postedDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:commentBody:ControlComment' :: Maybe Text
commentBody = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the user who authored the comment.
controlComment_authorName :: Lens.Lens' ControlComment (Prelude.Maybe Prelude.Text)
controlComment_authorName :: (Maybe Text -> f (Maybe Text))
-> ControlComment -> f ControlComment
controlComment_authorName = (ControlComment -> Maybe Text)
-> (ControlComment -> Maybe Text -> ControlComment)
-> Lens ControlComment ControlComment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlComment' {Maybe Text
authorName :: Maybe Text
$sel:authorName:ControlComment' :: ControlComment -> Maybe Text
authorName} -> Maybe Text
authorName) (\s :: ControlComment
s@ControlComment' {} Maybe Text
a -> ControlComment
s {$sel:authorName:ControlComment' :: Maybe Text
authorName = Maybe Text
a} :: ControlComment)

-- | The time when the comment was posted.
controlComment_postedDate :: Lens.Lens' ControlComment (Prelude.Maybe Prelude.UTCTime)
controlComment_postedDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ControlComment -> f ControlComment
controlComment_postedDate = (ControlComment -> Maybe POSIX)
-> (ControlComment -> Maybe POSIX -> ControlComment)
-> Lens ControlComment ControlComment (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlComment' {Maybe POSIX
postedDate :: Maybe POSIX
$sel:postedDate:ControlComment' :: ControlComment -> Maybe POSIX
postedDate} -> Maybe POSIX
postedDate) (\s :: ControlComment
s@ControlComment' {} Maybe POSIX
a -> ControlComment
s {$sel:postedDate:ControlComment' :: Maybe POSIX
postedDate = Maybe POSIX
a} :: ControlComment) ((Maybe POSIX -> f (Maybe POSIX))
 -> ControlComment -> f ControlComment)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ControlComment
-> f ControlComment
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 body text of a control comment.
controlComment_commentBody :: Lens.Lens' ControlComment (Prelude.Maybe Prelude.Text)
controlComment_commentBody :: (Maybe Text -> f (Maybe Text))
-> ControlComment -> f ControlComment
controlComment_commentBody = (ControlComment -> Maybe Text)
-> (ControlComment -> Maybe Text -> ControlComment)
-> Lens ControlComment ControlComment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ControlComment' {Maybe Text
commentBody :: Maybe Text
$sel:commentBody:ControlComment' :: ControlComment -> Maybe Text
commentBody} -> Maybe Text
commentBody) (\s :: ControlComment
s@ControlComment' {} Maybe Text
a -> ControlComment
s {$sel:commentBody:ControlComment' :: Maybe Text
commentBody = Maybe Text
a} :: ControlComment)

instance Core.FromJSON ControlComment where
  parseJSON :: Value -> Parser ControlComment
parseJSON =
    String
-> (Object -> Parser ControlComment)
-> Value
-> Parser ControlComment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ControlComment"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> Maybe Text -> ControlComment
ControlComment'
            (Maybe Text -> Maybe POSIX -> Maybe Text -> ControlComment)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> ControlComment)
forall (f :: * -> *) a b. Functor 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
"authorName")
            Parser (Maybe POSIX -> Maybe Text -> ControlComment)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> ControlComment)
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
"postedDate")
            Parser (Maybe Text -> ControlComment)
-> Parser (Maybe Text) -> Parser ControlComment
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
"commentBody")
      )

instance Prelude.Hashable ControlComment

instance Prelude.NFData ControlComment