{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeCommit.Types.Evaluation 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

-- | 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 not had their conditions met.
    Evaluation -> Maybe [Text]
approvalRulesNotSatisfied :: Prelude.Maybe [Prelude.Text],
    -- | The names of the approval rules that have had their conditions met.
    Evaluation -> Maybe [Text]
approvalRulesSatisfied :: 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
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]
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
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. 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:
--
-- 'approvalRulesNotSatisfied', 'evaluation_approvalRulesNotSatisfied' - The names of the approval rules that have not had their conditions met.
--
-- 'approvalRulesSatisfied', 'evaluation_approvalRulesSatisfied' - The names of the approval rules that have 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'
    { $sel:approvalRulesNotSatisfied:Evaluation' :: Maybe [Text]
approvalRulesNotSatisfied =
        forall a. Maybe a
Prelude.Nothing,
      $sel:approvalRulesSatisfied:Evaluation' :: Maybe [Text]
approvalRulesSatisfied = forall a. Maybe a
Prelude.Nothing,
      $sel:approved:Evaluation' :: Maybe Bool
approved = forall a. Maybe a
Prelude.Nothing,
      $sel:overridden:Evaluation' :: Maybe Bool
overridden = forall a. Maybe a
Prelude.Nothing
    }

-- | The names of the approval rules that have not had their conditions met.
evaluation_approvalRulesNotSatisfied :: Lens.Lens' Evaluation (Prelude.Maybe [Prelude.Text])
evaluation_approvalRulesNotSatisfied :: Lens' Evaluation (Maybe [Text])
evaluation_approvalRulesNotSatisfied = 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) 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 names of the approval rules that have had their conditions met.
evaluation_approvalRulesSatisfied :: Lens.Lens' Evaluation (Prelude.Maybe [Prelude.Text])
evaluation_approvalRulesSatisfied :: Lens' Evaluation (Maybe [Text])
evaluation_approvalRulesSatisfied = 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) 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

-- | Whether the state of the pull request is approved.
evaluation_approved :: Lens.Lens' Evaluation (Prelude.Maybe Prelude.Bool)
evaluation_approved :: Lens' Evaluation (Maybe Bool)
evaluation_approved = 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 :: Lens' Evaluation (Maybe Bool)
evaluation_overridden = 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 Data.FromJSON Evaluation where
  parseJSON :: Value -> Parser Evaluation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Evaluation"
      ( \Object
x ->
          Maybe [Text]
-> Maybe [Text] -> Maybe Bool -> Maybe Bool -> Evaluation
Evaluation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"approvalRulesNotSatisfied"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"approvalRulesSatisfied"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"approved")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"overridden")
      )

instance Prelude.Hashable Evaluation where
  hashWithSalt :: Int -> Evaluation -> Int
hashWithSalt Int
_salt Evaluation' {Maybe Bool
Maybe [Text]
overridden :: Maybe Bool
approved :: Maybe Bool
approvalRulesSatisfied :: Maybe [Text]
approvalRulesNotSatisfied :: Maybe [Text]
$sel:overridden:Evaluation' :: Evaluation -> Maybe Bool
$sel:approved:Evaluation' :: Evaluation -> Maybe Bool
$sel:approvalRulesSatisfied:Evaluation' :: Evaluation -> Maybe [Text]
$sel:approvalRulesNotSatisfied:Evaluation' :: Evaluation -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
approvalRulesNotSatisfied
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
approvalRulesSatisfied
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
approved
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
overridden

instance Prelude.NFData Evaluation where
  rnf :: Evaluation -> ()
rnf Evaluation' {Maybe Bool
Maybe [Text]
overridden :: Maybe Bool
approved :: Maybe Bool
approvalRulesSatisfied :: Maybe [Text]
approvalRulesNotSatisfied :: Maybe [Text]
$sel:overridden:Evaluation' :: Evaluation -> Maybe Bool
$sel:approved:Evaluation' :: Evaluation -> Maybe Bool
$sel:approvalRulesSatisfied:Evaluation' :: Evaluation -> Maybe [Text]
$sel:approvalRulesNotSatisfied:Evaluation' :: Evaluation -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
approvalRulesNotSatisfied
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
approvalRulesSatisfied
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
approved
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
overridden