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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Returns information about the approval rules applied to a pull request
-- and whether conditions have been met.
--
-- /See:/ 'newEvaluation' smart constructor.
data Evaluation = Evaluation'
  { -- | The names of the approval rules that have had their conditions met.
    Evaluation -> Maybe [Text]
approvalRulesSatisfied :: Prelude.Maybe [Prelude.Text],
    -- | The names of the approval rules that have not had their conditions met.
    Evaluation -> Maybe [Text]
approvalRulesNotSatisfied :: Prelude.Maybe [Prelude.Text],
    -- | Whether the state of the pull request is approved.
    Evaluation -> Maybe Bool
approved :: Prelude.Maybe Prelude.Bool,
    -- | Whether the approval rule requirements for the pull request have been
    -- overridden and no longer need to be met.
    Evaluation -> Maybe Bool
overridden :: Prelude.Maybe Prelude.Bool
  }
  deriving (Evaluation -> Evaluation -> Bool
(Evaluation -> Evaluation -> Bool)
-> (Evaluation -> Evaluation -> Bool) -> Eq Evaluation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Evaluation -> Evaluation -> Bool
$c/= :: Evaluation -> Evaluation -> Bool
== :: Evaluation -> Evaluation -> Bool
$c== :: Evaluation -> Evaluation -> Bool
Prelude.Eq, ReadPrec [Evaluation]
ReadPrec Evaluation
Int -> ReadS Evaluation
ReadS [Evaluation]
(Int -> ReadS Evaluation)
-> ReadS [Evaluation]
-> ReadPrec Evaluation
-> ReadPrec [Evaluation]
-> Read Evaluation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Evaluation]
$creadListPrec :: ReadPrec [Evaluation]
readPrec :: ReadPrec Evaluation
$creadPrec :: ReadPrec Evaluation
readList :: ReadS [Evaluation]
$creadList :: ReadS [Evaluation]
readsPrec :: Int -> ReadS Evaluation
$creadsPrec :: Int -> ReadS Evaluation
Prelude.Read, Int -> Evaluation -> ShowS
[Evaluation] -> ShowS
Evaluation -> String
(Int -> Evaluation -> ShowS)
-> (Evaluation -> String)
-> ([Evaluation] -> ShowS)
-> Show Evaluation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Evaluation] -> ShowS
$cshowList :: [Evaluation] -> ShowS
show :: Evaluation -> String
$cshow :: Evaluation -> String
showsPrec :: Int -> Evaluation -> ShowS
$cshowsPrec :: Int -> Evaluation -> ShowS
Prelude.Show, (forall x. Evaluation -> Rep Evaluation x)
-> (forall x. Rep Evaluation x -> Evaluation) -> Generic Evaluation
forall x. Rep Evaluation x -> Evaluation
forall x. Evaluation -> Rep Evaluation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Evaluation x -> Evaluation
$cfrom :: forall x. Evaluation -> Rep Evaluation x
Prelude.Generic)

-- |
-- Create a value of 'Evaluation' 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:
--
-- 'approvalRulesSatisfied', 'evaluation_approvalRulesSatisfied' - The names of the approval rules that have had their conditions met.
--
-- 'approvalRulesNotSatisfied', 'evaluation_approvalRulesNotSatisfied' - The names of the approval rules that have not had their conditions met.
--
-- 'approved', 'evaluation_approved' - Whether the state of the pull request is approved.
--
-- 'overridden', 'evaluation_overridden' - Whether the approval rule requirements for the pull request have been
-- overridden and no longer need to be met.
newEvaluation ::
  Evaluation
newEvaluation :: Evaluation
newEvaluation =
  Evaluation' :: Maybe [Text]
-> Maybe [Text] -> Maybe Bool -> Maybe Bool -> Evaluation
Evaluation'
    { $sel:approvalRulesSatisfied:Evaluation' :: Maybe [Text]
approvalRulesSatisfied =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:approvalRulesNotSatisfied:Evaluation' :: Maybe [Text]
approvalRulesNotSatisfied = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:approved:Evaluation' :: Maybe Bool
approved = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:overridden:Evaluation' :: Maybe Bool
overridden = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The names of the approval rules that have had their conditions met.
evaluation_approvalRulesSatisfied :: Lens.Lens' Evaluation (Prelude.Maybe [Prelude.Text])
evaluation_approvalRulesSatisfied :: (Maybe [Text] -> f (Maybe [Text])) -> Evaluation -> f Evaluation
evaluation_approvalRulesSatisfied = (Evaluation -> Maybe [Text])
-> (Evaluation -> Maybe [Text] -> Evaluation)
-> Lens Evaluation Evaluation (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Evaluation' {Maybe [Text]
approvalRulesSatisfied :: Maybe [Text]
$sel:approvalRulesSatisfied:Evaluation' :: Evaluation -> Maybe [Text]
approvalRulesSatisfied} -> Maybe [Text]
approvalRulesSatisfied) (\s :: Evaluation
s@Evaluation' {} Maybe [Text]
a -> Evaluation
s {$sel:approvalRulesSatisfied:Evaluation' :: Maybe [Text]
approvalRulesSatisfied = Maybe [Text]
a} :: Evaluation) ((Maybe [Text] -> f (Maybe [Text])) -> Evaluation -> f Evaluation)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Evaluation
-> f Evaluation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The names of the approval rules that have not had their conditions met.
evaluation_approvalRulesNotSatisfied :: Lens.Lens' Evaluation (Prelude.Maybe [Prelude.Text])
evaluation_approvalRulesNotSatisfied :: (Maybe [Text] -> f (Maybe [Text])) -> Evaluation -> f Evaluation
evaluation_approvalRulesNotSatisfied = (Evaluation -> Maybe [Text])
-> (Evaluation -> Maybe [Text] -> Evaluation)
-> Lens Evaluation Evaluation (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Evaluation' {Maybe [Text]
approvalRulesNotSatisfied :: Maybe [Text]
$sel:approvalRulesNotSatisfied:Evaluation' :: Evaluation -> Maybe [Text]
approvalRulesNotSatisfied} -> Maybe [Text]
approvalRulesNotSatisfied) (\s :: Evaluation
s@Evaluation' {} Maybe [Text]
a -> Evaluation
s {$sel:approvalRulesNotSatisfied:Evaluation' :: Maybe [Text]
approvalRulesNotSatisfied = Maybe [Text]
a} :: Evaluation) ((Maybe [Text] -> f (Maybe [Text])) -> Evaluation -> f Evaluation)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Evaluation
-> f Evaluation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Whether the state of the pull request is approved.
evaluation_approved :: Lens.Lens' Evaluation (Prelude.Maybe Prelude.Bool)
evaluation_approved :: (Maybe Bool -> f (Maybe Bool)) -> Evaluation -> f Evaluation
evaluation_approved = (Evaluation -> Maybe Bool)
-> (Evaluation -> Maybe Bool -> Evaluation)
-> Lens Evaluation Evaluation (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Evaluation' {Maybe Bool
approved :: Maybe Bool
$sel:approved:Evaluation' :: Evaluation -> Maybe Bool
approved} -> Maybe Bool
approved) (\s :: Evaluation
s@Evaluation' {} Maybe Bool
a -> Evaluation
s {$sel:approved:Evaluation' :: Maybe Bool
approved = Maybe Bool
a} :: Evaluation)

-- | Whether the approval rule requirements for the pull request have been
-- overridden and no longer need to be met.
evaluation_overridden :: Lens.Lens' Evaluation (Prelude.Maybe Prelude.Bool)
evaluation_overridden :: (Maybe Bool -> f (Maybe Bool)) -> Evaluation -> f Evaluation
evaluation_overridden = (Evaluation -> Maybe Bool)
-> (Evaluation -> Maybe Bool -> Evaluation)
-> Lens Evaluation Evaluation (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Evaluation' {Maybe Bool
overridden :: Maybe Bool
$sel:overridden:Evaluation' :: Evaluation -> Maybe Bool
overridden} -> Maybe Bool
overridden) (\s :: Evaluation
s@Evaluation' {} Maybe Bool
a -> Evaluation
s {$sel:overridden:Evaluation' :: Maybe Bool
overridden = Maybe Bool
a} :: Evaluation)

instance Core.FromJSON Evaluation where
  parseJSON :: Value -> Parser Evaluation
parseJSON =
    String
-> (Object -> Parser Evaluation) -> Value -> Parser Evaluation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Evaluation"
      ( \Object
x ->
          Maybe [Text]
-> Maybe [Text] -> Maybe Bool -> Maybe Bool -> Evaluation
Evaluation'
            (Maybe [Text]
 -> Maybe [Text] -> Maybe Bool -> Maybe Bool -> Evaluation)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> Maybe Bool -> Maybe Bool -> Evaluation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"approvalRulesSatisfied"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [Text] -> Maybe Bool -> Maybe Bool -> Evaluation)
-> Parser (Maybe [Text])
-> Parser (Maybe Bool -> Maybe Bool -> Evaluation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"approvalRulesNotSatisfied"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Bool -> Maybe Bool -> Evaluation)
-> Parser (Maybe Bool) -> Parser (Maybe Bool -> Evaluation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"approved")
            Parser (Maybe Bool -> Evaluation)
-> Parser (Maybe Bool) -> Parser Evaluation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"overridden")
      )

instance Prelude.Hashable Evaluation

instance Prelude.NFData Evaluation