{-# 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.CodePipeline.Types.ApprovalResult
-- 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.CodePipeline.Types.ApprovalResult where

import Amazonka.CodePipeline.Types.ApprovalStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information about the result of an approval request.
--
-- /See:/ 'newApprovalResult' smart constructor.
data ApprovalResult = ApprovalResult'
  { -- | The summary of the current status of the approval request.
    ApprovalResult -> Text
summary :: Prelude.Text,
    -- | The response submitted by a reviewer assigned to an approval action
    -- request.
    ApprovalResult -> ApprovalStatus
status :: ApprovalStatus
  }
  deriving (ApprovalResult -> ApprovalResult -> Bool
(ApprovalResult -> ApprovalResult -> Bool)
-> (ApprovalResult -> ApprovalResult -> Bool) -> Eq ApprovalResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApprovalResult -> ApprovalResult -> Bool
$c/= :: ApprovalResult -> ApprovalResult -> Bool
== :: ApprovalResult -> ApprovalResult -> Bool
$c== :: ApprovalResult -> ApprovalResult -> Bool
Prelude.Eq, ReadPrec [ApprovalResult]
ReadPrec ApprovalResult
Int -> ReadS ApprovalResult
ReadS [ApprovalResult]
(Int -> ReadS ApprovalResult)
-> ReadS [ApprovalResult]
-> ReadPrec ApprovalResult
-> ReadPrec [ApprovalResult]
-> Read ApprovalResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApprovalResult]
$creadListPrec :: ReadPrec [ApprovalResult]
readPrec :: ReadPrec ApprovalResult
$creadPrec :: ReadPrec ApprovalResult
readList :: ReadS [ApprovalResult]
$creadList :: ReadS [ApprovalResult]
readsPrec :: Int -> ReadS ApprovalResult
$creadsPrec :: Int -> ReadS ApprovalResult
Prelude.Read, Int -> ApprovalResult -> ShowS
[ApprovalResult] -> ShowS
ApprovalResult -> String
(Int -> ApprovalResult -> ShowS)
-> (ApprovalResult -> String)
-> ([ApprovalResult] -> ShowS)
-> Show ApprovalResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApprovalResult] -> ShowS
$cshowList :: [ApprovalResult] -> ShowS
show :: ApprovalResult -> String
$cshow :: ApprovalResult -> String
showsPrec :: Int -> ApprovalResult -> ShowS
$cshowsPrec :: Int -> ApprovalResult -> ShowS
Prelude.Show, (forall x. ApprovalResult -> Rep ApprovalResult x)
-> (forall x. Rep ApprovalResult x -> ApprovalResult)
-> Generic ApprovalResult
forall x. Rep ApprovalResult x -> ApprovalResult
forall x. ApprovalResult -> Rep ApprovalResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApprovalResult x -> ApprovalResult
$cfrom :: forall x. ApprovalResult -> Rep ApprovalResult x
Prelude.Generic)

-- |
-- Create a value of 'ApprovalResult' 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:
--
-- 'summary', 'approvalResult_summary' - The summary of the current status of the approval request.
--
-- 'status', 'approvalResult_status' - The response submitted by a reviewer assigned to an approval action
-- request.
newApprovalResult ::
  -- | 'summary'
  Prelude.Text ->
  -- | 'status'
  ApprovalStatus ->
  ApprovalResult
newApprovalResult :: Text -> ApprovalStatus -> ApprovalResult
newApprovalResult Text
pSummary_ ApprovalStatus
pStatus_ =
  ApprovalResult' :: Text -> ApprovalStatus -> ApprovalResult
ApprovalResult'
    { $sel:summary:ApprovalResult' :: Text
summary = Text
pSummary_,
      $sel:status:ApprovalResult' :: ApprovalStatus
status = ApprovalStatus
pStatus_
    }

-- | The summary of the current status of the approval request.
approvalResult_summary :: Lens.Lens' ApprovalResult Prelude.Text
approvalResult_summary :: (Text -> f Text) -> ApprovalResult -> f ApprovalResult
approvalResult_summary = (ApprovalResult -> Text)
-> (ApprovalResult -> Text -> ApprovalResult)
-> Lens ApprovalResult ApprovalResult Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApprovalResult' {Text
summary :: Text
$sel:summary:ApprovalResult' :: ApprovalResult -> Text
summary} -> Text
summary) (\s :: ApprovalResult
s@ApprovalResult' {} Text
a -> ApprovalResult
s {$sel:summary:ApprovalResult' :: Text
summary = Text
a} :: ApprovalResult)

-- | The response submitted by a reviewer assigned to an approval action
-- request.
approvalResult_status :: Lens.Lens' ApprovalResult ApprovalStatus
approvalResult_status :: (ApprovalStatus -> f ApprovalStatus)
-> ApprovalResult -> f ApprovalResult
approvalResult_status = (ApprovalResult -> ApprovalStatus)
-> (ApprovalResult -> ApprovalStatus -> ApprovalResult)
-> Lens ApprovalResult ApprovalResult ApprovalStatus ApprovalStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApprovalResult' {ApprovalStatus
status :: ApprovalStatus
$sel:status:ApprovalResult' :: ApprovalResult -> ApprovalStatus
status} -> ApprovalStatus
status) (\s :: ApprovalResult
s@ApprovalResult' {} ApprovalStatus
a -> ApprovalResult
s {$sel:status:ApprovalResult' :: ApprovalStatus
status = ApprovalStatus
a} :: ApprovalResult)

instance Prelude.Hashable ApprovalResult

instance Prelude.NFData ApprovalResult

instance Core.ToJSON ApprovalResult where
  toJSON :: ApprovalResult -> Value
toJSON ApprovalResult' {Text
ApprovalStatus
status :: ApprovalStatus
summary :: Text
$sel:status:ApprovalResult' :: ApprovalResult -> ApprovalStatus
$sel:summary:ApprovalResult' :: ApprovalResult -> 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
"summary" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
summary),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"status" Text -> ApprovalStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ApprovalStatus
status)
          ]
      )