{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AuditManager.Types.ControlComment 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

-- | A comment that\'s 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 body text of a control comment.
    ControlComment -> Maybe Text
commentBody :: Prelude.Maybe Prelude.Text,
    -- | The time when the comment was posted.
    ControlComment -> Maybe POSIX
postedDate :: Prelude.Maybe Data.POSIX
  }
  deriving (ControlComment -> ControlComment -> Bool
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]
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
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. 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.
--
-- 'commentBody', 'controlComment_commentBody' - The body text of a control comment.
--
-- 'postedDate', 'controlComment_postedDate' - The time when the comment was posted.
newControlComment ::
  ControlComment
newControlComment :: ControlComment
newControlComment =
  ControlComment'
    { $sel:authorName:ControlComment' :: Maybe Text
authorName = forall a. Maybe a
Prelude.Nothing,
      $sel:commentBody:ControlComment' :: Maybe Text
commentBody = forall a. Maybe a
Prelude.Nothing,
      $sel:postedDate:ControlComment' :: Maybe POSIX
postedDate = 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 :: Lens' ControlComment (Maybe Text)
controlComment_authorName = 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 body text of a control comment.
controlComment_commentBody :: Lens.Lens' ControlComment (Prelude.Maybe Prelude.Text)
controlComment_commentBody :: Lens' ControlComment (Maybe Text)
controlComment_commentBody = 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)

-- | The time when the comment was posted.
controlComment_postedDate :: Lens.Lens' ControlComment (Prelude.Maybe Prelude.UTCTime)
controlComment_postedDate :: Lens' ControlComment (Maybe UTCTime)
controlComment_postedDate = 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) 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

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

instance Prelude.Hashable ControlComment where
  hashWithSalt :: Int -> ControlComment -> Int
hashWithSalt Int
_salt ControlComment' {Maybe Text
Maybe POSIX
postedDate :: Maybe POSIX
commentBody :: Maybe Text
authorName :: Maybe Text
$sel:postedDate:ControlComment' :: ControlComment -> Maybe POSIX
$sel:commentBody:ControlComment' :: ControlComment -> Maybe Text
$sel:authorName:ControlComment' :: ControlComment -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
authorName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
commentBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
postedDate

instance Prelude.NFData ControlComment where
  rnf :: ControlComment -> ()
rnf ControlComment' {Maybe Text
Maybe POSIX
postedDate :: Maybe POSIX
commentBody :: Maybe Text
authorName :: Maybe Text
$sel:postedDate:ControlComment' :: ControlComment -> Maybe POSIX
$sel:commentBody:ControlComment' :: ControlComment -> Maybe Text
$sel:authorName:ControlComment' :: ControlComment -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
authorName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
commentBody
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
postedDate