module LaunchDarkly.Server.Features where

import Control.Monad                 (mzero)
import Data.Aeson                    (FromJSON(..), ToJSON(..), Value(..), withObject, (.:), (.:?), object, (.=), (.!=))
import Data.Text                     (Text)
import Data.HashSet                  (HashSet)
import Data.Generics.Product         (getField)
import GHC.Natural                   (Natural)
import GHC.Generics                  (Generic)

import LaunchDarkly.Server.Operators (Op)

data Target = Target
    { Target -> [Text]
values    :: ![Text]
    , Target -> Natural
variation :: !Natural
    } deriving ((forall x. Target -> Rep Target x)
-> (forall x. Rep Target x -> Target) -> Generic Target
forall x. Rep Target x -> Target
forall x. Target -> Rep Target x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Target x -> Target
$cfrom :: forall x. Target -> Rep Target x
Generic, Value -> Parser [Target]
Value -> Parser Target
(Value -> Parser Target)
-> (Value -> Parser [Target]) -> FromJSON Target
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Target]
$cparseJSONList :: Value -> Parser [Target]
parseJSON :: Value -> Parser Target
$cparseJSON :: Value -> Parser Target
FromJSON, [Target] -> Encoding
[Target] -> Value
Target -> Encoding
Target -> Value
(Target -> Value)
-> (Target -> Encoding)
-> ([Target] -> Value)
-> ([Target] -> Encoding)
-> ToJSON Target
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Target] -> Encoding
$ctoEncodingList :: [Target] -> Encoding
toJSONList :: [Target] -> Value
$ctoJSONList :: [Target] -> Value
toEncoding :: Target -> Encoding
$ctoEncoding :: Target -> Encoding
toJSON :: Target -> Value
$ctoJSON :: Target -> Value
ToJSON, Int -> Target -> ShowS
[Target] -> ShowS
Target -> String
(Int -> Target -> ShowS)
-> (Target -> String) -> ([Target] -> ShowS) -> Show Target
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Target] -> ShowS
$cshowList :: [Target] -> ShowS
show :: Target -> String
$cshow :: Target -> String
showsPrec :: Int -> Target -> ShowS
$cshowsPrec :: Int -> Target -> ShowS
Show, Target -> Target -> Bool
(Target -> Target -> Bool)
-> (Target -> Target -> Bool) -> Eq Target
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Target -> Target -> Bool
$c/= :: Target -> Target -> Bool
== :: Target -> Target -> Bool
$c== :: Target -> Target -> Bool
Eq)

data Rule = Rule
    { Rule -> Text
id                 :: !Text
    , Rule -> [Clause]
clauses            :: ![Clause]
    , Rule -> VariationOrRollout
variationOrRollout :: !VariationOrRollout
    , Rule -> Bool
trackEvents        :: !Bool
    } deriving ((forall x. Rule -> Rep Rule x)
-> (forall x. Rep Rule x -> Rule) -> Generic Rule
forall x. Rep Rule x -> Rule
forall x. Rule -> Rep Rule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Rule x -> Rule
$cfrom :: forall x. Rule -> Rep Rule x
Generic, Int -> Rule -> ShowS
[Rule] -> ShowS
Rule -> String
(Int -> Rule -> ShowS)
-> (Rule -> String) -> ([Rule] -> ShowS) -> Show Rule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rule] -> ShowS
$cshowList :: [Rule] -> ShowS
show :: Rule -> String
$cshow :: Rule -> String
showsPrec :: Int -> Rule -> ShowS
$cshowsPrec :: Int -> Rule -> ShowS
Show, Rule -> Rule -> Bool
(Rule -> Rule -> Bool) -> (Rule -> Rule -> Bool) -> Eq Rule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rule -> Rule -> Bool
$c/= :: Rule -> Rule -> Bool
== :: Rule -> Rule -> Bool
$c== :: Rule -> Rule -> Bool
Eq)

instance FromJSON Rule where
    parseJSON :: Value -> Parser Rule
parseJSON = String -> (Object -> Parser Rule) -> Value -> Parser Rule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Rule" ((Object -> Parser Rule) -> Value -> Parser Rule)
-> (Object -> Parser Rule) -> Value -> Parser Rule
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Text
id          <- Object
o Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.:  Text
"id"
        [Clause]
clauses     <- Object
o Object -> Text -> Parser [Clause]
forall a. FromJSON a => Object -> Text -> Parser a
.:  Text
"clauses"
        Maybe Natural
variation   <- Object
o Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"variation"
        Maybe Rollout
rollout     <- Object
o Object -> Text -> Parser (Maybe Rollout)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"rollout"
        Bool
trackEvents <- Object
o Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
.:  Text
"trackEvents"
        Rule -> Parser Rule
forall (f :: * -> *) a. Applicative f => a -> f a
pure Rule :: Text -> [Clause] -> VariationOrRollout -> Bool -> Rule
Rule
            { $sel:id:Rule :: Text
id                 = Text
id
            , $sel:clauses:Rule :: [Clause]
clauses            = [Clause]
clauses
            , $sel:variationOrRollout:Rule :: VariationOrRollout
variationOrRollout = VariationOrRollout :: Maybe Natural -> Maybe Rollout -> VariationOrRollout
VariationOrRollout
                { $sel:variation:VariationOrRollout :: Maybe Natural
variation = Maybe Natural
variation
                , $sel:rollout:VariationOrRollout :: Maybe Rollout
rollout   = Maybe Rollout
rollout
                }
            , $sel:trackEvents:Rule :: Bool
trackEvents        = Bool
trackEvents
            }

instance ToJSON Rule where
    toJSON :: Rule -> Value
toJSON Rule
rule = [Pair] -> Value
object
        [ Text
"id"          Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Rule -> Text
forall (f :: Symbol) a s. HasField' f s a => s -> a
getField @"id" Rule
rule
        , Text
"clauses"     Text -> [Clause] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Rule -> [Clause]
forall (f :: Symbol) a s. HasField' f s a => s -> a
getField @"clauses" Rule
rule
        , Text
"trackEvents" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Rule -> Bool
forall (f :: Symbol) a s. HasField' f s a => s -> a
getField @"trackEvents" Rule
rule
        , Text
"variation"   Text -> Maybe Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= VariationOrRollout -> Maybe Natural
forall (f :: Symbol) a s. HasField' f s a => s -> a
getField @"variation" (Rule -> VariationOrRollout
forall (f :: Symbol) a s. HasField' f s a => s -> a
getField @"variationOrRollout" Rule
rule)
        , Text
"rollout"     Text -> Maybe Rollout -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= VariationOrRollout -> Maybe Rollout
forall (f :: Symbol) a s. HasField' f s a => s -> a
getField @"rollout" (Rule -> VariationOrRollout
forall (f :: Symbol) a s. HasField' f s a => s -> a
getField @"variationOrRollout" Rule
rule)
        ]

data WeightedVariation = WeightedVariation
    { WeightedVariation -> Natural
variation :: !Natural
    , WeightedVariation -> Float
weight    :: !Float
    , WeightedVariation -> Bool
untracked :: !Bool
    } deriving ((forall x. WeightedVariation -> Rep WeightedVariation x)
-> (forall x. Rep WeightedVariation x -> WeightedVariation)
-> Generic WeightedVariation
forall x. Rep WeightedVariation x -> WeightedVariation
forall x. WeightedVariation -> Rep WeightedVariation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WeightedVariation x -> WeightedVariation
$cfrom :: forall x. WeightedVariation -> Rep WeightedVariation x
Generic, [WeightedVariation] -> Encoding
[WeightedVariation] -> Value
WeightedVariation -> Encoding
WeightedVariation -> Value
(WeightedVariation -> Value)
-> (WeightedVariation -> Encoding)
-> ([WeightedVariation] -> Value)
-> ([WeightedVariation] -> Encoding)
-> ToJSON WeightedVariation
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [WeightedVariation] -> Encoding
$ctoEncodingList :: [WeightedVariation] -> Encoding
toJSONList :: [WeightedVariation] -> Value
$ctoJSONList :: [WeightedVariation] -> Value
toEncoding :: WeightedVariation -> Encoding
$ctoEncoding :: WeightedVariation -> Encoding
toJSON :: WeightedVariation -> Value
$ctoJSON :: WeightedVariation -> Value
ToJSON, Int -> WeightedVariation -> ShowS
[WeightedVariation] -> ShowS
WeightedVariation -> String
(Int -> WeightedVariation -> ShowS)
-> (WeightedVariation -> String)
-> ([WeightedVariation] -> ShowS)
-> Show WeightedVariation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WeightedVariation] -> ShowS
$cshowList :: [WeightedVariation] -> ShowS
show :: WeightedVariation -> String
$cshow :: WeightedVariation -> String
showsPrec :: Int -> WeightedVariation -> ShowS
$cshowsPrec :: Int -> WeightedVariation -> ShowS
Show, WeightedVariation -> WeightedVariation -> Bool
(WeightedVariation -> WeightedVariation -> Bool)
-> (WeightedVariation -> WeightedVariation -> Bool)
-> Eq WeightedVariation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WeightedVariation -> WeightedVariation -> Bool
$c/= :: WeightedVariation -> WeightedVariation -> Bool
== :: WeightedVariation -> WeightedVariation -> Bool
$c== :: WeightedVariation -> WeightedVariation -> Bool
Eq)

instance FromJSON WeightedVariation where
    parseJSON :: Value -> Parser WeightedVariation
parseJSON = String
-> (Object -> Parser WeightedVariation)
-> Value
-> Parser WeightedVariation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"WeightedVariation" ((Object -> Parser WeightedVariation)
 -> Value -> Parser WeightedVariation)
-> (Object -> Parser WeightedVariation)
-> Value
-> Parser WeightedVariation
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Natural
variation <- Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.:  Text
"variation"
        Float
weight    <- Object
o Object -> Text -> Parser Float
forall a. FromJSON a => Object -> Text -> Parser a
.:  Text
"weight"
        Bool
untracked <- Object
o Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"untracked" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
.!= Bool
False
        WeightedVariation -> Parser WeightedVariation
forall (f :: * -> *) a. Applicative f => a -> f a
pure WeightedVariation :: Natural -> Float -> Bool -> WeightedVariation
WeightedVariation { Bool
Float
Natural
untracked :: Bool
weight :: Float
variation :: Natural
$sel:untracked:WeightedVariation :: Bool
$sel:weight:WeightedVariation :: Float
$sel:variation:WeightedVariation :: Natural
.. }

data RolloutKind = RolloutKindExperiment | RolloutKindRollout
    deriving (RolloutKind -> RolloutKind -> Bool
(RolloutKind -> RolloutKind -> Bool)
-> (RolloutKind -> RolloutKind -> Bool) -> Eq RolloutKind
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RolloutKind -> RolloutKind -> Bool
$c/= :: RolloutKind -> RolloutKind -> Bool
== :: RolloutKind -> RolloutKind -> Bool
$c== :: RolloutKind -> RolloutKind -> Bool
Eq, Int -> RolloutKind -> ShowS
[RolloutKind] -> ShowS
RolloutKind -> String
(Int -> RolloutKind -> ShowS)
-> (RolloutKind -> String)
-> ([RolloutKind] -> ShowS)
-> Show RolloutKind
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RolloutKind] -> ShowS
$cshowList :: [RolloutKind] -> ShowS
show :: RolloutKind -> String
$cshow :: RolloutKind -> String
showsPrec :: Int -> RolloutKind -> ShowS
$cshowsPrec :: Int -> RolloutKind -> ShowS
Show)

instance ToJSON RolloutKind where
    toJSON :: RolloutKind -> Value
toJSON RolloutKind
x = Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ case RolloutKind
x of
        RolloutKind
RolloutKindExperiment -> Text
"experiment" 
        RolloutKind
RolloutKindRollout    -> Text
"rollout"

instance FromJSON RolloutKind where
    parseJSON :: Value -> Parser RolloutKind
parseJSON Value
x = case Value
x of
        (String Text
"experiment") -> RolloutKind -> Parser RolloutKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure RolloutKind
RolloutKindExperiment
        (String Text
"rollout")    -> RolloutKind -> Parser RolloutKind
forall (f :: * -> *) a. Applicative f => a -> f a
pure RolloutKind
RolloutKindRollout
        Value
_                     -> Parser RolloutKind
forall (m :: * -> *) a. MonadPlus m => m a
mzero

data Rollout = Rollout
    { Rollout -> [WeightedVariation]
variations :: ![WeightedVariation]
    , Rollout -> Maybe Text
bucketBy   :: !(Maybe Text)
    , Rollout -> RolloutKind
kind       :: !RolloutKind
    , Rollout -> Maybe Int
seed       :: !(Maybe Int)
    } deriving ((forall x. Rollout -> Rep Rollout x)
-> (forall x. Rep Rollout x -> Rollout) -> Generic Rollout
forall x. Rep Rollout x -> Rollout
forall x. Rollout -> Rep Rollout x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Rollout x -> Rollout
$cfrom :: forall x. Rollout -> Rep Rollout x
Generic, [Rollout] -> Encoding
[Rollout] -> Value
Rollout -> Encoding
Rollout -> Value
(Rollout -> Value)
-> (Rollout -> Encoding)
-> ([Rollout] -> Value)
-> ([Rollout] -> Encoding)
-> ToJSON Rollout
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Rollout] -> Encoding
$ctoEncodingList :: [Rollout] -> Encoding
toJSONList :: [Rollout] -> Value
$ctoJSONList :: [Rollout] -> Value
toEncoding :: Rollout -> Encoding
$ctoEncoding :: Rollout -> Encoding
toJSON :: Rollout -> Value
$ctoJSON :: Rollout -> Value
ToJSON, Int -> Rollout -> ShowS
[Rollout] -> ShowS
Rollout -> String
(Int -> Rollout -> ShowS)
-> (Rollout -> String) -> ([Rollout] -> ShowS) -> Show Rollout
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rollout] -> ShowS
$cshowList :: [Rollout] -> ShowS
show :: Rollout -> String
$cshow :: Rollout -> String
showsPrec :: Int -> Rollout -> ShowS
$cshowsPrec :: Int -> Rollout -> ShowS
Show, Rollout -> Rollout -> Bool
(Rollout -> Rollout -> Bool)
-> (Rollout -> Rollout -> Bool) -> Eq Rollout
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rollout -> Rollout -> Bool
$c/= :: Rollout -> Rollout -> Bool
== :: Rollout -> Rollout -> Bool
$c== :: Rollout -> Rollout -> Bool
Eq)

instance FromJSON Rollout where
    parseJSON :: Value -> Parser Rollout
parseJSON = String -> (Object -> Parser Rollout) -> Value -> Parser Rollout
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"rollout" ((Object -> Parser Rollout) -> Value -> Parser Rollout)
-> (Object -> Parser Rollout) -> Value -> Parser Rollout
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        [WeightedVariation]
variations <- Object
o Object -> Text -> Parser [WeightedVariation]
forall a. FromJSON a => Object -> Text -> Parser a
.:  Text
"variations"
        Maybe Text
bucketBy   <- Object
o Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"bucketBy"
        RolloutKind
kind       <- Object
o Object -> Text -> Parser (Maybe RolloutKind)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"kind" Parser (Maybe RolloutKind) -> RolloutKind -> Parser RolloutKind
forall a. Parser (Maybe a) -> a -> Parser a
.!= RolloutKind
RolloutKindRollout
        Maybe Int
seed       <- Object
o Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"seed"
        Rollout -> Parser Rollout
forall (f :: * -> *) a. Applicative f => a -> f a
pure Rollout :: [WeightedVariation]
-> Maybe Text -> RolloutKind -> Maybe Int -> Rollout
Rollout { [WeightedVariation]
Maybe Int
Maybe Text
RolloutKind
seed :: Maybe Int
kind :: RolloutKind
bucketBy :: Maybe Text
variations :: [WeightedVariation]
$sel:seed:Rollout :: Maybe Int
$sel:kind:Rollout :: RolloutKind
$sel:bucketBy:Rollout :: Maybe Text
$sel:variations:Rollout :: [WeightedVariation]
.. }

data VariationOrRollout = VariationOrRollout
    { VariationOrRollout -> Maybe Natural
variation :: !(Maybe Natural)
    , VariationOrRollout -> Maybe Rollout
rollout   :: !(Maybe Rollout)
    } deriving ((forall x. VariationOrRollout -> Rep VariationOrRollout x)
-> (forall x. Rep VariationOrRollout x -> VariationOrRollout)
-> Generic VariationOrRollout
forall x. Rep VariationOrRollout x -> VariationOrRollout
forall x. VariationOrRollout -> Rep VariationOrRollout x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VariationOrRollout x -> VariationOrRollout
$cfrom :: forall x. VariationOrRollout -> Rep VariationOrRollout x
Generic, Value -> Parser [VariationOrRollout]
Value -> Parser VariationOrRollout
(Value -> Parser VariationOrRollout)
-> (Value -> Parser [VariationOrRollout])
-> FromJSON VariationOrRollout
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [VariationOrRollout]
$cparseJSONList :: Value -> Parser [VariationOrRollout]
parseJSON :: Value -> Parser VariationOrRollout
$cparseJSON :: Value -> Parser VariationOrRollout
FromJSON, [VariationOrRollout] -> Encoding
[VariationOrRollout] -> Value
VariationOrRollout -> Encoding
VariationOrRollout -> Value
(VariationOrRollout -> Value)
-> (VariationOrRollout -> Encoding)
-> ([VariationOrRollout] -> Value)
-> ([VariationOrRollout] -> Encoding)
-> ToJSON VariationOrRollout
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [VariationOrRollout] -> Encoding
$ctoEncodingList :: [VariationOrRollout] -> Encoding
toJSONList :: [VariationOrRollout] -> Value
$ctoJSONList :: [VariationOrRollout] -> Value
toEncoding :: VariationOrRollout -> Encoding
$ctoEncoding :: VariationOrRollout -> Encoding
toJSON :: VariationOrRollout -> Value
$ctoJSON :: VariationOrRollout -> Value
ToJSON, Int -> VariationOrRollout -> ShowS
[VariationOrRollout] -> ShowS
VariationOrRollout -> String
(Int -> VariationOrRollout -> ShowS)
-> (VariationOrRollout -> String)
-> ([VariationOrRollout] -> ShowS)
-> Show VariationOrRollout
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VariationOrRollout] -> ShowS
$cshowList :: [VariationOrRollout] -> ShowS
show :: VariationOrRollout -> String
$cshow :: VariationOrRollout -> String
showsPrec :: Int -> VariationOrRollout -> ShowS
$cshowsPrec :: Int -> VariationOrRollout -> ShowS
Show, VariationOrRollout -> VariationOrRollout -> Bool
(VariationOrRollout -> VariationOrRollout -> Bool)
-> (VariationOrRollout -> VariationOrRollout -> Bool)
-> Eq VariationOrRollout
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VariationOrRollout -> VariationOrRollout -> Bool
$c/= :: VariationOrRollout -> VariationOrRollout -> Bool
== :: VariationOrRollout -> VariationOrRollout -> Bool
$c== :: VariationOrRollout -> VariationOrRollout -> Bool
Eq)

data Flag = Flag
    { Flag -> Text
key                    :: !Text
    , Flag -> Natural
version                :: !Natural
    , Flag -> Bool
on                     :: !Bool
    , Flag -> Bool
trackEvents            :: !Bool
    , Flag -> Bool
trackEventsFallthrough :: !Bool
    , Flag -> Bool
deleted                :: !Bool
    , Flag -> [Prerequisite]
prerequisites          :: ![Prerequisite]
    , Flag -> Text
salt                   :: !Text
    , Flag -> [Target]
targets                :: ![Target]
    , Flag -> [Rule]
rules                  :: ![Rule]
    , Flag -> VariationOrRollout
fallthrough            :: !VariationOrRollout
    , Flag -> Maybe Natural
offVariation           :: !(Maybe Natural)
    , Flag -> [Value]
variations             :: ![Value]
    , Flag -> Maybe Natural
debugEventsUntilDate   :: !(Maybe Natural)
    } deriving ((forall x. Flag -> Rep Flag x)
-> (forall x. Rep Flag x -> Flag) -> Generic Flag
forall x. Rep Flag x -> Flag
forall x. Flag -> Rep Flag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Flag x -> Flag
$cfrom :: forall x. Flag -> Rep Flag x
Generic, [Flag] -> Encoding
[Flag] -> Value
Flag -> Encoding
Flag -> Value
(Flag -> Value)
-> (Flag -> Encoding)
-> ([Flag] -> Value)
-> ([Flag] -> Encoding)
-> ToJSON Flag
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Flag] -> Encoding
$ctoEncodingList :: [Flag] -> Encoding
toJSONList :: [Flag] -> Value
$ctoJSONList :: [Flag] -> Value
toEncoding :: Flag -> Encoding
$ctoEncoding :: Flag -> Encoding
toJSON :: Flag -> Value
$ctoJSON :: Flag -> Value
ToJSON, Value -> Parser [Flag]
Value -> Parser Flag
(Value -> Parser Flag) -> (Value -> Parser [Flag]) -> FromJSON Flag
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Flag]
$cparseJSONList :: Value -> Parser [Flag]
parseJSON :: Value -> Parser Flag
$cparseJSON :: Value -> Parser Flag
FromJSON, Int -> Flag -> ShowS
[Flag] -> ShowS
Flag -> String
(Int -> Flag -> ShowS)
-> (Flag -> String) -> ([Flag] -> ShowS) -> Show Flag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Flag] -> ShowS
$cshowList :: [Flag] -> ShowS
show :: Flag -> String
$cshow :: Flag -> String
showsPrec :: Int -> Flag -> ShowS
$cshowsPrec :: Int -> Flag -> ShowS
Show, Flag -> Flag -> Bool
(Flag -> Flag -> Bool) -> (Flag -> Flag -> Bool) -> Eq Flag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Flag -> Flag -> Bool
$c/= :: Flag -> Flag -> Bool
== :: Flag -> Flag -> Bool
$c== :: Flag -> Flag -> Bool
Eq)

data Prerequisite = Prerequisite
    { Prerequisite -> Text
key       :: !Text
    , Prerequisite -> Natural
variation :: !Natural
    } deriving ((forall x. Prerequisite -> Rep Prerequisite x)
-> (forall x. Rep Prerequisite x -> Prerequisite)
-> Generic Prerequisite
forall x. Rep Prerequisite x -> Prerequisite
forall x. Prerequisite -> Rep Prerequisite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Prerequisite x -> Prerequisite
$cfrom :: forall x. Prerequisite -> Rep Prerequisite x
Generic, Value -> Parser [Prerequisite]
Value -> Parser Prerequisite
(Value -> Parser Prerequisite)
-> (Value -> Parser [Prerequisite]) -> FromJSON Prerequisite
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Prerequisite]
$cparseJSONList :: Value -> Parser [Prerequisite]
parseJSON :: Value -> Parser Prerequisite
$cparseJSON :: Value -> Parser Prerequisite
FromJSON, [Prerequisite] -> Encoding
[Prerequisite] -> Value
Prerequisite -> Encoding
Prerequisite -> Value
(Prerequisite -> Value)
-> (Prerequisite -> Encoding)
-> ([Prerequisite] -> Value)
-> ([Prerequisite] -> Encoding)
-> ToJSON Prerequisite
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Prerequisite] -> Encoding
$ctoEncodingList :: [Prerequisite] -> Encoding
toJSONList :: [Prerequisite] -> Value
$ctoJSONList :: [Prerequisite] -> Value
toEncoding :: Prerequisite -> Encoding
$ctoEncoding :: Prerequisite -> Encoding
toJSON :: Prerequisite -> Value
$ctoJSON :: Prerequisite -> Value
ToJSON, Int -> Prerequisite -> ShowS
[Prerequisite] -> ShowS
Prerequisite -> String
(Int -> Prerequisite -> ShowS)
-> (Prerequisite -> String)
-> ([Prerequisite] -> ShowS)
-> Show Prerequisite
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Prerequisite] -> ShowS
$cshowList :: [Prerequisite] -> ShowS
show :: Prerequisite -> String
$cshow :: Prerequisite -> String
showsPrec :: Int -> Prerequisite -> ShowS
$cshowsPrec :: Int -> Prerequisite -> ShowS
Show, Prerequisite -> Prerequisite -> Bool
(Prerequisite -> Prerequisite -> Bool)
-> (Prerequisite -> Prerequisite -> Bool) -> Eq Prerequisite
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Prerequisite -> Prerequisite -> Bool
$c/= :: Prerequisite -> Prerequisite -> Bool
== :: Prerequisite -> Prerequisite -> Bool
$c== :: Prerequisite -> Prerequisite -> Bool
Eq)

data SegmentRule = SegmentRule
    { SegmentRule -> Text
id       :: !Text
    , SegmentRule -> [Clause]
clauses  :: ![Clause]
    , SegmentRule -> Maybe Float
weight   :: !(Maybe Float)
    , SegmentRule -> Maybe Text
bucketBy :: !(Maybe Text)
    } deriving ((forall x. SegmentRule -> Rep SegmentRule x)
-> (forall x. Rep SegmentRule x -> SegmentRule)
-> Generic SegmentRule
forall x. Rep SegmentRule x -> SegmentRule
forall x. SegmentRule -> Rep SegmentRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SegmentRule x -> SegmentRule
$cfrom :: forall x. SegmentRule -> Rep SegmentRule x
Generic, Value -> Parser [SegmentRule]
Value -> Parser SegmentRule
(Value -> Parser SegmentRule)
-> (Value -> Parser [SegmentRule]) -> FromJSON SegmentRule
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [SegmentRule]
$cparseJSONList :: Value -> Parser [SegmentRule]
parseJSON :: Value -> Parser SegmentRule
$cparseJSON :: Value -> Parser SegmentRule
FromJSON, [SegmentRule] -> Encoding
[SegmentRule] -> Value
SegmentRule -> Encoding
SegmentRule -> Value
(SegmentRule -> Value)
-> (SegmentRule -> Encoding)
-> ([SegmentRule] -> Value)
-> ([SegmentRule] -> Encoding)
-> ToJSON SegmentRule
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [SegmentRule] -> Encoding
$ctoEncodingList :: [SegmentRule] -> Encoding
toJSONList :: [SegmentRule] -> Value
$ctoJSONList :: [SegmentRule] -> Value
toEncoding :: SegmentRule -> Encoding
$ctoEncoding :: SegmentRule -> Encoding
toJSON :: SegmentRule -> Value
$ctoJSON :: SegmentRule -> Value
ToJSON, Int -> SegmentRule -> ShowS
[SegmentRule] -> ShowS
SegmentRule -> String
(Int -> SegmentRule -> ShowS)
-> (SegmentRule -> String)
-> ([SegmentRule] -> ShowS)
-> Show SegmentRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SegmentRule] -> ShowS
$cshowList :: [SegmentRule] -> ShowS
show :: SegmentRule -> String
$cshow :: SegmentRule -> String
showsPrec :: Int -> SegmentRule -> ShowS
$cshowsPrec :: Int -> SegmentRule -> ShowS
Show, SegmentRule -> SegmentRule -> Bool
(SegmentRule -> SegmentRule -> Bool)
-> (SegmentRule -> SegmentRule -> Bool) -> Eq SegmentRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SegmentRule -> SegmentRule -> Bool
$c/= :: SegmentRule -> SegmentRule -> Bool
== :: SegmentRule -> SegmentRule -> Bool
$c== :: SegmentRule -> SegmentRule -> Bool
Eq)

data Segment = Segment
    { Segment -> Text
key      :: !Text
    , Segment -> HashSet Text
included :: !(HashSet Text)
    , Segment -> HashSet Text
excluded :: !(HashSet Text)
    , Segment -> Text
salt     :: !Text
    , Segment -> [SegmentRule]
rules    :: ![SegmentRule]
    , Segment -> Natural
version  :: !Natural
    , Segment -> Bool
deleted  :: !Bool
    } deriving ((forall x. Segment -> Rep Segment x)
-> (forall x. Rep Segment x -> Segment) -> Generic Segment
forall x. Rep Segment x -> Segment
forall x. Segment -> Rep Segment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Segment x -> Segment
$cfrom :: forall x. Segment -> Rep Segment x
Generic, Value -> Parser [Segment]
Value -> Parser Segment
(Value -> Parser Segment)
-> (Value -> Parser [Segment]) -> FromJSON Segment
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Segment]
$cparseJSONList :: Value -> Parser [Segment]
parseJSON :: Value -> Parser Segment
$cparseJSON :: Value -> Parser Segment
FromJSON, [Segment] -> Encoding
[Segment] -> Value
Segment -> Encoding
Segment -> Value
(Segment -> Value)
-> (Segment -> Encoding)
-> ([Segment] -> Value)
-> ([Segment] -> Encoding)
-> ToJSON Segment
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Segment] -> Encoding
$ctoEncodingList :: [Segment] -> Encoding
toJSONList :: [Segment] -> Value
$ctoJSONList :: [Segment] -> Value
toEncoding :: Segment -> Encoding
$ctoEncoding :: Segment -> Encoding
toJSON :: Segment -> Value
$ctoJSON :: Segment -> Value
ToJSON, Int -> Segment -> ShowS
[Segment] -> ShowS
Segment -> String
(Int -> Segment -> ShowS)
-> (Segment -> String) -> ([Segment] -> ShowS) -> Show Segment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Segment] -> ShowS
$cshowList :: [Segment] -> ShowS
show :: Segment -> String
$cshow :: Segment -> String
showsPrec :: Int -> Segment -> ShowS
$cshowsPrec :: Int -> Segment -> ShowS
Show, Segment -> Segment -> Bool
(Segment -> Segment -> Bool)
-> (Segment -> Segment -> Bool) -> Eq Segment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Segment -> Segment -> Bool
$c/= :: Segment -> Segment -> Bool
== :: Segment -> Segment -> Bool
$c== :: Segment -> Segment -> Bool
Eq)

data Clause = Clause
    { Clause -> Text
attribute :: !Text
    , Clause -> Bool
negate    :: !Bool
    , Clause -> Op
op        :: !Op
    , Clause -> [Value]
values    :: ![Value]
    } deriving ((forall x. Clause -> Rep Clause x)
-> (forall x. Rep Clause x -> Clause) -> Generic Clause
forall x. Rep Clause x -> Clause
forall x. Clause -> Rep Clause x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Clause x -> Clause
$cfrom :: forall x. Clause -> Rep Clause x
Generic, Value -> Parser [Clause]
Value -> Parser Clause
(Value -> Parser Clause)
-> (Value -> Parser [Clause]) -> FromJSON Clause
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Clause]
$cparseJSONList :: Value -> Parser [Clause]
parseJSON :: Value -> Parser Clause
$cparseJSON :: Value -> Parser Clause
FromJSON, [Clause] -> Encoding
[Clause] -> Value
Clause -> Encoding
Clause -> Value
(Clause -> Value)
-> (Clause -> Encoding)
-> ([Clause] -> Value)
-> ([Clause] -> Encoding)
-> ToJSON Clause
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Clause] -> Encoding
$ctoEncodingList :: [Clause] -> Encoding
toJSONList :: [Clause] -> Value
$ctoJSONList :: [Clause] -> Value
toEncoding :: Clause -> Encoding
$ctoEncoding :: Clause -> Encoding
toJSON :: Clause -> Value
$ctoJSON :: Clause -> Value
ToJSON, Int -> Clause -> ShowS
[Clause] -> ShowS
Clause -> String
(Int -> Clause -> ShowS)
-> (Clause -> String) -> ([Clause] -> ShowS) -> Show Clause
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Clause] -> ShowS
$cshowList :: [Clause] -> ShowS
show :: Clause -> String
$cshow :: Clause -> String
showsPrec :: Int -> Clause -> ShowS
$cshowsPrec :: Int -> Clause -> ShowS
Show, Clause -> Clause -> Bool
(Clause -> Clause -> Bool)
-> (Clause -> Clause -> Bool) -> Eq Clause
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Clause -> Clause -> Bool
$c/= :: Clause -> Clause -> Bool
== :: Clause -> Clause -> Bool
$c== :: Clause -> Clause -> Bool
Eq)