{-# 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.CodeCommit.Types.ApprovalStateChangedEventMetadata
-- 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.CodeCommit.Types.ApprovalStateChangedEventMetadata where

import Amazonka.CodeCommit.Types.ApprovalState
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Returns information about a change in the approval state for a pull
-- request.
--
-- /See:/ 'newApprovalStateChangedEventMetadata' smart constructor.
data ApprovalStateChangedEventMetadata = ApprovalStateChangedEventMetadata'
  { -- | The approval status for the pull request.
    ApprovalStateChangedEventMetadata -> Maybe ApprovalState
approvalStatus :: Prelude.Maybe ApprovalState,
    -- | The revision ID of the pull request when the approval state changed.
    ApprovalStateChangedEventMetadata -> Maybe Text
revisionId :: Prelude.Maybe Prelude.Text
  }
  deriving (ApprovalStateChangedEventMetadata
-> ApprovalStateChangedEventMetadata -> Bool
(ApprovalStateChangedEventMetadata
 -> ApprovalStateChangedEventMetadata -> Bool)
-> (ApprovalStateChangedEventMetadata
    -> ApprovalStateChangedEventMetadata -> Bool)
-> Eq ApprovalStateChangedEventMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApprovalStateChangedEventMetadata
-> ApprovalStateChangedEventMetadata -> Bool
$c/= :: ApprovalStateChangedEventMetadata
-> ApprovalStateChangedEventMetadata -> Bool
== :: ApprovalStateChangedEventMetadata
-> ApprovalStateChangedEventMetadata -> Bool
$c== :: ApprovalStateChangedEventMetadata
-> ApprovalStateChangedEventMetadata -> Bool
Prelude.Eq, ReadPrec [ApprovalStateChangedEventMetadata]
ReadPrec ApprovalStateChangedEventMetadata
Int -> ReadS ApprovalStateChangedEventMetadata
ReadS [ApprovalStateChangedEventMetadata]
(Int -> ReadS ApprovalStateChangedEventMetadata)
-> ReadS [ApprovalStateChangedEventMetadata]
-> ReadPrec ApprovalStateChangedEventMetadata
-> ReadPrec [ApprovalStateChangedEventMetadata]
-> Read ApprovalStateChangedEventMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApprovalStateChangedEventMetadata]
$creadListPrec :: ReadPrec [ApprovalStateChangedEventMetadata]
readPrec :: ReadPrec ApprovalStateChangedEventMetadata
$creadPrec :: ReadPrec ApprovalStateChangedEventMetadata
readList :: ReadS [ApprovalStateChangedEventMetadata]
$creadList :: ReadS [ApprovalStateChangedEventMetadata]
readsPrec :: Int -> ReadS ApprovalStateChangedEventMetadata
$creadsPrec :: Int -> ReadS ApprovalStateChangedEventMetadata
Prelude.Read, Int -> ApprovalStateChangedEventMetadata -> ShowS
[ApprovalStateChangedEventMetadata] -> ShowS
ApprovalStateChangedEventMetadata -> String
(Int -> ApprovalStateChangedEventMetadata -> ShowS)
-> (ApprovalStateChangedEventMetadata -> String)
-> ([ApprovalStateChangedEventMetadata] -> ShowS)
-> Show ApprovalStateChangedEventMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApprovalStateChangedEventMetadata] -> ShowS
$cshowList :: [ApprovalStateChangedEventMetadata] -> ShowS
show :: ApprovalStateChangedEventMetadata -> String
$cshow :: ApprovalStateChangedEventMetadata -> String
showsPrec :: Int -> ApprovalStateChangedEventMetadata -> ShowS
$cshowsPrec :: Int -> ApprovalStateChangedEventMetadata -> ShowS
Prelude.Show, (forall x.
 ApprovalStateChangedEventMetadata
 -> Rep ApprovalStateChangedEventMetadata x)
-> (forall x.
    Rep ApprovalStateChangedEventMetadata x
    -> ApprovalStateChangedEventMetadata)
-> Generic ApprovalStateChangedEventMetadata
forall x.
Rep ApprovalStateChangedEventMetadata x
-> ApprovalStateChangedEventMetadata
forall x.
ApprovalStateChangedEventMetadata
-> Rep ApprovalStateChangedEventMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ApprovalStateChangedEventMetadata x
-> ApprovalStateChangedEventMetadata
$cfrom :: forall x.
ApprovalStateChangedEventMetadata
-> Rep ApprovalStateChangedEventMetadata x
Prelude.Generic)

-- |
-- Create a value of 'ApprovalStateChangedEventMetadata' 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:
--
-- 'approvalStatus', 'approvalStateChangedEventMetadata_approvalStatus' - The approval status for the pull request.
--
-- 'revisionId', 'approvalStateChangedEventMetadata_revisionId' - The revision ID of the pull request when the approval state changed.
newApprovalStateChangedEventMetadata ::
  ApprovalStateChangedEventMetadata
newApprovalStateChangedEventMetadata :: ApprovalStateChangedEventMetadata
newApprovalStateChangedEventMetadata =
  ApprovalStateChangedEventMetadata' :: Maybe ApprovalState
-> Maybe Text -> ApprovalStateChangedEventMetadata
ApprovalStateChangedEventMetadata'
    { $sel:approvalStatus:ApprovalStateChangedEventMetadata' :: Maybe ApprovalState
approvalStatus =
        Maybe ApprovalState
forall a. Maybe a
Prelude.Nothing,
      $sel:revisionId:ApprovalStateChangedEventMetadata' :: Maybe Text
revisionId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The approval status for the pull request.
approvalStateChangedEventMetadata_approvalStatus :: Lens.Lens' ApprovalStateChangedEventMetadata (Prelude.Maybe ApprovalState)
approvalStateChangedEventMetadata_approvalStatus :: (Maybe ApprovalState -> f (Maybe ApprovalState))
-> ApprovalStateChangedEventMetadata
-> f ApprovalStateChangedEventMetadata
approvalStateChangedEventMetadata_approvalStatus = (ApprovalStateChangedEventMetadata -> Maybe ApprovalState)
-> (ApprovalStateChangedEventMetadata
    -> Maybe ApprovalState -> ApprovalStateChangedEventMetadata)
-> Lens
     ApprovalStateChangedEventMetadata
     ApprovalStateChangedEventMetadata
     (Maybe ApprovalState)
     (Maybe ApprovalState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApprovalStateChangedEventMetadata' {Maybe ApprovalState
approvalStatus :: Maybe ApprovalState
$sel:approvalStatus:ApprovalStateChangedEventMetadata' :: ApprovalStateChangedEventMetadata -> Maybe ApprovalState
approvalStatus} -> Maybe ApprovalState
approvalStatus) (\s :: ApprovalStateChangedEventMetadata
s@ApprovalStateChangedEventMetadata' {} Maybe ApprovalState
a -> ApprovalStateChangedEventMetadata
s {$sel:approvalStatus:ApprovalStateChangedEventMetadata' :: Maybe ApprovalState
approvalStatus = Maybe ApprovalState
a} :: ApprovalStateChangedEventMetadata)

-- | The revision ID of the pull request when the approval state changed.
approvalStateChangedEventMetadata_revisionId :: Lens.Lens' ApprovalStateChangedEventMetadata (Prelude.Maybe Prelude.Text)
approvalStateChangedEventMetadata_revisionId :: (Maybe Text -> f (Maybe Text))
-> ApprovalStateChangedEventMetadata
-> f ApprovalStateChangedEventMetadata
approvalStateChangedEventMetadata_revisionId = (ApprovalStateChangedEventMetadata -> Maybe Text)
-> (ApprovalStateChangedEventMetadata
    -> Maybe Text -> ApprovalStateChangedEventMetadata)
-> Lens
     ApprovalStateChangedEventMetadata
     ApprovalStateChangedEventMetadata
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApprovalStateChangedEventMetadata' {Maybe Text
revisionId :: Maybe Text
$sel:revisionId:ApprovalStateChangedEventMetadata' :: ApprovalStateChangedEventMetadata -> Maybe Text
revisionId} -> Maybe Text
revisionId) (\s :: ApprovalStateChangedEventMetadata
s@ApprovalStateChangedEventMetadata' {} Maybe Text
a -> ApprovalStateChangedEventMetadata
s {$sel:revisionId:ApprovalStateChangedEventMetadata' :: Maybe Text
revisionId = Maybe Text
a} :: ApprovalStateChangedEventMetadata)

instance
  Core.FromJSON
    ApprovalStateChangedEventMetadata
  where
  parseJSON :: Value -> Parser ApprovalStateChangedEventMetadata
parseJSON =
    String
-> (Object -> Parser ApprovalStateChangedEventMetadata)
-> Value
-> Parser ApprovalStateChangedEventMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ApprovalStateChangedEventMetadata"
      ( \Object
x ->
          Maybe ApprovalState
-> Maybe Text -> ApprovalStateChangedEventMetadata
ApprovalStateChangedEventMetadata'
            (Maybe ApprovalState
 -> Maybe Text -> ApprovalStateChangedEventMetadata)
-> Parser (Maybe ApprovalState)
-> Parser (Maybe Text -> ApprovalStateChangedEventMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ApprovalState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"approvalStatus")
            Parser (Maybe Text -> ApprovalStateChangedEventMetadata)
-> Parser (Maybe Text) -> Parser ApprovalStateChangedEventMetadata
forall (f :: * -> *) a b. Applicative f => 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
"revisionId")
      )

instance
  Prelude.Hashable
    ApprovalStateChangedEventMetadata

instance
  Prelude.NFData
    ApprovalStateChangedEventMetadata