{-# 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.SSM.Types.DocumentReviewCommentSource
-- 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.SSM.Types.DocumentReviewCommentSource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.DocumentReviewCommentType

-- | Information about comments added to a document review request.
--
-- /See:/ 'newDocumentReviewCommentSource' smart constructor.
data DocumentReviewCommentSource = DocumentReviewCommentSource'
  { -- | The content of a comment entered by a user who requests a review of a
    -- new document version, or who reviews the new version.
    DocumentReviewCommentSource -> Maybe Text
content :: Prelude.Maybe Prelude.Text,
    -- | The type of information added to a review request. Currently, only the
    -- value @Comment@ is supported.
    DocumentReviewCommentSource -> Maybe DocumentReviewCommentType
type' :: Prelude.Maybe DocumentReviewCommentType
  }
  deriving (DocumentReviewCommentSource -> DocumentReviewCommentSource -> Bool
(DocumentReviewCommentSource
 -> DocumentReviewCommentSource -> Bool)
-> (DocumentReviewCommentSource
    -> DocumentReviewCommentSource -> Bool)
-> Eq DocumentReviewCommentSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentReviewCommentSource -> DocumentReviewCommentSource -> Bool
$c/= :: DocumentReviewCommentSource -> DocumentReviewCommentSource -> Bool
== :: DocumentReviewCommentSource -> DocumentReviewCommentSource -> Bool
$c== :: DocumentReviewCommentSource -> DocumentReviewCommentSource -> Bool
Prelude.Eq, ReadPrec [DocumentReviewCommentSource]
ReadPrec DocumentReviewCommentSource
Int -> ReadS DocumentReviewCommentSource
ReadS [DocumentReviewCommentSource]
(Int -> ReadS DocumentReviewCommentSource)
-> ReadS [DocumentReviewCommentSource]
-> ReadPrec DocumentReviewCommentSource
-> ReadPrec [DocumentReviewCommentSource]
-> Read DocumentReviewCommentSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentReviewCommentSource]
$creadListPrec :: ReadPrec [DocumentReviewCommentSource]
readPrec :: ReadPrec DocumentReviewCommentSource
$creadPrec :: ReadPrec DocumentReviewCommentSource
readList :: ReadS [DocumentReviewCommentSource]
$creadList :: ReadS [DocumentReviewCommentSource]
readsPrec :: Int -> ReadS DocumentReviewCommentSource
$creadsPrec :: Int -> ReadS DocumentReviewCommentSource
Prelude.Read, Int -> DocumentReviewCommentSource -> ShowS
[DocumentReviewCommentSource] -> ShowS
DocumentReviewCommentSource -> String
(Int -> DocumentReviewCommentSource -> ShowS)
-> (DocumentReviewCommentSource -> String)
-> ([DocumentReviewCommentSource] -> ShowS)
-> Show DocumentReviewCommentSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentReviewCommentSource] -> ShowS
$cshowList :: [DocumentReviewCommentSource] -> ShowS
show :: DocumentReviewCommentSource -> String
$cshow :: DocumentReviewCommentSource -> String
showsPrec :: Int -> DocumentReviewCommentSource -> ShowS
$cshowsPrec :: Int -> DocumentReviewCommentSource -> ShowS
Prelude.Show, (forall x.
 DocumentReviewCommentSource -> Rep DocumentReviewCommentSource x)
-> (forall x.
    Rep DocumentReviewCommentSource x -> DocumentReviewCommentSource)
-> Generic DocumentReviewCommentSource
forall x.
Rep DocumentReviewCommentSource x -> DocumentReviewCommentSource
forall x.
DocumentReviewCommentSource -> Rep DocumentReviewCommentSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DocumentReviewCommentSource x -> DocumentReviewCommentSource
$cfrom :: forall x.
DocumentReviewCommentSource -> Rep DocumentReviewCommentSource x
Prelude.Generic)

-- |
-- Create a value of 'DocumentReviewCommentSource' 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:
--
-- 'content', 'documentReviewCommentSource_content' - The content of a comment entered by a user who requests a review of a
-- new document version, or who reviews the new version.
--
-- 'type'', 'documentReviewCommentSource_type' - The type of information added to a review request. Currently, only the
-- value @Comment@ is supported.
newDocumentReviewCommentSource ::
  DocumentReviewCommentSource
newDocumentReviewCommentSource :: DocumentReviewCommentSource
newDocumentReviewCommentSource =
  DocumentReviewCommentSource' :: Maybe Text
-> Maybe DocumentReviewCommentType -> DocumentReviewCommentSource
DocumentReviewCommentSource'
    { $sel:content:DocumentReviewCommentSource' :: Maybe Text
content =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':DocumentReviewCommentSource' :: Maybe DocumentReviewCommentType
type' = Maybe DocumentReviewCommentType
forall a. Maybe a
Prelude.Nothing
    }

-- | The content of a comment entered by a user who requests a review of a
-- new document version, or who reviews the new version.
documentReviewCommentSource_content :: Lens.Lens' DocumentReviewCommentSource (Prelude.Maybe Prelude.Text)
documentReviewCommentSource_content :: (Maybe Text -> f (Maybe Text))
-> DocumentReviewCommentSource -> f DocumentReviewCommentSource
documentReviewCommentSource_content = (DocumentReviewCommentSource -> Maybe Text)
-> (DocumentReviewCommentSource
    -> Maybe Text -> DocumentReviewCommentSource)
-> Lens
     DocumentReviewCommentSource
     DocumentReviewCommentSource
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentReviewCommentSource' {Maybe Text
content :: Maybe Text
$sel:content:DocumentReviewCommentSource' :: DocumentReviewCommentSource -> Maybe Text
content} -> Maybe Text
content) (\s :: DocumentReviewCommentSource
s@DocumentReviewCommentSource' {} Maybe Text
a -> DocumentReviewCommentSource
s {$sel:content:DocumentReviewCommentSource' :: Maybe Text
content = Maybe Text
a} :: DocumentReviewCommentSource)

-- | The type of information added to a review request. Currently, only the
-- value @Comment@ is supported.
documentReviewCommentSource_type :: Lens.Lens' DocumentReviewCommentSource (Prelude.Maybe DocumentReviewCommentType)
documentReviewCommentSource_type :: (Maybe DocumentReviewCommentType
 -> f (Maybe DocumentReviewCommentType))
-> DocumentReviewCommentSource -> f DocumentReviewCommentSource
documentReviewCommentSource_type = (DocumentReviewCommentSource -> Maybe DocumentReviewCommentType)
-> (DocumentReviewCommentSource
    -> Maybe DocumentReviewCommentType -> DocumentReviewCommentSource)
-> Lens
     DocumentReviewCommentSource
     DocumentReviewCommentSource
     (Maybe DocumentReviewCommentType)
     (Maybe DocumentReviewCommentType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentReviewCommentSource' {Maybe DocumentReviewCommentType
type' :: Maybe DocumentReviewCommentType
$sel:type':DocumentReviewCommentSource' :: DocumentReviewCommentSource -> Maybe DocumentReviewCommentType
type'} -> Maybe DocumentReviewCommentType
type') (\s :: DocumentReviewCommentSource
s@DocumentReviewCommentSource' {} Maybe DocumentReviewCommentType
a -> DocumentReviewCommentSource
s {$sel:type':DocumentReviewCommentSource' :: Maybe DocumentReviewCommentType
type' = Maybe DocumentReviewCommentType
a} :: DocumentReviewCommentSource)

instance Core.FromJSON DocumentReviewCommentSource where
  parseJSON :: Value -> Parser DocumentReviewCommentSource
parseJSON =
    String
-> (Object -> Parser DocumentReviewCommentSource)
-> Value
-> Parser DocumentReviewCommentSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DocumentReviewCommentSource"
      ( \Object
x ->
          Maybe Text
-> Maybe DocumentReviewCommentType -> DocumentReviewCommentSource
DocumentReviewCommentSource'
            (Maybe Text
 -> Maybe DocumentReviewCommentType -> DocumentReviewCommentSource)
-> Parser (Maybe Text)
-> Parser
     (Maybe DocumentReviewCommentType -> DocumentReviewCommentSource)
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
"Content")
            Parser
  (Maybe DocumentReviewCommentType -> DocumentReviewCommentSource)
-> Parser (Maybe DocumentReviewCommentType)
-> Parser DocumentReviewCommentSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DocumentReviewCommentType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable DocumentReviewCommentSource

instance Prelude.NFData DocumentReviewCommentSource

instance Core.ToJSON DocumentReviewCommentSource where
  toJSON :: DocumentReviewCommentSource -> Value
toJSON DocumentReviewCommentSource' {Maybe Text
Maybe DocumentReviewCommentType
type' :: Maybe DocumentReviewCommentType
content :: Maybe Text
$sel:type':DocumentReviewCommentSource' :: DocumentReviewCommentSource -> Maybe DocumentReviewCommentType
$sel:content:DocumentReviewCommentSource' :: DocumentReviewCommentSource -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Content" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
content,
            (Text
"Type" Text -> DocumentReviewCommentType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DocumentReviewCommentType -> Pair)
-> Maybe DocumentReviewCommentType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DocumentReviewCommentType
type'
          ]
      )