module WebDriverPreCore.BiDi.Browser
( ClientWindowInfo (..),
ClientWindowState (..),
CreateUserContext (..),
DownloadBehaviour (..),
GetClientWindowsResult (..),
GetUserContextsResult (..),
NamedState (..),
RectState (..),
RemoveUserContext (..),
SetClientWindowState (..),
SetDownloadBehavior (..),
WindowState (..),
)
where
import Data.Aeson (FromJSON (..), ToJSON (..), Value (..), object, (.=), KeyValue)
import Data.Aeson.KeyMap (fromList)
import Data.Aeson.Types (Parser)
import Data.Maybe (catMaybes)
import Data.Text (Text)
import GHC.Generics (Generic)
import WebDriverPreCore.BiDi.Capabilities (ProxyConfiguration, UserPromptHandler)
import WebDriverPreCore.BiDi.CoreTypes (ClientWindow, UserContext)
import AesonUtils (enumCamelCase, fromJSONCamelCase, opt)
data ClientWindowInfo = MkClientWindowInfo
{ ClientWindowInfo -> Bool
active :: Bool,
ClientWindowInfo -> ClientWindow
clientWindow :: ClientWindow,
ClientWindowInfo -> Int
height :: Int,
ClientWindowInfo -> ClientWindowState
state :: ClientWindowState,
ClientWindowInfo -> Int
width :: Int,
ClientWindowInfo -> Int
x :: Int,
ClientWindowInfo -> Int
y :: Int
}
deriving (Int -> ClientWindowInfo -> ShowS
[ClientWindowInfo] -> ShowS
ClientWindowInfo -> String
(Int -> ClientWindowInfo -> ShowS)
-> (ClientWindowInfo -> String)
-> ([ClientWindowInfo] -> ShowS)
-> Show ClientWindowInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClientWindowInfo -> ShowS
showsPrec :: Int -> ClientWindowInfo -> ShowS
$cshow :: ClientWindowInfo -> String
show :: ClientWindowInfo -> String
$cshowList :: [ClientWindowInfo] -> ShowS
showList :: [ClientWindowInfo] -> ShowS
Show, ClientWindowInfo -> ClientWindowInfo -> Bool
(ClientWindowInfo -> ClientWindowInfo -> Bool)
-> (ClientWindowInfo -> ClientWindowInfo -> Bool)
-> Eq ClientWindowInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClientWindowInfo -> ClientWindowInfo -> Bool
== :: ClientWindowInfo -> ClientWindowInfo -> Bool
$c/= :: ClientWindowInfo -> ClientWindowInfo -> Bool
/= :: ClientWindowInfo -> ClientWindowInfo -> Bool
Eq, (forall x. ClientWindowInfo -> Rep ClientWindowInfo x)
-> (forall x. Rep ClientWindowInfo x -> ClientWindowInfo)
-> Generic ClientWindowInfo
forall x. Rep ClientWindowInfo x -> ClientWindowInfo
forall x. ClientWindowInfo -> Rep ClientWindowInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ClientWindowInfo -> Rep ClientWindowInfo x
from :: forall x. ClientWindowInfo -> Rep ClientWindowInfo x
$cto :: forall x. Rep ClientWindowInfo x -> ClientWindowInfo
to :: forall x. Rep ClientWindowInfo x -> ClientWindowInfo
Generic)
instance FromJSON ClientWindowInfo
data ClientWindowState
= Fullscreen
| Maximized
| Minimized
| Normal
deriving (Int -> ClientWindowState -> ShowS
[ClientWindowState] -> ShowS
ClientWindowState -> String
(Int -> ClientWindowState -> ShowS)
-> (ClientWindowState -> String)
-> ([ClientWindowState] -> ShowS)
-> Show ClientWindowState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClientWindowState -> ShowS
showsPrec :: Int -> ClientWindowState -> ShowS
$cshow :: ClientWindowState -> String
show :: ClientWindowState -> String
$cshowList :: [ClientWindowState] -> ShowS
showList :: [ClientWindowState] -> ShowS
Show, ClientWindowState -> ClientWindowState -> Bool
(ClientWindowState -> ClientWindowState -> Bool)
-> (ClientWindowState -> ClientWindowState -> Bool)
-> Eq ClientWindowState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClientWindowState -> ClientWindowState -> Bool
== :: ClientWindowState -> ClientWindowState -> Bool
$c/= :: ClientWindowState -> ClientWindowState -> Bool
/= :: ClientWindowState -> ClientWindowState -> Bool
Eq, (forall x. ClientWindowState -> Rep ClientWindowState x)
-> (forall x. Rep ClientWindowState x -> ClientWindowState)
-> Generic ClientWindowState
forall x. Rep ClientWindowState x -> ClientWindowState
forall x. ClientWindowState -> Rep ClientWindowState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ClientWindowState -> Rep ClientWindowState x
from :: forall x. ClientWindowState -> Rep ClientWindowState x
$cto :: forall x. Rep ClientWindowState x -> ClientWindowState
to :: forall x. Rep ClientWindowState x -> ClientWindowState
Generic)
instance FromJSON ClientWindowState where
parseJSON :: Value -> Parser ClientWindowState
parseJSON :: Value -> Parser ClientWindowState
parseJSON = Value -> Parser ClientWindowState
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
fromJSONCamelCase
instance ToJSON ClientWindowState where
toJSON :: ClientWindowState -> Value
toJSON :: ClientWindowState -> Value
toJSON = ClientWindowState -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase
data CreateUserContext = MkCreateUserContext
{
CreateUserContext -> Maybe Bool
insecureCerts :: Maybe Bool,
CreateUserContext -> Maybe ProxyConfiguration
proxy :: Maybe ProxyConfiguration,
CreateUserContext -> Maybe UserPromptHandler
unhandledPromptBehavior :: Maybe UserPromptHandler
}
deriving (Int -> CreateUserContext -> ShowS
[CreateUserContext] -> ShowS
CreateUserContext -> String
(Int -> CreateUserContext -> ShowS)
-> (CreateUserContext -> String)
-> ([CreateUserContext] -> ShowS)
-> Show CreateUserContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateUserContext -> ShowS
showsPrec :: Int -> CreateUserContext -> ShowS
$cshow :: CreateUserContext -> String
show :: CreateUserContext -> String
$cshowList :: [CreateUserContext] -> ShowS
showList :: [CreateUserContext] -> ShowS
Show, CreateUserContext -> CreateUserContext -> Bool
(CreateUserContext -> CreateUserContext -> Bool)
-> (CreateUserContext -> CreateUserContext -> Bool)
-> Eq CreateUserContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateUserContext -> CreateUserContext -> Bool
== :: CreateUserContext -> CreateUserContext -> Bool
$c/= :: CreateUserContext -> CreateUserContext -> Bool
/= :: CreateUserContext -> CreateUserContext -> Bool
Eq, (forall x. CreateUserContext -> Rep CreateUserContext x)
-> (forall x. Rep CreateUserContext x -> CreateUserContext)
-> Generic CreateUserContext
forall x. Rep CreateUserContext x -> CreateUserContext
forall x. CreateUserContext -> Rep CreateUserContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CreateUserContext -> Rep CreateUserContext x
from :: forall x. CreateUserContext -> Rep CreateUserContext x
$cto :: forall x. Rep CreateUserContext x -> CreateUserContext
to :: forall x. Rep CreateUserContext x -> CreateUserContext
Generic)
instance ToJSON CreateUserContext where
toJSON :: CreateUserContext -> Value
toJSON :: CreateUserContext -> Value
toJSON MkCreateUserContext {Maybe Bool
insecureCerts :: CreateUserContext -> Maybe Bool
insecureCerts :: Maybe Bool
insecureCerts, Maybe ProxyConfiguration
proxy :: CreateUserContext -> Maybe ProxyConfiguration
proxy :: Maybe ProxyConfiguration
proxy, Maybe UserPromptHandler
unhandledPromptBehavior :: CreateUserContext -> Maybe UserPromptHandler
unhandledPromptBehavior :: Maybe UserPromptHandler
unhandledPromptBehavior} =
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
[Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
[ Key -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"acceptInsecureCerts" Maybe Bool
insecureCerts,
Key -> Maybe ProxyConfiguration -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"proxy" Maybe ProxyConfiguration
proxy,
Key -> Maybe UserPromptHandler -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"unhandledPromptBehavior" Maybe UserPromptHandler
unhandledPromptBehavior
]
newtype RemoveUserContext = MkRemoveUserContext
{ RemoveUserContext -> UserContext
userContext :: UserContext
}
deriving (Int -> RemoveUserContext -> ShowS
[RemoveUserContext] -> ShowS
RemoveUserContext -> String
(Int -> RemoveUserContext -> ShowS)
-> (RemoveUserContext -> String)
-> ([RemoveUserContext] -> ShowS)
-> Show RemoveUserContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoveUserContext -> ShowS
showsPrec :: Int -> RemoveUserContext -> ShowS
$cshow :: RemoveUserContext -> String
show :: RemoveUserContext -> String
$cshowList :: [RemoveUserContext] -> ShowS
showList :: [RemoveUserContext] -> ShowS
Show, RemoveUserContext -> RemoveUserContext -> Bool
(RemoveUserContext -> RemoveUserContext -> Bool)
-> (RemoveUserContext -> RemoveUserContext -> Bool)
-> Eq RemoveUserContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoveUserContext -> RemoveUserContext -> Bool
== :: RemoveUserContext -> RemoveUserContext -> Bool
$c/= :: RemoveUserContext -> RemoveUserContext -> Bool
/= :: RemoveUserContext -> RemoveUserContext -> Bool
Eq, (forall x. RemoveUserContext -> Rep RemoveUserContext x)
-> (forall x. Rep RemoveUserContext x -> RemoveUserContext)
-> Generic RemoveUserContext
forall x. Rep RemoveUserContext x -> RemoveUserContext
forall x. RemoveUserContext -> Rep RemoveUserContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RemoveUserContext -> Rep RemoveUserContext x
from :: forall x. RemoveUserContext -> Rep RemoveUserContext x
$cto :: forall x. Rep RemoveUserContext x -> RemoveUserContext
to :: forall x. Rep RemoveUserContext x -> RemoveUserContext
Generic)
instance ToJSON RemoveUserContext
data SetClientWindowState = MkSetClientWindowState
{ SetClientWindowState -> ClientWindow
clientWindow :: ClientWindow,
SetClientWindowState -> WindowState
windowState :: WindowState
}
deriving (Int -> SetClientWindowState -> ShowS
[SetClientWindowState] -> ShowS
SetClientWindowState -> String
(Int -> SetClientWindowState -> ShowS)
-> (SetClientWindowState -> String)
-> ([SetClientWindowState] -> ShowS)
-> Show SetClientWindowState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetClientWindowState -> ShowS
showsPrec :: Int -> SetClientWindowState -> ShowS
$cshow :: SetClientWindowState -> String
show :: SetClientWindowState -> String
$cshowList :: [SetClientWindowState] -> ShowS
showList :: [SetClientWindowState] -> ShowS
Show, SetClientWindowState -> SetClientWindowState -> Bool
(SetClientWindowState -> SetClientWindowState -> Bool)
-> (SetClientWindowState -> SetClientWindowState -> Bool)
-> Eq SetClientWindowState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetClientWindowState -> SetClientWindowState -> Bool
== :: SetClientWindowState -> SetClientWindowState -> Bool
$c/= :: SetClientWindowState -> SetClientWindowState -> Bool
/= :: SetClientWindowState -> SetClientWindowState -> Bool
Eq, (forall x. SetClientWindowState -> Rep SetClientWindowState x)
-> (forall x. Rep SetClientWindowState x -> SetClientWindowState)
-> Generic SetClientWindowState
forall x. Rep SetClientWindowState x -> SetClientWindowState
forall x. SetClientWindowState -> Rep SetClientWindowState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SetClientWindowState -> Rep SetClientWindowState x
from :: forall x. SetClientWindowState -> Rep SetClientWindowState x
$cto :: forall x. Rep SetClientWindowState x -> SetClientWindowState
to :: forall x. Rep SetClientWindowState x -> SetClientWindowState
Generic)
instance ToJSON SetClientWindowState where
toJSON :: SetClientWindowState -> Value
toJSON :: SetClientWindowState -> Value
toJSON (MkSetClientWindowState ClientWindow
cw WindowState
ws) =
case WindowState
ws of
ClientWindowNamedState NamedState
ns ->
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [Pair]
cwProp [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Key
"state" Key -> NamedState -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= NamedState
ns]
ClientWindowRectState RectState
rs ->
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [Pair]
cwProp [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Key
"state" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"normal"]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> RectState -> [Pair]
forall e a. KeyValue e a => RectState -> [a]
recStatePairs RectState
rs
where
cwProp :: [Pair]
cwProp = [Key
"clientWindow" Key -> ClientWindow -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ClientWindow
cw]
data WindowState
= ClientWindowNamedState NamedState
| ClientWindowRectState RectState
deriving (Int -> WindowState -> ShowS
[WindowState] -> ShowS
WindowState -> String
(Int -> WindowState -> ShowS)
-> (WindowState -> String)
-> ([WindowState] -> ShowS)
-> Show WindowState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WindowState -> ShowS
showsPrec :: Int -> WindowState -> ShowS
$cshow :: WindowState -> String
show :: WindowState -> String
$cshowList :: [WindowState] -> ShowS
showList :: [WindowState] -> ShowS
Show, WindowState -> WindowState -> Bool
(WindowState -> WindowState -> Bool)
-> (WindowState -> WindowState -> Bool) -> Eq WindowState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WindowState -> WindowState -> Bool
== :: WindowState -> WindowState -> Bool
$c/= :: WindowState -> WindowState -> Bool
/= :: WindowState -> WindowState -> Bool
Eq, (forall x. WindowState -> Rep WindowState x)
-> (forall x. Rep WindowState x -> WindowState)
-> Generic WindowState
forall x. Rep WindowState x -> WindowState
forall x. WindowState -> Rep WindowState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. WindowState -> Rep WindowState x
from :: forall x. WindowState -> Rep WindowState x
$cto :: forall x. Rep WindowState x -> WindowState
to :: forall x. Rep WindowState x -> WindowState
Generic)
instance FromJSON WindowState
instance ToJSON WindowState where
toJSON :: WindowState -> Value
toJSON :: WindowState -> Value
toJSON = WindowState -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase
data NamedState
= FullscreenState
| MaximizedState
| MinimizedState
deriving (Int -> NamedState -> ShowS
[NamedState] -> ShowS
NamedState -> String
(Int -> NamedState -> ShowS)
-> (NamedState -> String)
-> ([NamedState] -> ShowS)
-> Show NamedState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NamedState -> ShowS
showsPrec :: Int -> NamedState -> ShowS
$cshow :: NamedState -> String
show :: NamedState -> String
$cshowList :: [NamedState] -> ShowS
showList :: [NamedState] -> ShowS
Show, NamedState -> NamedState -> Bool
(NamedState -> NamedState -> Bool)
-> (NamedState -> NamedState -> Bool) -> Eq NamedState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NamedState -> NamedState -> Bool
== :: NamedState -> NamedState -> Bool
$c/= :: NamedState -> NamedState -> Bool
/= :: NamedState -> NamedState -> Bool
Eq, (forall x. NamedState -> Rep NamedState x)
-> (forall x. Rep NamedState x -> NamedState) -> Generic NamedState
forall x. Rep NamedState x -> NamedState
forall x. NamedState -> Rep NamedState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NamedState -> Rep NamedState x
from :: forall x. NamedState -> Rep NamedState x
$cto :: forall x. Rep NamedState x -> NamedState
to :: forall x. Rep NamedState x -> NamedState
Generic)
instance FromJSON NamedState where
parseJSON :: Value -> Parser NamedState
parseJSON :: Value -> Parser NamedState
parseJSON = \case
String Text
"fullscreen" -> NamedState -> Parser NamedState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure NamedState
FullscreenState
String Text
"maximized" -> NamedState -> Parser NamedState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure NamedState
MaximizedState
String Text
"minimized" -> NamedState -> Parser NamedState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure NamedState
MinimizedState
Value
_ -> String -> Parser NamedState
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Expected one of: fullscreen, maximized, minimized"
instance ToJSON NamedState where
toJSON :: NamedState -> Value
toJSON :: NamedState -> Value
toJSON = \case
NamedState
FullscreenState -> Value
"fullscreen"
NamedState
MaximizedState -> Value
"maximized"
NamedState
MinimizedState -> Value
"minimized"
data RectState = MkRectState
{ RectState -> Maybe Int
width :: Maybe Int,
RectState -> Maybe Int
height :: Maybe Int,
RectState -> Maybe Int
x :: Maybe Int,
RectState -> Maybe Int
y :: Maybe Int
}
deriving (Int -> RectState -> ShowS
[RectState] -> ShowS
RectState -> String
(Int -> RectState -> ShowS)
-> (RectState -> String)
-> ([RectState] -> ShowS)
-> Show RectState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RectState -> ShowS
showsPrec :: Int -> RectState -> ShowS
$cshow :: RectState -> String
show :: RectState -> String
$cshowList :: [RectState] -> ShowS
showList :: [RectState] -> ShowS
Show, RectState -> RectState -> Bool
(RectState -> RectState -> Bool)
-> (RectState -> RectState -> Bool) -> Eq RectState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RectState -> RectState -> Bool
== :: RectState -> RectState -> Bool
$c/= :: RectState -> RectState -> Bool
/= :: RectState -> RectState -> Bool
Eq, (forall x. RectState -> Rep RectState x)
-> (forall x. Rep RectState x -> RectState) -> Generic RectState
forall x. Rep RectState x -> RectState
forall x. RectState -> Rep RectState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RectState -> Rep RectState x
from :: forall x. RectState -> Rep RectState x
$cto :: forall x. Rep RectState x -> RectState
to :: forall x. Rep RectState x -> RectState
Generic)
instance FromJSON RectState
instance ToJSON RectState where
toJSON :: RectState -> Value
toJSON :: RectState -> Value
toJSON =
Object -> Value
Object (Object -> Value) -> (RectState -> Object) -> RectState -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pair] -> Object
forall v. [(Key, v)] -> KeyMap v
fromList ([Pair] -> Object) -> (RectState -> [Pair]) -> RectState -> Object
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RectState -> [Pair]
forall e a. KeyValue e a => RectState -> [a]
recStatePairs
recStatePairs :: KeyValue e a => RectState -> [a]
recStatePairs :: forall e a. KeyValue e a => RectState -> [a]
recStatePairs MkRectState {Maybe Int
width :: RectState -> Maybe Int
width :: Maybe Int
width, Maybe Int
height :: RectState -> Maybe Int
height :: Maybe Int
height, Maybe Int
x :: RectState -> Maybe Int
x :: Maybe Int
x, Maybe Int
y :: RectState -> Maybe Int
y :: Maybe Int
y} =
[Maybe a] -> [a]
forall a. [Maybe a] -> [a]
catMaybes
[ Key -> Maybe Int -> Maybe a
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"width" Maybe Int
width,
Key -> Maybe Int -> Maybe a
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"height" Maybe Int
height,
Key -> Maybe Int -> Maybe a
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"x" Maybe Int
x,
Key -> Maybe Int -> Maybe a
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"y" Maybe Int
y
]
data SetDownloadBehavior = MkSetDownloadBehavior
{ SetDownloadBehavior -> Maybe DownloadBehaviour
downloadBehavior :: Maybe DownloadBehaviour,
SetDownloadBehavior -> Maybe [UserContext]
userContexts :: Maybe [UserContext]
}
deriving (Int -> SetDownloadBehavior -> ShowS
[SetDownloadBehavior] -> ShowS
SetDownloadBehavior -> String
(Int -> SetDownloadBehavior -> ShowS)
-> (SetDownloadBehavior -> String)
-> ([SetDownloadBehavior] -> ShowS)
-> Show SetDownloadBehavior
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetDownloadBehavior -> ShowS
showsPrec :: Int -> SetDownloadBehavior -> ShowS
$cshow :: SetDownloadBehavior -> String
show :: SetDownloadBehavior -> String
$cshowList :: [SetDownloadBehavior] -> ShowS
showList :: [SetDownloadBehavior] -> ShowS
Show, SetDownloadBehavior -> SetDownloadBehavior -> Bool
(SetDownloadBehavior -> SetDownloadBehavior -> Bool)
-> (SetDownloadBehavior -> SetDownloadBehavior -> Bool)
-> Eq SetDownloadBehavior
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetDownloadBehavior -> SetDownloadBehavior -> Bool
== :: SetDownloadBehavior -> SetDownloadBehavior -> Bool
$c/= :: SetDownloadBehavior -> SetDownloadBehavior -> Bool
/= :: SetDownloadBehavior -> SetDownloadBehavior -> Bool
Eq, (forall x. SetDownloadBehavior -> Rep SetDownloadBehavior x)
-> (forall x. Rep SetDownloadBehavior x -> SetDownloadBehavior)
-> Generic SetDownloadBehavior
forall x. Rep SetDownloadBehavior x -> SetDownloadBehavior
forall x. SetDownloadBehavior -> Rep SetDownloadBehavior x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SetDownloadBehavior -> Rep SetDownloadBehavior x
from :: forall x. SetDownloadBehavior -> Rep SetDownloadBehavior x
$cto :: forall x. Rep SetDownloadBehavior x -> SetDownloadBehavior
to :: forall x. Rep SetDownloadBehavior x -> SetDownloadBehavior
Generic)
instance ToJSON SetDownloadBehavior where
toJSON :: SetDownloadBehavior -> Value
toJSON :: SetDownloadBehavior -> Value
toJSON MkSetDownloadBehavior {Maybe DownloadBehaviour
downloadBehavior :: SetDownloadBehavior -> Maybe DownloadBehaviour
downloadBehavior :: Maybe DownloadBehaviour
downloadBehavior, Maybe [UserContext]
userContexts :: SetDownloadBehavior -> Maybe [UserContext]
userContexts :: Maybe [UserContext]
userContexts} =
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
[Key
"downloadBehavior" Key -> Maybe DownloadBehaviour -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe DownloadBehaviour
downloadBehavior]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
[ Key -> Maybe [UserContext] -> Maybe Pair
forall (f :: * -> *) e b a.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"userContexts" Maybe [UserContext]
userContexts
]
data DownloadBehaviour
= AllowedDownload
{ DownloadBehaviour -> Text
destinationFolder :: Text
}
| DeniedDownload
deriving (Int -> DownloadBehaviour -> ShowS
[DownloadBehaviour] -> ShowS
DownloadBehaviour -> String
(Int -> DownloadBehaviour -> ShowS)
-> (DownloadBehaviour -> String)
-> ([DownloadBehaviour] -> ShowS)
-> Show DownloadBehaviour
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DownloadBehaviour -> ShowS
showsPrec :: Int -> DownloadBehaviour -> ShowS
$cshow :: DownloadBehaviour -> String
show :: DownloadBehaviour -> String
$cshowList :: [DownloadBehaviour] -> ShowS
showList :: [DownloadBehaviour] -> ShowS
Show, DownloadBehaviour -> DownloadBehaviour -> Bool
(DownloadBehaviour -> DownloadBehaviour -> Bool)
-> (DownloadBehaviour -> DownloadBehaviour -> Bool)
-> Eq DownloadBehaviour
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DownloadBehaviour -> DownloadBehaviour -> Bool
== :: DownloadBehaviour -> DownloadBehaviour -> Bool
$c/= :: DownloadBehaviour -> DownloadBehaviour -> Bool
/= :: DownloadBehaviour -> DownloadBehaviour -> Bool
Eq, (forall x. DownloadBehaviour -> Rep DownloadBehaviour x)
-> (forall x. Rep DownloadBehaviour x -> DownloadBehaviour)
-> Generic DownloadBehaviour
forall x. Rep DownloadBehaviour x -> DownloadBehaviour
forall x. DownloadBehaviour -> Rep DownloadBehaviour x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DownloadBehaviour -> Rep DownloadBehaviour x
from :: forall x. DownloadBehaviour -> Rep DownloadBehaviour x
$cto :: forall x. Rep DownloadBehaviour x -> DownloadBehaviour
to :: forall x. Rep DownloadBehaviour x -> DownloadBehaviour
Generic)
instance FromJSON DownloadBehaviour
instance ToJSON DownloadBehaviour where
toJSON :: DownloadBehaviour -> Value
toJSON :: DownloadBehaviour -> Value
toJSON (AllowedDownload Text
destinationFolder) =
[Pair] -> Value
object
[ Key
"type" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
"allowed" :: Text),
Key
"destinationFolder" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
destinationFolder
]
toJSON DownloadBehaviour
DeniedDownload =
[Pair] -> Value
object
[ Key
"type" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
"denied" :: Text)
]
newtype GetClientWindowsResult = MkGetClientWindowsResult
{ GetClientWindowsResult -> [ClientWindowInfo]
clientWindows :: [ClientWindowInfo]
}
deriving (Int -> GetClientWindowsResult -> ShowS
[GetClientWindowsResult] -> ShowS
GetClientWindowsResult -> String
(Int -> GetClientWindowsResult -> ShowS)
-> (GetClientWindowsResult -> String)
-> ([GetClientWindowsResult] -> ShowS)
-> Show GetClientWindowsResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetClientWindowsResult -> ShowS
showsPrec :: Int -> GetClientWindowsResult -> ShowS
$cshow :: GetClientWindowsResult -> String
show :: GetClientWindowsResult -> String
$cshowList :: [GetClientWindowsResult] -> ShowS
showList :: [GetClientWindowsResult] -> ShowS
Show, GetClientWindowsResult -> GetClientWindowsResult -> Bool
(GetClientWindowsResult -> GetClientWindowsResult -> Bool)
-> (GetClientWindowsResult -> GetClientWindowsResult -> Bool)
-> Eq GetClientWindowsResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetClientWindowsResult -> GetClientWindowsResult -> Bool
== :: GetClientWindowsResult -> GetClientWindowsResult -> Bool
$c/= :: GetClientWindowsResult -> GetClientWindowsResult -> Bool
/= :: GetClientWindowsResult -> GetClientWindowsResult -> Bool
Eq, (forall x. GetClientWindowsResult -> Rep GetClientWindowsResult x)
-> (forall x.
Rep GetClientWindowsResult x -> GetClientWindowsResult)
-> Generic GetClientWindowsResult
forall x. Rep GetClientWindowsResult x -> GetClientWindowsResult
forall x. GetClientWindowsResult -> Rep GetClientWindowsResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GetClientWindowsResult -> Rep GetClientWindowsResult x
from :: forall x. GetClientWindowsResult -> Rep GetClientWindowsResult x
$cto :: forall x. Rep GetClientWindowsResult x -> GetClientWindowsResult
to :: forall x. Rep GetClientWindowsResult x -> GetClientWindowsResult
Generic)
instance FromJSON GetClientWindowsResult
newtype GetUserContextsResult = MkGetUserContextsResult
{ GetUserContextsResult -> [UserContext]
userContexts :: [UserContext]
}
deriving (Int -> GetUserContextsResult -> ShowS
[GetUserContextsResult] -> ShowS
GetUserContextsResult -> String
(Int -> GetUserContextsResult -> ShowS)
-> (GetUserContextsResult -> String)
-> ([GetUserContextsResult] -> ShowS)
-> Show GetUserContextsResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetUserContextsResult -> ShowS
showsPrec :: Int -> GetUserContextsResult -> ShowS
$cshow :: GetUserContextsResult -> String
show :: GetUserContextsResult -> String
$cshowList :: [GetUserContextsResult] -> ShowS
showList :: [GetUserContextsResult] -> ShowS
Show, GetUserContextsResult -> GetUserContextsResult -> Bool
(GetUserContextsResult -> GetUserContextsResult -> Bool)
-> (GetUserContextsResult -> GetUserContextsResult -> Bool)
-> Eq GetUserContextsResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetUserContextsResult -> GetUserContextsResult -> Bool
== :: GetUserContextsResult -> GetUserContextsResult -> Bool
$c/= :: GetUserContextsResult -> GetUserContextsResult -> Bool
/= :: GetUserContextsResult -> GetUserContextsResult -> Bool
Eq, (forall x. GetUserContextsResult -> Rep GetUserContextsResult x)
-> (forall x. Rep GetUserContextsResult x -> GetUserContextsResult)
-> Generic GetUserContextsResult
forall x. Rep GetUserContextsResult x -> GetUserContextsResult
forall x. GetUserContextsResult -> Rep GetUserContextsResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GetUserContextsResult -> Rep GetUserContextsResult x
from :: forall x. GetUserContextsResult -> Rep GetUserContextsResult x
$cto :: forall x. Rep GetUserContextsResult x -> GetUserContextsResult
to :: forall x. Rep GetUserContextsResult x -> GetUserContextsResult
Generic)
instance FromJSON GetUserContextsResult