{-# 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-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.DocumentReviews where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(DocumentReviews -> DocumentReviews -> Bool)
-> (DocumentReviews -> DocumentReviews -> Bool)
-> Eq DocumentReviews
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]
(Int -> ReadS DocumentReviews)
-> ReadS [DocumentReviews]
-> ReadPrec DocumentReviews
-> ReadPrec [DocumentReviews]
-> Read 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
(Int -> DocumentReviews -> ShowS)
-> (DocumentReviews -> String)
-> ([DocumentReviews] -> ShowS)
-> Show DocumentReviews
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. DocumentReviews -> Rep DocumentReviews x)
-> (forall x. Rep DocumentReviews x -> DocumentReviews)
-> Generic DocumentReviews
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' :: Maybe [DocumentReviewCommentSource]
-> DocumentReviewAction -> DocumentReviews
DocumentReviews'
    { $sel:comment:DocumentReviews' :: Maybe [DocumentReviewCommentSource]
comment = Maybe [DocumentReviewCommentSource]
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 :: (Maybe [DocumentReviewCommentSource]
 -> f (Maybe [DocumentReviewCommentSource]))
-> DocumentReviews -> f DocumentReviews
documentReviews_comment = (DocumentReviews -> Maybe [DocumentReviewCommentSource])
-> (DocumentReviews
    -> Maybe [DocumentReviewCommentSource] -> DocumentReviews)
-> Lens
     DocumentReviews
     DocumentReviews
     (Maybe [DocumentReviewCommentSource])
     (Maybe [DocumentReviewCommentSource])
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) ((Maybe [DocumentReviewCommentSource]
  -> f (Maybe [DocumentReviewCommentSource]))
 -> DocumentReviews -> f DocumentReviews)
-> ((Maybe [DocumentReviewCommentSource]
     -> f (Maybe [DocumentReviewCommentSource]))
    -> Maybe [DocumentReviewCommentSource]
    -> f (Maybe [DocumentReviewCommentSource]))
-> (Maybe [DocumentReviewCommentSource]
    -> f (Maybe [DocumentReviewCommentSource]))
-> DocumentReviews
-> f DocumentReviews
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DocumentReviewCommentSource]
  [DocumentReviewCommentSource]
  [DocumentReviewCommentSource]
  [DocumentReviewCommentSource]
-> Iso
     (Maybe [DocumentReviewCommentSource])
     (Maybe [DocumentReviewCommentSource])
     (Maybe [DocumentReviewCommentSource])
     (Maybe [DocumentReviewCommentSource])
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
  [DocumentReviewCommentSource]
  [DocumentReviewCommentSource]
  [DocumentReviewCommentSource]
  [DocumentReviewCommentSource]
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 :: (DocumentReviewAction -> f DocumentReviewAction)
-> DocumentReviews -> f DocumentReviews
documentReviews_action = (DocumentReviews -> DocumentReviewAction)
-> (DocumentReviews -> DocumentReviewAction -> DocumentReviews)
-> Lens
     DocumentReviews
     DocumentReviews
     DocumentReviewAction
     DocumentReviewAction
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

instance Prelude.NFData DocumentReviews

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Comment" Text -> [DocumentReviewCommentSource] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([DocumentReviewCommentSource] -> Pair)
-> Maybe [DocumentReviewCommentSource] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DocumentReviewCommentSource]
comment,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Action" Text -> DocumentReviewAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DocumentReviewAction
action)
          ]
      )