{-# 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.DocumentReviews
-- 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.SSM.Types.DocumentReviews 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
import Amazonka.SSM.Types.DocumentReviewAction
import Amazonka.SSM.Types.DocumentReviewCommentSource

-- | Information about a document approval review.
--
-- /See:/ 'newDocumentReviews' smart constructor.
data DocumentReviews = DocumentReviews'
  { -- | A comment entered by a user in your organization about the document
    -- review request.
    DocumentReviews -> Maybe [DocumentReviewCommentSource]
comment :: Prelude.Maybe [DocumentReviewCommentSource],
    -- | The action to take on a document approval review request.
    DocumentReviews -> DocumentReviewAction
action :: DocumentReviewAction
  }
  deriving (DocumentReviews -> DocumentReviews -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentReviews -> DocumentReviews -> Bool
$c/= :: DocumentReviews -> DocumentReviews -> Bool
== :: DocumentReviews -> DocumentReviews -> Bool
$c== :: DocumentReviews -> DocumentReviews -> Bool
Prelude.Eq, ReadPrec [DocumentReviews]
ReadPrec DocumentReviews
Int -> ReadS DocumentReviews
ReadS [DocumentReviews]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentReviews]
$creadListPrec :: ReadPrec [DocumentReviews]
readPrec :: ReadPrec DocumentReviews
$creadPrec :: ReadPrec DocumentReviews
readList :: ReadS [DocumentReviews]
$creadList :: ReadS [DocumentReviews]
readsPrec :: Int -> ReadS DocumentReviews
$creadsPrec :: Int -> ReadS DocumentReviews
Prelude.Read, Int -> DocumentReviews -> ShowS
[DocumentReviews] -> ShowS
DocumentReviews -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentReviews] -> ShowS
$cshowList :: [DocumentReviews] -> ShowS
show :: DocumentReviews -> String
$cshow :: DocumentReviews -> String
showsPrec :: Int -> DocumentReviews -> ShowS
$cshowsPrec :: Int -> DocumentReviews -> ShowS
Prelude.Show, forall x. Rep DocumentReviews x -> DocumentReviews
forall x. DocumentReviews -> Rep DocumentReviews x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentReviews x -> DocumentReviews
$cfrom :: forall x. DocumentReviews -> Rep DocumentReviews x
Prelude.Generic)

-- |
-- Create a value of 'DocumentReviews' 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:
--
-- 'comment', 'documentReviews_comment' - A comment entered by a user in your organization about the document
-- review request.
--
-- 'action', 'documentReviews_action' - The action to take on a document approval review request.
newDocumentReviews ::
  -- | 'action'
  DocumentReviewAction ->
  DocumentReviews
newDocumentReviews :: DocumentReviewAction -> DocumentReviews
newDocumentReviews DocumentReviewAction
pAction_ =
  DocumentReviews'
    { $sel:comment:DocumentReviews' :: Maybe [DocumentReviewCommentSource]
comment = forall a. Maybe a
Prelude.Nothing,
      $sel:action:DocumentReviews' :: DocumentReviewAction
action = DocumentReviewAction
pAction_
    }

-- | A comment entered by a user in your organization about the document
-- review request.
documentReviews_comment :: Lens.Lens' DocumentReviews (Prelude.Maybe [DocumentReviewCommentSource])
documentReviews_comment :: Lens' DocumentReviews (Maybe [DocumentReviewCommentSource])
documentReviews_comment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentReviews' {Maybe [DocumentReviewCommentSource]
comment :: Maybe [DocumentReviewCommentSource]
$sel:comment:DocumentReviews' :: DocumentReviews -> Maybe [DocumentReviewCommentSource]
comment} -> Maybe [DocumentReviewCommentSource]
comment) (\s :: DocumentReviews
s@DocumentReviews' {} Maybe [DocumentReviewCommentSource]
a -> DocumentReviews
s {$sel:comment:DocumentReviews' :: Maybe [DocumentReviewCommentSource]
comment = Maybe [DocumentReviewCommentSource]
a} :: DocumentReviews) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The action to take on a document approval review request.
documentReviews_action :: Lens.Lens' DocumentReviews DocumentReviewAction
documentReviews_action :: Lens' DocumentReviews DocumentReviewAction
documentReviews_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentReviews' {DocumentReviewAction
action :: DocumentReviewAction
$sel:action:DocumentReviews' :: DocumentReviews -> DocumentReviewAction
action} -> DocumentReviewAction
action) (\s :: DocumentReviews
s@DocumentReviews' {} DocumentReviewAction
a -> DocumentReviews
s {$sel:action:DocumentReviews' :: DocumentReviewAction
action = DocumentReviewAction
a} :: DocumentReviews)

instance Prelude.Hashable DocumentReviews where
  hashWithSalt :: Int -> DocumentReviews -> Int
hashWithSalt Int
_salt DocumentReviews' {Maybe [DocumentReviewCommentSource]
DocumentReviewAction
action :: DocumentReviewAction
comment :: Maybe [DocumentReviewCommentSource]
$sel:action:DocumentReviews' :: DocumentReviews -> DocumentReviewAction
$sel:comment:DocumentReviews' :: DocumentReviews -> Maybe [DocumentReviewCommentSource]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [DocumentReviewCommentSource]
comment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DocumentReviewAction
action

instance Prelude.NFData DocumentReviews where
  rnf :: DocumentReviews -> ()
rnf DocumentReviews' {Maybe [DocumentReviewCommentSource]
DocumentReviewAction
action :: DocumentReviewAction
comment :: Maybe [DocumentReviewCommentSource]
$sel:action:DocumentReviews' :: DocumentReviews -> DocumentReviewAction
$sel:comment:DocumentReviews' :: DocumentReviews -> Maybe [DocumentReviewCommentSource]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DocumentReviewCommentSource]
comment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DocumentReviewAction
action

instance Data.ToJSON DocumentReviews where
  toJSON :: DocumentReviews -> Value
toJSON DocumentReviews' {Maybe [DocumentReviewCommentSource]
DocumentReviewAction
action :: DocumentReviewAction
comment :: Maybe [DocumentReviewCommentSource]
$sel:action:DocumentReviews' :: DocumentReviews -> DocumentReviewAction
$sel:comment:DocumentReviews' :: DocumentReviews -> Maybe [DocumentReviewCommentSource]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Comment" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DocumentReviewCommentSource]
comment,
            forall a. a -> Maybe a
Prelude.Just (Key
"Action" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DocumentReviewAction
action)
          ]
      )