{-# 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.EvaluationResult
-- 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.EvaluationResult 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.VariableValue
import qualified Amazonka.Prelude as Prelude

-- | This structure displays the results of one feature evaluation assignment
-- to one user session.
--
-- /See:/ 'newEvaluationResult' smart constructor.
data EvaluationResult = EvaluationResult'
  { -- | If this user was assigned to a launch or experiment, this field lists
    -- the launch or experiment name.
    EvaluationResult -> Maybe Text
details :: Prelude.Maybe Prelude.Text,
    -- | The name or ARN of the project that contains the feature being
    -- evaluated.
    EvaluationResult -> Maybe Text
project :: Prelude.Maybe Prelude.Text,
    -- | Specifies the reason that the user session was assigned this variation.
    -- Possible values include @DEFAULT@, meaning the user was served the
    -- default variation; @LAUNCH_RULE_MATCH@, if the user session was enrolled
    -- in a launch; or @EXPERIMENT_RULE_MATCH@, if the user session was
    -- enrolled in an experiment.
    EvaluationResult -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The value assigned to this variation to differentiate it from the other
    -- variations of this feature.
    EvaluationResult -> Maybe VariableValue
value :: Prelude.Maybe VariableValue,
    -- | The name of the variation that was served to the user session.
    EvaluationResult -> Maybe Text
variation :: Prelude.Maybe Prelude.Text,
    -- | An internal ID that represents a unique user session of the application.
    EvaluationResult -> Text
entityId :: Prelude.Text,
    -- | The name of the feature being evaluated.
    EvaluationResult -> Text
feature :: Prelude.Text
  }
  deriving (EvaluationResult -> EvaluationResult -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EvaluationResult -> EvaluationResult -> Bool
$c/= :: EvaluationResult -> EvaluationResult -> Bool
== :: EvaluationResult -> EvaluationResult -> Bool
$c== :: EvaluationResult -> EvaluationResult -> Bool
Prelude.Eq, ReadPrec [EvaluationResult]
ReadPrec EvaluationResult
Int -> ReadS EvaluationResult
ReadS [EvaluationResult]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EvaluationResult]
$creadListPrec :: ReadPrec [EvaluationResult]
readPrec :: ReadPrec EvaluationResult
$creadPrec :: ReadPrec EvaluationResult
readList :: ReadS [EvaluationResult]
$creadList :: ReadS [EvaluationResult]
readsPrec :: Int -> ReadS EvaluationResult
$creadsPrec :: Int -> ReadS EvaluationResult
Prelude.Read, Int -> EvaluationResult -> ShowS
[EvaluationResult] -> ShowS
EvaluationResult -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvaluationResult] -> ShowS
$cshowList :: [EvaluationResult] -> ShowS
show :: EvaluationResult -> String
$cshow :: EvaluationResult -> String
showsPrec :: Int -> EvaluationResult -> ShowS
$cshowsPrec :: Int -> EvaluationResult -> ShowS
Prelude.Show, forall x. Rep EvaluationResult x -> EvaluationResult
forall x. EvaluationResult -> Rep EvaluationResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EvaluationResult x -> EvaluationResult
$cfrom :: forall x. EvaluationResult -> Rep EvaluationResult x
Prelude.Generic)

-- |
-- Create a value of 'EvaluationResult' 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:
--
-- 'details', 'evaluationResult_details' - If this user was assigned to a launch or experiment, this field lists
-- the launch or experiment name.
--
-- 'project', 'evaluationResult_project' - The name or ARN of the project that contains the feature being
-- evaluated.
--
-- 'reason', 'evaluationResult_reason' - Specifies the reason that the user session was assigned this variation.
-- Possible values include @DEFAULT@, meaning the user was served the
-- default variation; @LAUNCH_RULE_MATCH@, if the user session was enrolled
-- in a launch; or @EXPERIMENT_RULE_MATCH@, if the user session was
-- enrolled in an experiment.
--
-- 'value', 'evaluationResult_value' - The value assigned to this variation to differentiate it from the other
-- variations of this feature.
--
-- 'variation', 'evaluationResult_variation' - The name of the variation that was served to the user session.
--
-- 'entityId', 'evaluationResult_entityId' - An internal ID that represents a unique user session of the application.
--
-- 'feature', 'evaluationResult_feature' - The name of the feature being evaluated.
newEvaluationResult ::
  -- | 'entityId'
  Prelude.Text ->
  -- | 'feature'
  Prelude.Text ->
  EvaluationResult
newEvaluationResult :: Text -> Text -> EvaluationResult
newEvaluationResult Text
pEntityId_ Text
pFeature_ =
  EvaluationResult'
    { $sel:details:EvaluationResult' :: Maybe Text
details = forall a. Maybe a
Prelude.Nothing,
      $sel:project:EvaluationResult' :: Maybe Text
project = forall a. Maybe a
Prelude.Nothing,
      $sel:reason:EvaluationResult' :: Maybe Text
reason = forall a. Maybe a
Prelude.Nothing,
      $sel:value:EvaluationResult' :: Maybe VariableValue
value = forall a. Maybe a
Prelude.Nothing,
      $sel:variation:EvaluationResult' :: Maybe Text
variation = forall a. Maybe a
Prelude.Nothing,
      $sel:entityId:EvaluationResult' :: Text
entityId = Text
pEntityId_,
      $sel:feature:EvaluationResult' :: Text
feature = Text
pFeature_
    }

-- | If this user was assigned to a launch or experiment, this field lists
-- the launch or experiment name.
evaluationResult_details :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.Text)
evaluationResult_details :: Lens' EvaluationResult (Maybe Text)
evaluationResult_details = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe Text
details :: Maybe Text
$sel:details:EvaluationResult' :: EvaluationResult -> Maybe Text
details} -> Maybe Text
details) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe Text
a -> EvaluationResult
s {$sel:details:EvaluationResult' :: Maybe Text
details = Maybe Text
a} :: EvaluationResult)

-- | The name or ARN of the project that contains the feature being
-- evaluated.
evaluationResult_project :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.Text)
evaluationResult_project :: Lens' EvaluationResult (Maybe Text)
evaluationResult_project = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe Text
project :: Maybe Text
$sel:project:EvaluationResult' :: EvaluationResult -> Maybe Text
project} -> Maybe Text
project) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe Text
a -> EvaluationResult
s {$sel:project:EvaluationResult' :: Maybe Text
project = Maybe Text
a} :: EvaluationResult)

-- | Specifies the reason that the user session was assigned this variation.
-- Possible values include @DEFAULT@, meaning the user was served the
-- default variation; @LAUNCH_RULE_MATCH@, if the user session was enrolled
-- in a launch; or @EXPERIMENT_RULE_MATCH@, if the user session was
-- enrolled in an experiment.
evaluationResult_reason :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.Text)
evaluationResult_reason :: Lens' EvaluationResult (Maybe Text)
evaluationResult_reason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe Text
reason :: Maybe Text
$sel:reason:EvaluationResult' :: EvaluationResult -> Maybe Text
reason} -> Maybe Text
reason) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe Text
a -> EvaluationResult
s {$sel:reason:EvaluationResult' :: Maybe Text
reason = Maybe Text
a} :: EvaluationResult)

-- | The value assigned to this variation to differentiate it from the other
-- variations of this feature.
evaluationResult_value :: Lens.Lens' EvaluationResult (Prelude.Maybe VariableValue)
evaluationResult_value :: Lens' EvaluationResult (Maybe VariableValue)
evaluationResult_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe VariableValue
value :: Maybe VariableValue
$sel:value:EvaluationResult' :: EvaluationResult -> Maybe VariableValue
value} -> Maybe VariableValue
value) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe VariableValue
a -> EvaluationResult
s {$sel:value:EvaluationResult' :: Maybe VariableValue
value = Maybe VariableValue
a} :: EvaluationResult)

-- | The name of the variation that was served to the user session.
evaluationResult_variation :: Lens.Lens' EvaluationResult (Prelude.Maybe Prelude.Text)
evaluationResult_variation :: Lens' EvaluationResult (Maybe Text)
evaluationResult_variation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Maybe Text
variation :: Maybe Text
$sel:variation:EvaluationResult' :: EvaluationResult -> Maybe Text
variation} -> Maybe Text
variation) (\s :: EvaluationResult
s@EvaluationResult' {} Maybe Text
a -> EvaluationResult
s {$sel:variation:EvaluationResult' :: Maybe Text
variation = Maybe Text
a} :: EvaluationResult)

-- | An internal ID that represents a unique user session of the application.
evaluationResult_entityId :: Lens.Lens' EvaluationResult Prelude.Text
evaluationResult_entityId :: Lens' EvaluationResult Text
evaluationResult_entityId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Text
entityId :: Text
$sel:entityId:EvaluationResult' :: EvaluationResult -> Text
entityId} -> Text
entityId) (\s :: EvaluationResult
s@EvaluationResult' {} Text
a -> EvaluationResult
s {$sel:entityId:EvaluationResult' :: Text
entityId = Text
a} :: EvaluationResult)

-- | The name of the feature being evaluated.
evaluationResult_feature :: Lens.Lens' EvaluationResult Prelude.Text
evaluationResult_feature :: Lens' EvaluationResult Text
evaluationResult_feature = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluationResult' {Text
feature :: Text
$sel:feature:EvaluationResult' :: EvaluationResult -> Text
feature} -> Text
feature) (\s :: EvaluationResult
s@EvaluationResult' {} Text
a -> EvaluationResult
s {$sel:feature:EvaluationResult' :: Text
feature = Text
a} :: EvaluationResult)

instance Data.FromJSON EvaluationResult where
  parseJSON :: Value -> Parser EvaluationResult
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EvaluationResult"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe VariableValue
-> Maybe Text
-> Text
-> Text
-> EvaluationResult
EvaluationResult'
            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
"details")
            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
"project")
            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
"reason")
            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
"value")
            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
"variation")
            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
"entityId")
            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
"feature")
      )

instance Prelude.Hashable EvaluationResult where
  hashWithSalt :: Int -> EvaluationResult -> Int
hashWithSalt Int
_salt EvaluationResult' {Maybe Text
Maybe VariableValue
Text
feature :: Text
entityId :: Text
variation :: Maybe Text
value :: Maybe VariableValue
reason :: Maybe Text
project :: Maybe Text
details :: Maybe Text
$sel:feature:EvaluationResult' :: EvaluationResult -> Text
$sel:entityId:EvaluationResult' :: EvaluationResult -> Text
$sel:variation:EvaluationResult' :: EvaluationResult -> Maybe Text
$sel:value:EvaluationResult' :: EvaluationResult -> Maybe VariableValue
$sel:reason:EvaluationResult' :: EvaluationResult -> Maybe Text
$sel:project:EvaluationResult' :: EvaluationResult -> Maybe Text
$sel:details:EvaluationResult' :: EvaluationResult -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
details
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
project
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
reason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VariableValue
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
variation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entityId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
feature

instance Prelude.NFData EvaluationResult where
  rnf :: EvaluationResult -> ()
rnf EvaluationResult' {Maybe Text
Maybe VariableValue
Text
feature :: Text
entityId :: Text
variation :: Maybe Text
value :: Maybe VariableValue
reason :: Maybe Text
project :: Maybe Text
details :: Maybe Text
$sel:feature:EvaluationResult' :: EvaluationResult -> Text
$sel:entityId:EvaluationResult' :: EvaluationResult -> Text
$sel:variation:EvaluationResult' :: EvaluationResult -> Maybe Text
$sel:value:EvaluationResult' :: EvaluationResult -> Maybe VariableValue
$sel:reason:EvaluationResult' :: EvaluationResult -> Maybe Text
$sel:project:EvaluationResult' :: EvaluationResult -> Maybe Text
$sel:details:EvaluationResult' :: EvaluationResult -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
details
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
project
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
reason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VariableValue
value
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
variation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
entityId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
feature