{-# 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.SecurityHub.Types.Note
-- 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.SecurityHub.Types.Note where

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

-- | A user-defined note added to a finding.
--
-- /See:/ 'newNote' smart constructor.
data Note = Note'
  { -- | The text of a note.
    Note -> Text
text :: Prelude.Text,
    -- | The principal that created a note.
    Note -> Text
updatedBy :: Prelude.Text,
    -- | The timestamp of when the note was updated.
    --
    -- Uses the @date-time@ format specified in
    -- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
    -- The value cannot contain spaces. For example,
    -- @2020-03-22T13:22:13.933Z@.
    Note -> Text
updatedAt :: Prelude.Text
  }
  deriving (Note -> Note -> Bool
(Note -> Note -> Bool) -> (Note -> Note -> Bool) -> Eq Note
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Note -> Note -> Bool
$c/= :: Note -> Note -> Bool
== :: Note -> Note -> Bool
$c== :: Note -> Note -> Bool
Prelude.Eq, ReadPrec [Note]
ReadPrec Note
Int -> ReadS Note
ReadS [Note]
(Int -> ReadS Note)
-> ReadS [Note] -> ReadPrec Note -> ReadPrec [Note] -> Read Note
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Note]
$creadListPrec :: ReadPrec [Note]
readPrec :: ReadPrec Note
$creadPrec :: ReadPrec Note
readList :: ReadS [Note]
$creadList :: ReadS [Note]
readsPrec :: Int -> ReadS Note
$creadsPrec :: Int -> ReadS Note
Prelude.Read, Int -> Note -> ShowS
[Note] -> ShowS
Note -> String
(Int -> Note -> ShowS)
-> (Note -> String) -> ([Note] -> ShowS) -> Show Note
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Note] -> ShowS
$cshowList :: [Note] -> ShowS
show :: Note -> String
$cshow :: Note -> String
showsPrec :: Int -> Note -> ShowS
$cshowsPrec :: Int -> Note -> ShowS
Prelude.Show, (forall x. Note -> Rep Note x)
-> (forall x. Rep Note x -> Note) -> Generic Note
forall x. Rep Note x -> Note
forall x. Note -> Rep Note x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Note x -> Note
$cfrom :: forall x. Note -> Rep Note x
Prelude.Generic)

-- |
-- Create a value of 'Note' 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:
--
-- 'text', 'note_text' - The text of a note.
--
-- 'updatedBy', 'note_updatedBy' - The principal that created a note.
--
-- 'updatedAt', 'note_updatedAt' - The timestamp of when the note was updated.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
newNote ::
  -- | 'text'
  Prelude.Text ->
  -- | 'updatedBy'
  Prelude.Text ->
  -- | 'updatedAt'
  Prelude.Text ->
  Note
newNote :: Text -> Text -> Text -> Note
newNote Text
pText_ Text
pUpdatedBy_ Text
pUpdatedAt_ =
  Note' :: Text -> Text -> Text -> Note
Note'
    { $sel:text:Note' :: Text
text = Text
pText_,
      $sel:updatedBy:Note' :: Text
updatedBy = Text
pUpdatedBy_,
      $sel:updatedAt:Note' :: Text
updatedAt = Text
pUpdatedAt_
    }

-- | The text of a note.
note_text :: Lens.Lens' Note Prelude.Text
note_text :: (Text -> f Text) -> Note -> f Note
note_text = (Note -> Text)
-> (Note -> Text -> Note) -> Lens Note Note Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Note' {Text
text :: Text
$sel:text:Note' :: Note -> Text
text} -> Text
text) (\s :: Note
s@Note' {} Text
a -> Note
s {$sel:text:Note' :: Text
text = Text
a} :: Note)

-- | The principal that created a note.
note_updatedBy :: Lens.Lens' Note Prelude.Text
note_updatedBy :: (Text -> f Text) -> Note -> f Note
note_updatedBy = (Note -> Text)
-> (Note -> Text -> Note) -> Lens Note Note Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Note' {Text
updatedBy :: Text
$sel:updatedBy:Note' :: Note -> Text
updatedBy} -> Text
updatedBy) (\s :: Note
s@Note' {} Text
a -> Note
s {$sel:updatedBy:Note' :: Text
updatedBy = Text
a} :: Note)

-- | The timestamp of when the note was updated.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
note_updatedAt :: Lens.Lens' Note Prelude.Text
note_updatedAt :: (Text -> f Text) -> Note -> f Note
note_updatedAt = (Note -> Text)
-> (Note -> Text -> Note) -> Lens Note Note Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Note' {Text
updatedAt :: Text
$sel:updatedAt:Note' :: Note -> Text
updatedAt} -> Text
updatedAt) (\s :: Note
s@Note' {} Text
a -> Note
s {$sel:updatedAt:Note' :: Text
updatedAt = Text
a} :: Note)

instance Core.FromJSON Note where
  parseJSON :: Value -> Parser Note
parseJSON =
    String -> (Object -> Parser Note) -> Value -> Parser Note
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Note"
      ( \Object
x ->
          Text -> Text -> Text -> Note
Note'
            (Text -> Text -> Text -> Note)
-> Parser Text -> Parser (Text -> Text -> Note)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Text")
            Parser (Text -> Text -> Note)
-> Parser Text -> Parser (Text -> Note)
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
"UpdatedBy")
            Parser (Text -> Note) -> Parser Text -> Parser Note
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
"UpdatedAt")
      )

instance Prelude.Hashable Note

instance Prelude.NFData Note

instance Core.ToJSON Note where
  toJSON :: Note -> Value
toJSON Note' {Text
updatedAt :: Text
updatedBy :: Text
text :: Text
$sel:updatedAt:Note' :: Note -> Text
$sel:updatedBy:Note' :: Note -> Text
$sel:text:Note' :: Note -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Text" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
text),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UpdatedBy" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
updatedBy),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UpdatedAt" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
updatedAt)
          ]
      )