{-# 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.TreatmentConfig
-- 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.TreatmentConfig 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

-- | A structure that defines one treatment in an experiment. A treatment is
-- a variation of the feature that you are including in the experiment.
--
-- /See:/ 'newTreatmentConfig' smart constructor.
data TreatmentConfig = TreatmentConfig'
  { -- | A description for this treatment.
    TreatmentConfig -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The feature that this experiment is testing.
    TreatmentConfig -> Text
feature :: Prelude.Text,
    -- | A name for this treatment.
    TreatmentConfig -> Text
name :: Prelude.Text,
    -- | The name of the variation to use as this treatment in the experiment.
    TreatmentConfig -> Text
variation :: Prelude.Text
  }
  deriving (TreatmentConfig -> TreatmentConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TreatmentConfig -> TreatmentConfig -> Bool
$c/= :: TreatmentConfig -> TreatmentConfig -> Bool
== :: TreatmentConfig -> TreatmentConfig -> Bool
$c== :: TreatmentConfig -> TreatmentConfig -> Bool
Prelude.Eq, ReadPrec [TreatmentConfig]
ReadPrec TreatmentConfig
Int -> ReadS TreatmentConfig
ReadS [TreatmentConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TreatmentConfig]
$creadListPrec :: ReadPrec [TreatmentConfig]
readPrec :: ReadPrec TreatmentConfig
$creadPrec :: ReadPrec TreatmentConfig
readList :: ReadS [TreatmentConfig]
$creadList :: ReadS [TreatmentConfig]
readsPrec :: Int -> ReadS TreatmentConfig
$creadsPrec :: Int -> ReadS TreatmentConfig
Prelude.Read, Int -> TreatmentConfig -> ShowS
[TreatmentConfig] -> ShowS
TreatmentConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TreatmentConfig] -> ShowS
$cshowList :: [TreatmentConfig] -> ShowS
show :: TreatmentConfig -> String
$cshow :: TreatmentConfig -> String
showsPrec :: Int -> TreatmentConfig -> ShowS
$cshowsPrec :: Int -> TreatmentConfig -> ShowS
Prelude.Show, forall x. Rep TreatmentConfig x -> TreatmentConfig
forall x. TreatmentConfig -> Rep TreatmentConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TreatmentConfig x -> TreatmentConfig
$cfrom :: forall x. TreatmentConfig -> Rep TreatmentConfig x
Prelude.Generic)

-- |
-- Create a value of 'TreatmentConfig' 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:
--
-- 'description', 'treatmentConfig_description' - A description for this treatment.
--
-- 'feature', 'treatmentConfig_feature' - The feature that this experiment is testing.
--
-- 'name', 'treatmentConfig_name' - A name for this treatment.
--
-- 'variation', 'treatmentConfig_variation' - The name of the variation to use as this treatment in the experiment.
newTreatmentConfig ::
  -- | 'feature'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'variation'
  Prelude.Text ->
  TreatmentConfig
newTreatmentConfig :: Text -> Text -> Text -> TreatmentConfig
newTreatmentConfig Text
pFeature_ Text
pName_ Text
pVariation_ =
  TreatmentConfig'
    { $sel:description:TreatmentConfig' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:feature:TreatmentConfig' :: Text
feature = Text
pFeature_,
      $sel:name:TreatmentConfig' :: Text
name = Text
pName_,
      $sel:variation:TreatmentConfig' :: Text
variation = Text
pVariation_
    }

-- | A description for this treatment.
treatmentConfig_description :: Lens.Lens' TreatmentConfig (Prelude.Maybe Prelude.Text)
treatmentConfig_description :: Lens' TreatmentConfig (Maybe Text)
treatmentConfig_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TreatmentConfig' {Maybe Text
description :: Maybe Text
$sel:description:TreatmentConfig' :: TreatmentConfig -> Maybe Text
description} -> Maybe Text
description) (\s :: TreatmentConfig
s@TreatmentConfig' {} Maybe Text
a -> TreatmentConfig
s {$sel:description:TreatmentConfig' :: Maybe Text
description = Maybe Text
a} :: TreatmentConfig)

-- | The feature that this experiment is testing.
treatmentConfig_feature :: Lens.Lens' TreatmentConfig Prelude.Text
treatmentConfig_feature :: Lens' TreatmentConfig Text
treatmentConfig_feature = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TreatmentConfig' {Text
feature :: Text
$sel:feature:TreatmentConfig' :: TreatmentConfig -> Text
feature} -> Text
feature) (\s :: TreatmentConfig
s@TreatmentConfig' {} Text
a -> TreatmentConfig
s {$sel:feature:TreatmentConfig' :: Text
feature = Text
a} :: TreatmentConfig)

-- | A name for this treatment.
treatmentConfig_name :: Lens.Lens' TreatmentConfig Prelude.Text
treatmentConfig_name :: Lens' TreatmentConfig Text
treatmentConfig_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TreatmentConfig' {Text
name :: Text
$sel:name:TreatmentConfig' :: TreatmentConfig -> Text
name} -> Text
name) (\s :: TreatmentConfig
s@TreatmentConfig' {} Text
a -> TreatmentConfig
s {$sel:name:TreatmentConfig' :: Text
name = Text
a} :: TreatmentConfig)

-- | The name of the variation to use as this treatment in the experiment.
treatmentConfig_variation :: Lens.Lens' TreatmentConfig Prelude.Text
treatmentConfig_variation :: Lens' TreatmentConfig Text
treatmentConfig_variation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TreatmentConfig' {Text
variation :: Text
$sel:variation:TreatmentConfig' :: TreatmentConfig -> Text
variation} -> Text
variation) (\s :: TreatmentConfig
s@TreatmentConfig' {} Text
a -> TreatmentConfig
s {$sel:variation:TreatmentConfig' :: Text
variation = Text
a} :: TreatmentConfig)

instance Prelude.Hashable TreatmentConfig where
  hashWithSalt :: Int -> TreatmentConfig -> Int
hashWithSalt Int
_salt TreatmentConfig' {Maybe Text
Text
variation :: Text
name :: Text
feature :: Text
description :: Maybe Text
$sel:variation:TreatmentConfig' :: TreatmentConfig -> Text
$sel:name:TreatmentConfig' :: TreatmentConfig -> Text
$sel:feature:TreatmentConfig' :: TreatmentConfig -> Text
$sel:description:TreatmentConfig' :: TreatmentConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
feature
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
variation

instance Prelude.NFData TreatmentConfig where
  rnf :: TreatmentConfig -> ()
rnf TreatmentConfig' {Maybe Text
Text
variation :: Text
name :: Text
feature :: Text
description :: Maybe Text
$sel:variation:TreatmentConfig' :: TreatmentConfig -> Text
$sel:name:TreatmentConfig' :: TreatmentConfig -> Text
$sel:feature:TreatmentConfig' :: TreatmentConfig -> Text
$sel:description:TreatmentConfig' :: TreatmentConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      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
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
variation

instance Data.ToJSON TreatmentConfig where
  toJSON :: TreatmentConfig -> Value
toJSON TreatmentConfig' {Maybe Text
Text
variation :: Text
name :: Text
feature :: Text
description :: Maybe Text
$sel:variation:TreatmentConfig' :: TreatmentConfig -> Text
$sel:name:TreatmentConfig' :: TreatmentConfig -> Text
$sel:feature:TreatmentConfig' :: TreatmentConfig -> Text
$sel:description:TreatmentConfig' :: TreatmentConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"description" 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
description,
            forall a. a -> Maybe a
Prelude.Just (Key
"feature" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
feature),
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"variation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
variation)
          ]
      )