{-# 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.Evidently.Types.MetricGoal
-- 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.Evidently.Types.MetricGoal where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Evidently.Types.ChangeDirectionEnum
import Amazonka.Evidently.Types.MetricDefinition
import qualified Amazonka.Prelude as Prelude

-- | A structure that tells Evidently whether higher or lower values are
-- desired for a metric that is used in an experiment.
--
-- /See:/ 'newMetricGoal' smart constructor.
data MetricGoal = MetricGoal'
  { -- | @INCREASE@ means that a variation with a higher number for this metric
    -- is performing better.
    --
    -- @DECREASE@ means that a variation with a lower number for this metric is
    -- performing better.
    MetricGoal -> Maybe ChangeDirectionEnum
desiredChange :: Prelude.Maybe ChangeDirectionEnum,
    -- | A structure that contains details about the metric.
    MetricGoal -> MetricDefinition
metricDefinition :: MetricDefinition
  }
  deriving (MetricGoal -> MetricGoal -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricGoal -> MetricGoal -> Bool
$c/= :: MetricGoal -> MetricGoal -> Bool
== :: MetricGoal -> MetricGoal -> Bool
$c== :: MetricGoal -> MetricGoal -> Bool
Prelude.Eq, ReadPrec [MetricGoal]
ReadPrec MetricGoal
Int -> ReadS MetricGoal
ReadS [MetricGoal]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricGoal]
$creadListPrec :: ReadPrec [MetricGoal]
readPrec :: ReadPrec MetricGoal
$creadPrec :: ReadPrec MetricGoal
readList :: ReadS [MetricGoal]
$creadList :: ReadS [MetricGoal]
readsPrec :: Int -> ReadS MetricGoal
$creadsPrec :: Int -> ReadS MetricGoal
Prelude.Read, Int -> MetricGoal -> ShowS
[MetricGoal] -> ShowS
MetricGoal -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricGoal] -> ShowS
$cshowList :: [MetricGoal] -> ShowS
show :: MetricGoal -> String
$cshow :: MetricGoal -> String
showsPrec :: Int -> MetricGoal -> ShowS
$cshowsPrec :: Int -> MetricGoal -> ShowS
Prelude.Show, forall x. Rep MetricGoal x -> MetricGoal
forall x. MetricGoal -> Rep MetricGoal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricGoal x -> MetricGoal
$cfrom :: forall x. MetricGoal -> Rep MetricGoal x
Prelude.Generic)

-- |
-- Create a value of 'MetricGoal' 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:
--
-- 'desiredChange', 'metricGoal_desiredChange' - @INCREASE@ means that a variation with a higher number for this metric
-- is performing better.
--
-- @DECREASE@ means that a variation with a lower number for this metric is
-- performing better.
--
-- 'metricDefinition', 'metricGoal_metricDefinition' - A structure that contains details about the metric.
newMetricGoal ::
  -- | 'metricDefinition'
  MetricDefinition ->
  MetricGoal
newMetricGoal :: MetricDefinition -> MetricGoal
newMetricGoal MetricDefinition
pMetricDefinition_ =
  MetricGoal'
    { $sel:desiredChange:MetricGoal' :: Maybe ChangeDirectionEnum
desiredChange = forall a. Maybe a
Prelude.Nothing,
      $sel:metricDefinition:MetricGoal' :: MetricDefinition
metricDefinition = MetricDefinition
pMetricDefinition_
    }

-- | @INCREASE@ means that a variation with a higher number for this metric
-- is performing better.
--
-- @DECREASE@ means that a variation with a lower number for this metric is
-- performing better.
metricGoal_desiredChange :: Lens.Lens' MetricGoal (Prelude.Maybe ChangeDirectionEnum)
metricGoal_desiredChange :: Lens' MetricGoal (Maybe ChangeDirectionEnum)
metricGoal_desiredChange = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricGoal' {Maybe ChangeDirectionEnum
desiredChange :: Maybe ChangeDirectionEnum
$sel:desiredChange:MetricGoal' :: MetricGoal -> Maybe ChangeDirectionEnum
desiredChange} -> Maybe ChangeDirectionEnum
desiredChange) (\s :: MetricGoal
s@MetricGoal' {} Maybe ChangeDirectionEnum
a -> MetricGoal
s {$sel:desiredChange:MetricGoal' :: Maybe ChangeDirectionEnum
desiredChange = Maybe ChangeDirectionEnum
a} :: MetricGoal)

-- | A structure that contains details about the metric.
metricGoal_metricDefinition :: Lens.Lens' MetricGoal MetricDefinition
metricGoal_metricDefinition :: Lens' MetricGoal MetricDefinition
metricGoal_metricDefinition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricGoal' {MetricDefinition
metricDefinition :: MetricDefinition
$sel:metricDefinition:MetricGoal' :: MetricGoal -> MetricDefinition
metricDefinition} -> MetricDefinition
metricDefinition) (\s :: MetricGoal
s@MetricGoal' {} MetricDefinition
a -> MetricGoal
s {$sel:metricDefinition:MetricGoal' :: MetricDefinition
metricDefinition = MetricDefinition
a} :: MetricGoal)

instance Data.FromJSON MetricGoal where
  parseJSON :: Value -> Parser MetricGoal
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MetricGoal"
      ( \Object
x ->
          Maybe ChangeDirectionEnum -> MetricDefinition -> MetricGoal
MetricGoal'
            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
"desiredChange")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"metricDefinition")
      )

instance Prelude.Hashable MetricGoal where
  hashWithSalt :: Int -> MetricGoal -> Int
hashWithSalt Int
_salt MetricGoal' {Maybe ChangeDirectionEnum
MetricDefinition
metricDefinition :: MetricDefinition
desiredChange :: Maybe ChangeDirectionEnum
$sel:metricDefinition:MetricGoal' :: MetricGoal -> MetricDefinition
$sel:desiredChange:MetricGoal' :: MetricGoal -> Maybe ChangeDirectionEnum
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChangeDirectionEnum
desiredChange
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MetricDefinition
metricDefinition

instance Prelude.NFData MetricGoal where
  rnf :: MetricGoal -> ()
rnf MetricGoal' {Maybe ChangeDirectionEnum
MetricDefinition
metricDefinition :: MetricDefinition
desiredChange :: Maybe ChangeDirectionEnum
$sel:metricDefinition:MetricGoal' :: MetricGoal -> MetricDefinition
$sel:desiredChange:MetricGoal' :: MetricGoal -> Maybe ChangeDirectionEnum
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ChangeDirectionEnum
desiredChange
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf MetricDefinition
metricDefinition