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

-- | This structure defines the traffic allocation percentages among the
-- feature variations during one step of a launch, and the start time of
-- that step.
--
-- /See:/ 'newScheduledSplit' smart constructor.
data ScheduledSplit = ScheduledSplit'
  { -- | The traffic allocation percentages among the feature variations during
    -- one step of a launch. This is a set of key-value pairs. The keys are
    -- variation names. The values represent the percentage of traffic to
    -- allocate to that variation during this step.
    --
    -- The values is expressed in thousandths of a percent, so assigning a
    -- weight of 50000 assigns 50% of traffic to that variation.
    --
    -- If the sum of the weights for all the variations in a segment override
    -- does not add up to 100,000, then the remaining traffic that matches this
    -- segment is not assigned by this segment override, and instead moves on
    -- to the next segment override or the default traffic split.
    ScheduledSplit -> Maybe (HashMap Text Natural)
groupWeights :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Natural),
    -- | Use this parameter to specify different traffic splits for one or more
    -- audience /segments/. A segment is a portion of your audience that share
    -- one or more characteristics. Examples could be Chrome browser users,
    -- users in Europe, or Firefox browser users in Europe who also fit other
    -- criteria that your application collects, such as age.
    --
    -- This parameter is an array of up to six segment override objects. Each
    -- of these objects specifies a segment that you have already created, and
    -- defines the traffic split for that segment.
    ScheduledSplit -> Maybe [SegmentOverride]
segmentOverrides :: Prelude.Maybe [SegmentOverride],
    -- | The date and time that this step of the launch starts.
    ScheduledSplit -> POSIX
startTime :: Data.POSIX
  }
  deriving (ScheduledSplit -> ScheduledSplit -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduledSplit -> ScheduledSplit -> Bool
$c/= :: ScheduledSplit -> ScheduledSplit -> Bool
== :: ScheduledSplit -> ScheduledSplit -> Bool
$c== :: ScheduledSplit -> ScheduledSplit -> Bool
Prelude.Eq, ReadPrec [ScheduledSplit]
ReadPrec ScheduledSplit
Int -> ReadS ScheduledSplit
ReadS [ScheduledSplit]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduledSplit]
$creadListPrec :: ReadPrec [ScheduledSplit]
readPrec :: ReadPrec ScheduledSplit
$creadPrec :: ReadPrec ScheduledSplit
readList :: ReadS [ScheduledSplit]
$creadList :: ReadS [ScheduledSplit]
readsPrec :: Int -> ReadS ScheduledSplit
$creadsPrec :: Int -> ReadS ScheduledSplit
Prelude.Read, Int -> ScheduledSplit -> ShowS
[ScheduledSplit] -> ShowS
ScheduledSplit -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduledSplit] -> ShowS
$cshowList :: [ScheduledSplit] -> ShowS
show :: ScheduledSplit -> String
$cshow :: ScheduledSplit -> String
showsPrec :: Int -> ScheduledSplit -> ShowS
$cshowsPrec :: Int -> ScheduledSplit -> ShowS
Prelude.Show, forall x. Rep ScheduledSplit x -> ScheduledSplit
forall x. ScheduledSplit -> Rep ScheduledSplit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScheduledSplit x -> ScheduledSplit
$cfrom :: forall x. ScheduledSplit -> Rep ScheduledSplit x
Prelude.Generic)

-- |
-- Create a value of 'ScheduledSplit' 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:
--
-- 'groupWeights', 'scheduledSplit_groupWeights' - The traffic allocation percentages among the feature variations during
-- one step of a launch. This is a set of key-value pairs. The keys are
-- variation names. The values represent the percentage of traffic to
-- allocate to that variation during this step.
--
-- The values is expressed in thousandths of a percent, so assigning a
-- weight of 50000 assigns 50% of traffic to that variation.
--
-- If the sum of the weights for all the variations in a segment override
-- does not add up to 100,000, then the remaining traffic that matches this
-- segment is not assigned by this segment override, and instead moves on
-- to the next segment override or the default traffic split.
--
-- 'segmentOverrides', 'scheduledSplit_segmentOverrides' - Use this parameter to specify different traffic splits for one or more
-- audience /segments/. A segment is a portion of your audience that share
-- one or more characteristics. Examples could be Chrome browser users,
-- users in Europe, or Firefox browser users in Europe who also fit other
-- criteria that your application collects, such as age.
--
-- This parameter is an array of up to six segment override objects. Each
-- of these objects specifies a segment that you have already created, and
-- defines the traffic split for that segment.
--
-- 'startTime', 'scheduledSplit_startTime' - The date and time that this step of the launch starts.
newScheduledSplit ::
  -- | 'startTime'
  Prelude.UTCTime ->
  ScheduledSplit
newScheduledSplit :: UTCTime -> ScheduledSplit
newScheduledSplit UTCTime
pStartTime_ =
  ScheduledSplit'
    { $sel:groupWeights:ScheduledSplit' :: Maybe (HashMap Text Natural)
groupWeights = forall a. Maybe a
Prelude.Nothing,
      $sel:segmentOverrides:ScheduledSplit' :: Maybe [SegmentOverride]
segmentOverrides = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:ScheduledSplit' :: POSIX
startTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_
    }

-- | The traffic allocation percentages among the feature variations during
-- one step of a launch. This is a set of key-value pairs. The keys are
-- variation names. The values represent the percentage of traffic to
-- allocate to that variation during this step.
--
-- The values is expressed in thousandths of a percent, so assigning a
-- weight of 50000 assigns 50% of traffic to that variation.
--
-- If the sum of the weights for all the variations in a segment override
-- does not add up to 100,000, then the remaining traffic that matches this
-- segment is not assigned by this segment override, and instead moves on
-- to the next segment override or the default traffic split.
scheduledSplit_groupWeights :: Lens.Lens' ScheduledSplit (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Natural))
scheduledSplit_groupWeights :: Lens' ScheduledSplit (Maybe (HashMap Text Natural))
scheduledSplit_groupWeights = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledSplit' {Maybe (HashMap Text Natural)
groupWeights :: Maybe (HashMap Text Natural)
$sel:groupWeights:ScheduledSplit' :: ScheduledSplit -> Maybe (HashMap Text Natural)
groupWeights} -> Maybe (HashMap Text Natural)
groupWeights) (\s :: ScheduledSplit
s@ScheduledSplit' {} Maybe (HashMap Text Natural)
a -> ScheduledSplit
s {$sel:groupWeights:ScheduledSplit' :: Maybe (HashMap Text Natural)
groupWeights = Maybe (HashMap Text Natural)
a} :: ScheduledSplit) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Use this parameter to specify different traffic splits for one or more
-- audience /segments/. A segment is a portion of your audience that share
-- one or more characteristics. Examples could be Chrome browser users,
-- users in Europe, or Firefox browser users in Europe who also fit other
-- criteria that your application collects, such as age.
--
-- This parameter is an array of up to six segment override objects. Each
-- of these objects specifies a segment that you have already created, and
-- defines the traffic split for that segment.
scheduledSplit_segmentOverrides :: Lens.Lens' ScheduledSplit (Prelude.Maybe [SegmentOverride])
scheduledSplit_segmentOverrides :: Lens' ScheduledSplit (Maybe [SegmentOverride])
scheduledSplit_segmentOverrides = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledSplit' {Maybe [SegmentOverride]
segmentOverrides :: Maybe [SegmentOverride]
$sel:segmentOverrides:ScheduledSplit' :: ScheduledSplit -> Maybe [SegmentOverride]
segmentOverrides} -> Maybe [SegmentOverride]
segmentOverrides) (\s :: ScheduledSplit
s@ScheduledSplit' {} Maybe [SegmentOverride]
a -> ScheduledSplit
s {$sel:segmentOverrides:ScheduledSplit' :: Maybe [SegmentOverride]
segmentOverrides = Maybe [SegmentOverride]
a} :: ScheduledSplit) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The date and time that this step of the launch starts.
scheduledSplit_startTime :: Lens.Lens' ScheduledSplit Prelude.UTCTime
scheduledSplit_startTime :: Lens' ScheduledSplit UTCTime
scheduledSplit_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledSplit' {POSIX
startTime :: POSIX
$sel:startTime:ScheduledSplit' :: ScheduledSplit -> POSIX
startTime} -> POSIX
startTime) (\s :: ScheduledSplit
s@ScheduledSplit' {} POSIX
a -> ScheduledSplit
s {$sel:startTime:ScheduledSplit' :: POSIX
startTime = POSIX
a} :: ScheduledSplit) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON ScheduledSplit where
  parseJSON :: Value -> Parser ScheduledSplit
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ScheduledSplit"
      ( \Object
x ->
          Maybe (HashMap Text Natural)
-> Maybe [SegmentOverride] -> POSIX -> ScheduledSplit
ScheduledSplit'
            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
"groupWeights" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"segmentOverrides"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"startTime")
      )

instance Prelude.Hashable ScheduledSplit where
  hashWithSalt :: Int -> ScheduledSplit -> Int
hashWithSalt Int
_salt ScheduledSplit' {Maybe [SegmentOverride]
Maybe (HashMap Text Natural)
POSIX
startTime :: POSIX
segmentOverrides :: Maybe [SegmentOverride]
groupWeights :: Maybe (HashMap Text Natural)
$sel:startTime:ScheduledSplit' :: ScheduledSplit -> POSIX
$sel:segmentOverrides:ScheduledSplit' :: ScheduledSplit -> Maybe [SegmentOverride]
$sel:groupWeights:ScheduledSplit' :: ScheduledSplit -> Maybe (HashMap Text Natural)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Natural)
groupWeights
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SegmentOverride]
segmentOverrides
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
startTime

instance Prelude.NFData ScheduledSplit where
  rnf :: ScheduledSplit -> ()
rnf ScheduledSplit' {Maybe [SegmentOverride]
Maybe (HashMap Text Natural)
POSIX
startTime :: POSIX
segmentOverrides :: Maybe [SegmentOverride]
groupWeights :: Maybe (HashMap Text Natural)
$sel:startTime:ScheduledSplit' :: ScheduledSplit -> POSIX
$sel:segmentOverrides:ScheduledSplit' :: ScheduledSplit -> Maybe [SegmentOverride]
$sel:groupWeights:ScheduledSplit' :: ScheduledSplit -> Maybe (HashMap Text Natural)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Natural)
groupWeights
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SegmentOverride]
segmentOverrides
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
startTime