{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.EvaluateFeature
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This operation assigns a feature variation to one given user session.
-- You pass in an @entityID@ that represents the user. Evidently then
-- checks the evaluation rules and assigns the variation.
--
-- The first rules that are evaluated are the override rules. If the
-- user\'s @entityID@ matches an override rule, the user is served the
-- variation specified by that rule.
--
-- >  <p>If there is a current launch with this feature that uses segment overrides, and if the user session's <code>evaluationContext</code> matches a segment rule defined in a segment override, the configuration in the segment overrides is used. For more information about segments, see <a href="https://docs.aws.amazon.com/cloudwatchevidently/latest/APIReference/API_CreateSegment.html">CreateSegment</a> and <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Evidently-segments.html">Use segments to focus your audience</a>.</p> <p>If there is a launch with no segment overrides, the user might be assigned to a variation in the launch. The chance of this depends on the percentage of users that are allocated to that launch. If the user is enrolled in the launch, the variation they are served depends on the allocation of the various feature variations used for the launch.</p> <p>If the user is not assigned to a launch, and there is an ongoing experiment for this feature, the user might be assigned to a variation in the experiment. The chance of this depends on the percentage of users that are allocated to that experiment.</p> <p>If the experiment uses a segment, then only user sessions with <code>evaluationContext</code> values that match the segment rule are used in the experiment.</p> <p>If the user is enrolled in the experiment, the variation they are served depends on the allocation of the various feature variations used for the experiment. </p> <p>If the user is not assigned to a launch or experiment, they are served the default variation.</p>
module Amazonka.Evidently.EvaluateFeature
  ( -- * Creating a Request
    EvaluateFeature (..),
    newEvaluateFeature,

    -- * Request Lenses
    evaluateFeature_evaluationContext,
    evaluateFeature_entityId,
    evaluateFeature_feature,
    evaluateFeature_project,

    -- * Destructuring the Response
    EvaluateFeatureResponse (..),
    newEvaluateFeatureResponse,

    -- * Response Lenses
    evaluateFeatureResponse_details,
    evaluateFeatureResponse_reason,
    evaluateFeatureResponse_value,
    evaluateFeatureResponse_variation,
    evaluateFeatureResponse_httpStatus,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newEvaluateFeature' smart constructor.
data EvaluateFeature = EvaluateFeature'
  { -- | A JSON object of attributes that you can optionally pass in as part of
    -- the evaluation event sent to Evidently from the user session. Evidently
    -- can use this value to match user sessions with defined audience
    -- segments. For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Evidently-segments.html Use segments to focus your audience>.
    --
    -- >  <p>If you include this parameter, the value must be a JSON object. A JSON array is not supported.</p>
    EvaluateFeature -> Maybe Text
evaluationContext :: Prelude.Maybe Prelude.Text,
    -- | An internal ID that represents a unique user of the application. This
    -- @entityID@ is checked against any override rules assigned for this
    -- feature.
    EvaluateFeature -> Text
entityId :: Prelude.Text,
    -- | The name of the feature being evaluated.
    EvaluateFeature -> Text
feature :: Prelude.Text,
    -- | The name or ARN of the project that contains this feature.
    EvaluateFeature -> Text
project :: Prelude.Text
  }
  deriving (EvaluateFeature -> EvaluateFeature -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EvaluateFeature -> EvaluateFeature -> Bool
$c/= :: EvaluateFeature -> EvaluateFeature -> Bool
== :: EvaluateFeature -> EvaluateFeature -> Bool
$c== :: EvaluateFeature -> EvaluateFeature -> Bool
Prelude.Eq, ReadPrec [EvaluateFeature]
ReadPrec EvaluateFeature
Int -> ReadS EvaluateFeature
ReadS [EvaluateFeature]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EvaluateFeature]
$creadListPrec :: ReadPrec [EvaluateFeature]
readPrec :: ReadPrec EvaluateFeature
$creadPrec :: ReadPrec EvaluateFeature
readList :: ReadS [EvaluateFeature]
$creadList :: ReadS [EvaluateFeature]
readsPrec :: Int -> ReadS EvaluateFeature
$creadsPrec :: Int -> ReadS EvaluateFeature
Prelude.Read, Int -> EvaluateFeature -> ShowS
[EvaluateFeature] -> ShowS
EvaluateFeature -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvaluateFeature] -> ShowS
$cshowList :: [EvaluateFeature] -> ShowS
show :: EvaluateFeature -> String
$cshow :: EvaluateFeature -> String
showsPrec :: Int -> EvaluateFeature -> ShowS
$cshowsPrec :: Int -> EvaluateFeature -> ShowS
Prelude.Show, forall x. Rep EvaluateFeature x -> EvaluateFeature
forall x. EvaluateFeature -> Rep EvaluateFeature x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EvaluateFeature x -> EvaluateFeature
$cfrom :: forall x. EvaluateFeature -> Rep EvaluateFeature x
Prelude.Generic)

-- |
-- Create a value of 'EvaluateFeature' 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:
--
-- 'evaluationContext', 'evaluateFeature_evaluationContext' - A JSON object of attributes that you can optionally pass in as part of
-- the evaluation event sent to Evidently from the user session. Evidently
-- can use this value to match user sessions with defined audience
-- segments. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Evidently-segments.html Use segments to focus your audience>.
--
-- >  <p>If you include this parameter, the value must be a JSON object. A JSON array is not supported.</p>
--
-- 'entityId', 'evaluateFeature_entityId' - An internal ID that represents a unique user of the application. This
-- @entityID@ is checked against any override rules assigned for this
-- feature.
--
-- 'feature', 'evaluateFeature_feature' - The name of the feature being evaluated.
--
-- 'project', 'evaluateFeature_project' - The name or ARN of the project that contains this feature.
newEvaluateFeature ::
  -- | 'entityId'
  Prelude.Text ->
  -- | 'feature'
  Prelude.Text ->
  -- | 'project'
  Prelude.Text ->
  EvaluateFeature
newEvaluateFeature :: Text -> Text -> Text -> EvaluateFeature
newEvaluateFeature Text
pEntityId_ Text
pFeature_ Text
pProject_ =
  EvaluateFeature'
    { $sel:evaluationContext:EvaluateFeature' :: Maybe Text
evaluationContext =
        forall a. Maybe a
Prelude.Nothing,
      $sel:entityId:EvaluateFeature' :: Text
entityId = Text
pEntityId_,
      $sel:feature:EvaluateFeature' :: Text
feature = Text
pFeature_,
      $sel:project:EvaluateFeature' :: Text
project = Text
pProject_
    }

-- | A JSON object of attributes that you can optionally pass in as part of
-- the evaluation event sent to Evidently from the user session. Evidently
-- can use this value to match user sessions with defined audience
-- segments. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Evidently-segments.html Use segments to focus your audience>.
--
-- >  <p>If you include this parameter, the value must be a JSON object. A JSON array is not supported.</p>
evaluateFeature_evaluationContext :: Lens.Lens' EvaluateFeature (Prelude.Maybe Prelude.Text)
evaluateFeature_evaluationContext :: Lens' EvaluateFeature (Maybe Text)
evaluateFeature_evaluationContext = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluateFeature' {Maybe Text
evaluationContext :: Maybe Text
$sel:evaluationContext:EvaluateFeature' :: EvaluateFeature -> Maybe Text
evaluationContext} -> Maybe Text
evaluationContext) (\s :: EvaluateFeature
s@EvaluateFeature' {} Maybe Text
a -> EvaluateFeature
s {$sel:evaluationContext:EvaluateFeature' :: Maybe Text
evaluationContext = Maybe Text
a} :: EvaluateFeature)

-- | An internal ID that represents a unique user of the application. This
-- @entityID@ is checked against any override rules assigned for this
-- feature.
evaluateFeature_entityId :: Lens.Lens' EvaluateFeature Prelude.Text
evaluateFeature_entityId :: Lens' EvaluateFeature Text
evaluateFeature_entityId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluateFeature' {Text
entityId :: Text
$sel:entityId:EvaluateFeature' :: EvaluateFeature -> Text
entityId} -> Text
entityId) (\s :: EvaluateFeature
s@EvaluateFeature' {} Text
a -> EvaluateFeature
s {$sel:entityId:EvaluateFeature' :: Text
entityId = Text
a} :: EvaluateFeature)

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

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

instance Core.AWSRequest EvaluateFeature where
  type
    AWSResponse EvaluateFeature =
      EvaluateFeatureResponse
  request :: (Service -> Service) -> EvaluateFeature -> Request EvaluateFeature
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy EvaluateFeature
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EvaluateFeature)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe VariableValue
-> Maybe Text
-> Int
-> EvaluateFeatureResponse
EvaluateFeatureResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (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 -> Either String (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 -> Either String (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 -> Either String (Maybe a)
Data..?> Key
"variation")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable EvaluateFeature where
  hashWithSalt :: Int -> EvaluateFeature -> Int
hashWithSalt Int
_salt EvaluateFeature' {Maybe Text
Text
project :: Text
feature :: Text
entityId :: Text
evaluationContext :: Maybe Text
$sel:project:EvaluateFeature' :: EvaluateFeature -> Text
$sel:feature:EvaluateFeature' :: EvaluateFeature -> Text
$sel:entityId:EvaluateFeature' :: EvaluateFeature -> Text
$sel:evaluationContext:EvaluateFeature' :: EvaluateFeature -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
evaluationContext
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
entityId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
feature
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
project

instance Prelude.NFData EvaluateFeature where
  rnf :: EvaluateFeature -> ()
rnf EvaluateFeature' {Maybe Text
Text
project :: Text
feature :: Text
entityId :: Text
evaluationContext :: Maybe Text
$sel:project:EvaluateFeature' :: EvaluateFeature -> Text
$sel:feature:EvaluateFeature' :: EvaluateFeature -> Text
$sel:entityId:EvaluateFeature' :: EvaluateFeature -> Text
$sel:evaluationContext:EvaluateFeature' :: EvaluateFeature -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
evaluationContext
      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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
project

instance Data.ToHeaders EvaluateFeature where
  toHeaders :: EvaluateFeature -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON EvaluateFeature where
  toJSON :: EvaluateFeature -> Value
toJSON EvaluateFeature' {Maybe Text
Text
project :: Text
feature :: Text
entityId :: Text
evaluationContext :: Maybe Text
$sel:project:EvaluateFeature' :: EvaluateFeature -> Text
$sel:feature:EvaluateFeature' :: EvaluateFeature -> Text
$sel:entityId:EvaluateFeature' :: EvaluateFeature -> Text
$sel:evaluationContext:EvaluateFeature' :: EvaluateFeature -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"evaluationContext" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
evaluationContext,
            forall a. a -> Maybe a
Prelude.Just (Key
"entityId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
entityId)
          ]
      )

instance Data.ToPath EvaluateFeature where
  toPath :: EvaluateFeature -> ByteString
toPath EvaluateFeature' {Maybe Text
Text
project :: Text
feature :: Text
entityId :: Text
evaluationContext :: Maybe Text
$sel:project:EvaluateFeature' :: EvaluateFeature -> Text
$sel:feature:EvaluateFeature' :: EvaluateFeature -> Text
$sel:entityId:EvaluateFeature' :: EvaluateFeature -> Text
$sel:evaluationContext:EvaluateFeature' :: EvaluateFeature -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/projects/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
project,
        ByteString
"/evaluations/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
feature
      ]

instance Data.ToQuery EvaluateFeature where
  toQuery :: EvaluateFeature -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newEvaluateFeatureResponse' smart constructor.
data EvaluateFeatureResponse = EvaluateFeatureResponse'
  { -- | If this user was assigned to a launch or experiment, this field lists
    -- the launch or experiment name.
    EvaluateFeatureResponse -> Maybe Text
details :: 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; @EXPERIMENT_RULE_MATCH@, if the user session was enrolled
    -- in an experiment; or @ENTITY_OVERRIDES_MATCH@, if the user\'s @entityId@
    -- matches an override rule.
    EvaluateFeatureResponse -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The value assigned to this variation to differentiate it from the other
    -- variations of this feature.
    EvaluateFeatureResponse -> Maybe VariableValue
value :: Prelude.Maybe VariableValue,
    -- | The name of the variation that was served to the user session.
    EvaluateFeatureResponse -> Maybe Text
variation :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    EvaluateFeatureResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (EvaluateFeatureResponse -> EvaluateFeatureResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EvaluateFeatureResponse -> EvaluateFeatureResponse -> Bool
$c/= :: EvaluateFeatureResponse -> EvaluateFeatureResponse -> Bool
== :: EvaluateFeatureResponse -> EvaluateFeatureResponse -> Bool
$c== :: EvaluateFeatureResponse -> EvaluateFeatureResponse -> Bool
Prelude.Eq, ReadPrec [EvaluateFeatureResponse]
ReadPrec EvaluateFeatureResponse
Int -> ReadS EvaluateFeatureResponse
ReadS [EvaluateFeatureResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EvaluateFeatureResponse]
$creadListPrec :: ReadPrec [EvaluateFeatureResponse]
readPrec :: ReadPrec EvaluateFeatureResponse
$creadPrec :: ReadPrec EvaluateFeatureResponse
readList :: ReadS [EvaluateFeatureResponse]
$creadList :: ReadS [EvaluateFeatureResponse]
readsPrec :: Int -> ReadS EvaluateFeatureResponse
$creadsPrec :: Int -> ReadS EvaluateFeatureResponse
Prelude.Read, Int -> EvaluateFeatureResponse -> ShowS
[EvaluateFeatureResponse] -> ShowS
EvaluateFeatureResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvaluateFeatureResponse] -> ShowS
$cshowList :: [EvaluateFeatureResponse] -> ShowS
show :: EvaluateFeatureResponse -> String
$cshow :: EvaluateFeatureResponse -> String
showsPrec :: Int -> EvaluateFeatureResponse -> ShowS
$cshowsPrec :: Int -> EvaluateFeatureResponse -> ShowS
Prelude.Show, forall x. Rep EvaluateFeatureResponse x -> EvaluateFeatureResponse
forall x. EvaluateFeatureResponse -> Rep EvaluateFeatureResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EvaluateFeatureResponse x -> EvaluateFeatureResponse
$cfrom :: forall x. EvaluateFeatureResponse -> Rep EvaluateFeatureResponse x
Prelude.Generic)

-- |
-- Create a value of 'EvaluateFeatureResponse' 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', 'evaluateFeatureResponse_details' - If this user was assigned to a launch or experiment, this field lists
-- the launch or experiment name.
--
-- 'reason', 'evaluateFeatureResponse_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; @EXPERIMENT_RULE_MATCH@, if the user session was enrolled
-- in an experiment; or @ENTITY_OVERRIDES_MATCH@, if the user\'s @entityId@
-- matches an override rule.
--
-- 'value', 'evaluateFeatureResponse_value' - The value assigned to this variation to differentiate it from the other
-- variations of this feature.
--
-- 'variation', 'evaluateFeatureResponse_variation' - The name of the variation that was served to the user session.
--
-- 'httpStatus', 'evaluateFeatureResponse_httpStatus' - The response's http status code.
newEvaluateFeatureResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  EvaluateFeatureResponse
newEvaluateFeatureResponse :: Int -> EvaluateFeatureResponse
newEvaluateFeatureResponse Int
pHttpStatus_ =
  EvaluateFeatureResponse'
    { $sel:details:EvaluateFeatureResponse' :: Maybe Text
details = forall a. Maybe a
Prelude.Nothing,
      $sel:reason:EvaluateFeatureResponse' :: Maybe Text
reason = forall a. Maybe a
Prelude.Nothing,
      $sel:value:EvaluateFeatureResponse' :: Maybe VariableValue
value = forall a. Maybe a
Prelude.Nothing,
      $sel:variation:EvaluateFeatureResponse' :: Maybe Text
variation = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:EvaluateFeatureResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | 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; @EXPERIMENT_RULE_MATCH@, if the user session was enrolled
-- in an experiment; or @ENTITY_OVERRIDES_MATCH@, if the user\'s @entityId@
-- matches an override rule.
evaluateFeatureResponse_reason :: Lens.Lens' EvaluateFeatureResponse (Prelude.Maybe Prelude.Text)
evaluateFeatureResponse_reason :: Lens' EvaluateFeatureResponse (Maybe Text)
evaluateFeatureResponse_reason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluateFeatureResponse' {Maybe Text
reason :: Maybe Text
$sel:reason:EvaluateFeatureResponse' :: EvaluateFeatureResponse -> Maybe Text
reason} -> Maybe Text
reason) (\s :: EvaluateFeatureResponse
s@EvaluateFeatureResponse' {} Maybe Text
a -> EvaluateFeatureResponse
s {$sel:reason:EvaluateFeatureResponse' :: Maybe Text
reason = Maybe Text
a} :: EvaluateFeatureResponse)

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

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

-- | The response's http status code.
evaluateFeatureResponse_httpStatus :: Lens.Lens' EvaluateFeatureResponse Prelude.Int
evaluateFeatureResponse_httpStatus :: Lens' EvaluateFeatureResponse Int
evaluateFeatureResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EvaluateFeatureResponse' {Int
httpStatus :: Int
$sel:httpStatus:EvaluateFeatureResponse' :: EvaluateFeatureResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: EvaluateFeatureResponse
s@EvaluateFeatureResponse' {} Int
a -> EvaluateFeatureResponse
s {$sel:httpStatus:EvaluateFeatureResponse' :: Int
httpStatus = Int
a} :: EvaluateFeatureResponse)

instance Prelude.NFData EvaluateFeatureResponse where
  rnf :: EvaluateFeatureResponse -> ()
rnf EvaluateFeatureResponse' {Int
Maybe Text
Maybe VariableValue
httpStatus :: Int
variation :: Maybe Text
value :: Maybe VariableValue
reason :: Maybe Text
details :: Maybe Text
$sel:httpStatus:EvaluateFeatureResponse' :: EvaluateFeatureResponse -> Int
$sel:variation:EvaluateFeatureResponse' :: EvaluateFeatureResponse -> Maybe Text
$sel:value:EvaluateFeatureResponse' :: EvaluateFeatureResponse -> Maybe VariableValue
$sel:reason:EvaluateFeatureResponse' :: EvaluateFeatureResponse -> Maybe Text
$sel:details:EvaluateFeatureResponse' :: EvaluateFeatureResponse -> 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
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 Int
httpStatus