{-# 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 #-}
module Amazonka.AppStream.Types.UserSetting where
import Amazonka.AppStream.Types.Action
import Amazonka.AppStream.Types.Permission
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data UserSetting = UserSetting'
{
UserSetting -> Action
action :: Action,
UserSetting -> Permission
permission :: Permission
}
deriving (UserSetting -> UserSetting -> Bool
(UserSetting -> UserSetting -> Bool)
-> (UserSetting -> UserSetting -> Bool) -> Eq UserSetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserSetting -> UserSetting -> Bool
$c/= :: UserSetting -> UserSetting -> Bool
== :: UserSetting -> UserSetting -> Bool
$c== :: UserSetting -> UserSetting -> Bool
Prelude.Eq, ReadPrec [UserSetting]
ReadPrec UserSetting
Int -> ReadS UserSetting
ReadS [UserSetting]
(Int -> ReadS UserSetting)
-> ReadS [UserSetting]
-> ReadPrec UserSetting
-> ReadPrec [UserSetting]
-> Read UserSetting
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserSetting]
$creadListPrec :: ReadPrec [UserSetting]
readPrec :: ReadPrec UserSetting
$creadPrec :: ReadPrec UserSetting
readList :: ReadS [UserSetting]
$creadList :: ReadS [UserSetting]
readsPrec :: Int -> ReadS UserSetting
$creadsPrec :: Int -> ReadS UserSetting
Prelude.Read, Int -> UserSetting -> ShowS
[UserSetting] -> ShowS
UserSetting -> String
(Int -> UserSetting -> ShowS)
-> (UserSetting -> String)
-> ([UserSetting] -> ShowS)
-> Show UserSetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserSetting] -> ShowS
$cshowList :: [UserSetting] -> ShowS
show :: UserSetting -> String
$cshow :: UserSetting -> String
showsPrec :: Int -> UserSetting -> ShowS
$cshowsPrec :: Int -> UserSetting -> ShowS
Prelude.Show, (forall x. UserSetting -> Rep UserSetting x)
-> (forall x. Rep UserSetting x -> UserSetting)
-> Generic UserSetting
forall x. Rep UserSetting x -> UserSetting
forall x. UserSetting -> Rep UserSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserSetting x -> UserSetting
$cfrom :: forall x. UserSetting -> Rep UserSetting x
Prelude.Generic)
newUserSetting ::
Action ->
Permission ->
UserSetting
newUserSetting :: Action -> Permission -> UserSetting
newUserSetting Action
pAction_ Permission
pPermission_ =
UserSetting' :: Action -> Permission -> UserSetting
UserSetting'
{ $sel:action:UserSetting' :: Action
action = Action
pAction_,
$sel:permission:UserSetting' :: Permission
permission = Permission
pPermission_
}
userSetting_action :: Lens.Lens' UserSetting Action
userSetting_action :: (Action -> f Action) -> UserSetting -> f UserSetting
userSetting_action = (UserSetting -> Action)
-> (UserSetting -> Action -> UserSetting)
-> Lens UserSetting UserSetting Action Action
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserSetting' {Action
action :: Action
$sel:action:UserSetting' :: UserSetting -> Action
action} -> Action
action) (\s :: UserSetting
s@UserSetting' {} Action
a -> UserSetting
s {$sel:action:UserSetting' :: Action
action = Action
a} :: UserSetting)
userSetting_permission :: Lens.Lens' UserSetting Permission
userSetting_permission :: (Permission -> f Permission) -> UserSetting -> f UserSetting
userSetting_permission = (UserSetting -> Permission)
-> (UserSetting -> Permission -> UserSetting)
-> Lens UserSetting UserSetting Permission Permission
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserSetting' {Permission
permission :: Permission
$sel:permission:UserSetting' :: UserSetting -> Permission
permission} -> Permission
permission) (\s :: UserSetting
s@UserSetting' {} Permission
a -> UserSetting
s {$sel:permission:UserSetting' :: Permission
permission = Permission
a} :: UserSetting)
instance Core.FromJSON UserSetting where
parseJSON :: Value -> Parser UserSetting
parseJSON =
String
-> (Object -> Parser UserSetting) -> Value -> Parser UserSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"UserSetting"
( \Object
x ->
Action -> Permission -> UserSetting
UserSetting'
(Action -> Permission -> UserSetting)
-> Parser Action -> Parser (Permission -> UserSetting)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Action
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Action")
Parser (Permission -> UserSetting)
-> Parser Permission -> Parser UserSetting
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Permission
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Permission")
)
instance Prelude.Hashable UserSetting
instance Prelude.NFData UserSetting
instance Core.ToJSON UserSetting where
toJSON :: UserSetting -> Value
toJSON UserSetting' {Action
Permission
permission :: Permission
action :: Action
$sel:permission:UserSetting' :: UserSetting -> Permission
$sel:action:UserSetting' :: UserSetting -> Action
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Action" Text -> Action -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Action
action),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Permission" Text -> Permission -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Permission
permission)
]
)