{-# 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.DataBrew.Types.StatisticOverride
-- 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.DataBrew.Types.StatisticOverride where

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

-- | Override of a particular evaluation for a profile job.
--
-- /See:/ 'newStatisticOverride' smart constructor.
data StatisticOverride = StatisticOverride'
  { -- | The name of an evaluation
    StatisticOverride -> Text
statistic :: Prelude.Text,
    -- | A map that includes overrides of an evaluation’s parameters.
    StatisticOverride -> HashMap Text Text
parameters :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (StatisticOverride -> StatisticOverride -> Bool
(StatisticOverride -> StatisticOverride -> Bool)
-> (StatisticOverride -> StatisticOverride -> Bool)
-> Eq StatisticOverride
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatisticOverride -> StatisticOverride -> Bool
$c/= :: StatisticOverride -> StatisticOverride -> Bool
== :: StatisticOverride -> StatisticOverride -> Bool
$c== :: StatisticOverride -> StatisticOverride -> Bool
Prelude.Eq, ReadPrec [StatisticOverride]
ReadPrec StatisticOverride
Int -> ReadS StatisticOverride
ReadS [StatisticOverride]
(Int -> ReadS StatisticOverride)
-> ReadS [StatisticOverride]
-> ReadPrec StatisticOverride
-> ReadPrec [StatisticOverride]
-> Read StatisticOverride
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatisticOverride]
$creadListPrec :: ReadPrec [StatisticOverride]
readPrec :: ReadPrec StatisticOverride
$creadPrec :: ReadPrec StatisticOverride
readList :: ReadS [StatisticOverride]
$creadList :: ReadS [StatisticOverride]
readsPrec :: Int -> ReadS StatisticOverride
$creadsPrec :: Int -> ReadS StatisticOverride
Prelude.Read, Int -> StatisticOverride -> ShowS
[StatisticOverride] -> ShowS
StatisticOverride -> String
(Int -> StatisticOverride -> ShowS)
-> (StatisticOverride -> String)
-> ([StatisticOverride] -> ShowS)
-> Show StatisticOverride
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatisticOverride] -> ShowS
$cshowList :: [StatisticOverride] -> ShowS
show :: StatisticOverride -> String
$cshow :: StatisticOverride -> String
showsPrec :: Int -> StatisticOverride -> ShowS
$cshowsPrec :: Int -> StatisticOverride -> ShowS
Prelude.Show, (forall x. StatisticOverride -> Rep StatisticOverride x)
-> (forall x. Rep StatisticOverride x -> StatisticOverride)
-> Generic StatisticOverride
forall x. Rep StatisticOverride x -> StatisticOverride
forall x. StatisticOverride -> Rep StatisticOverride x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatisticOverride x -> StatisticOverride
$cfrom :: forall x. StatisticOverride -> Rep StatisticOverride x
Prelude.Generic)

-- |
-- Create a value of 'StatisticOverride' 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:
--
-- 'statistic', 'statisticOverride_statistic' - The name of an evaluation
--
-- 'parameters', 'statisticOverride_parameters' - A map that includes overrides of an evaluation’s parameters.
newStatisticOverride ::
  -- | 'statistic'
  Prelude.Text ->
  StatisticOverride
newStatisticOverride :: Text -> StatisticOverride
newStatisticOverride Text
pStatistic_ =
  StatisticOverride' :: Text -> HashMap Text Text -> StatisticOverride
StatisticOverride'
    { $sel:statistic:StatisticOverride' :: Text
statistic = Text
pStatistic_,
      $sel:parameters:StatisticOverride' :: HashMap Text Text
parameters = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of an evaluation
statisticOverride_statistic :: Lens.Lens' StatisticOverride Prelude.Text
statisticOverride_statistic :: (Text -> f Text) -> StatisticOverride -> f StatisticOverride
statisticOverride_statistic = (StatisticOverride -> Text)
-> (StatisticOverride -> Text -> StatisticOverride)
-> Lens StatisticOverride StatisticOverride Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatisticOverride' {Text
statistic :: Text
$sel:statistic:StatisticOverride' :: StatisticOverride -> Text
statistic} -> Text
statistic) (\s :: StatisticOverride
s@StatisticOverride' {} Text
a -> StatisticOverride
s {$sel:statistic:StatisticOverride' :: Text
statistic = Text
a} :: StatisticOverride)

-- | A map that includes overrides of an evaluation’s parameters.
statisticOverride_parameters :: Lens.Lens' StatisticOverride (Prelude.HashMap Prelude.Text Prelude.Text)
statisticOverride_parameters :: (HashMap Text Text -> f (HashMap Text Text))
-> StatisticOverride -> f StatisticOverride
statisticOverride_parameters = (StatisticOverride -> HashMap Text Text)
-> (StatisticOverride -> HashMap Text Text -> StatisticOverride)
-> Lens
     StatisticOverride
     StatisticOverride
     (HashMap Text Text)
     (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatisticOverride' {HashMap Text Text
parameters :: HashMap Text Text
$sel:parameters:StatisticOverride' :: StatisticOverride -> HashMap Text Text
parameters} -> HashMap Text Text
parameters) (\s :: StatisticOverride
s@StatisticOverride' {} HashMap Text Text
a -> StatisticOverride
s {$sel:parameters:StatisticOverride' :: HashMap Text Text
parameters = HashMap Text Text
a} :: StatisticOverride) ((HashMap Text Text -> f (HashMap Text Text))
 -> StatisticOverride -> f StatisticOverride)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> StatisticOverride
-> f StatisticOverride
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON StatisticOverride where
  parseJSON :: Value -> Parser StatisticOverride
parseJSON =
    String
-> (Object -> Parser StatisticOverride)
-> Value
-> Parser StatisticOverride
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StatisticOverride"
      ( \Object
x ->
          Text -> HashMap Text Text -> StatisticOverride
StatisticOverride'
            (Text -> HashMap Text Text -> StatisticOverride)
-> Parser Text -> Parser (HashMap Text Text -> StatisticOverride)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Statistic")
            Parser (HashMap Text Text -> StatisticOverride)
-> Parser (HashMap Text Text) -> Parser StatisticOverride
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (HashMap Text Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parameters" Parser (Maybe (HashMap Text Text))
-> HashMap Text Text -> Parser (HashMap Text Text)
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= HashMap Text Text
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable StatisticOverride

instance Prelude.NFData StatisticOverride

instance Core.ToJSON StatisticOverride where
  toJSON :: StatisticOverride -> Value
toJSON StatisticOverride' {Text
HashMap Text Text
parameters :: HashMap Text Text
statistic :: Text
$sel:parameters:StatisticOverride' :: StatisticOverride -> HashMap Text Text
$sel:statistic:StatisticOverride' :: StatisticOverride -> 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
"Statistic" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
statistic),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Parameters" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Text
parameters)
          ]
      )