{-# 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.Grafana.Types.UpdateInstruction where
import qualified Amazonka.Core as Core
import Amazonka.Grafana.Types.Role
import Amazonka.Grafana.Types.UpdateAction
import Amazonka.Grafana.Types.User
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data UpdateInstruction = UpdateInstruction'
{
UpdateInstruction -> UpdateAction
action :: UpdateAction,
UpdateInstruction -> Role
role' :: Role,
UpdateInstruction -> [User]
users :: [User]
}
deriving (UpdateInstruction -> UpdateInstruction -> Bool
(UpdateInstruction -> UpdateInstruction -> Bool)
-> (UpdateInstruction -> UpdateInstruction -> Bool)
-> Eq UpdateInstruction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateInstruction -> UpdateInstruction -> Bool
$c/= :: UpdateInstruction -> UpdateInstruction -> Bool
== :: UpdateInstruction -> UpdateInstruction -> Bool
$c== :: UpdateInstruction -> UpdateInstruction -> Bool
Prelude.Eq, ReadPrec [UpdateInstruction]
ReadPrec UpdateInstruction
Int -> ReadS UpdateInstruction
ReadS [UpdateInstruction]
(Int -> ReadS UpdateInstruction)
-> ReadS [UpdateInstruction]
-> ReadPrec UpdateInstruction
-> ReadPrec [UpdateInstruction]
-> Read UpdateInstruction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateInstruction]
$creadListPrec :: ReadPrec [UpdateInstruction]
readPrec :: ReadPrec UpdateInstruction
$creadPrec :: ReadPrec UpdateInstruction
readList :: ReadS [UpdateInstruction]
$creadList :: ReadS [UpdateInstruction]
readsPrec :: Int -> ReadS UpdateInstruction
$creadsPrec :: Int -> ReadS UpdateInstruction
Prelude.Read, Int -> UpdateInstruction -> ShowS
[UpdateInstruction] -> ShowS
UpdateInstruction -> String
(Int -> UpdateInstruction -> ShowS)
-> (UpdateInstruction -> String)
-> ([UpdateInstruction] -> ShowS)
-> Show UpdateInstruction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateInstruction] -> ShowS
$cshowList :: [UpdateInstruction] -> ShowS
show :: UpdateInstruction -> String
$cshow :: UpdateInstruction -> String
showsPrec :: Int -> UpdateInstruction -> ShowS
$cshowsPrec :: Int -> UpdateInstruction -> ShowS
Prelude.Show, (forall x. UpdateInstruction -> Rep UpdateInstruction x)
-> (forall x. Rep UpdateInstruction x -> UpdateInstruction)
-> Generic UpdateInstruction
forall x. Rep UpdateInstruction x -> UpdateInstruction
forall x. UpdateInstruction -> Rep UpdateInstruction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateInstruction x -> UpdateInstruction
$cfrom :: forall x. UpdateInstruction -> Rep UpdateInstruction x
Prelude.Generic)
newUpdateInstruction ::
UpdateAction ->
Role ->
UpdateInstruction
newUpdateInstruction :: UpdateAction -> Role -> UpdateInstruction
newUpdateInstruction UpdateAction
pAction_ Role
pRole_ =
UpdateInstruction' :: UpdateAction -> Role -> [User] -> UpdateInstruction
UpdateInstruction'
{ $sel:action:UpdateInstruction' :: UpdateAction
action = UpdateAction
pAction_,
$sel:role':UpdateInstruction' :: Role
role' = Role
pRole_,
$sel:users:UpdateInstruction' :: [User]
users = [User]
forall a. Monoid a => a
Prelude.mempty
}
updateInstruction_action :: Lens.Lens' UpdateInstruction UpdateAction
updateInstruction_action :: (UpdateAction -> f UpdateAction)
-> UpdateInstruction -> f UpdateInstruction
updateInstruction_action = (UpdateInstruction -> UpdateAction)
-> (UpdateInstruction -> UpdateAction -> UpdateInstruction)
-> Lens
UpdateInstruction UpdateInstruction UpdateAction UpdateAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstruction' {UpdateAction
action :: UpdateAction
$sel:action:UpdateInstruction' :: UpdateInstruction -> UpdateAction
action} -> UpdateAction
action) (\s :: UpdateInstruction
s@UpdateInstruction' {} UpdateAction
a -> UpdateInstruction
s {$sel:action:UpdateInstruction' :: UpdateAction
action = UpdateAction
a} :: UpdateInstruction)
updateInstruction_role :: Lens.Lens' UpdateInstruction Role
updateInstruction_role :: (Role -> f Role) -> UpdateInstruction -> f UpdateInstruction
updateInstruction_role = (UpdateInstruction -> Role)
-> (UpdateInstruction -> Role -> UpdateInstruction)
-> Lens UpdateInstruction UpdateInstruction Role Role
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstruction' {Role
role' :: Role
$sel:role':UpdateInstruction' :: UpdateInstruction -> Role
role'} -> Role
role') (\s :: UpdateInstruction
s@UpdateInstruction' {} Role
a -> UpdateInstruction
s {$sel:role':UpdateInstruction' :: Role
role' = Role
a} :: UpdateInstruction)
updateInstruction_users :: Lens.Lens' UpdateInstruction [User]
updateInstruction_users :: ([User] -> f [User]) -> UpdateInstruction -> f UpdateInstruction
updateInstruction_users = (UpdateInstruction -> [User])
-> (UpdateInstruction -> [User] -> UpdateInstruction)
-> Lens UpdateInstruction UpdateInstruction [User] [User]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstruction' {[User]
users :: [User]
$sel:users:UpdateInstruction' :: UpdateInstruction -> [User]
users} -> [User]
users) (\s :: UpdateInstruction
s@UpdateInstruction' {} [User]
a -> UpdateInstruction
s {$sel:users:UpdateInstruction' :: [User]
users = [User]
a} :: UpdateInstruction) (([User] -> f [User]) -> UpdateInstruction -> f UpdateInstruction)
-> (([User] -> f [User]) -> [User] -> f [User])
-> ([User] -> f [User])
-> UpdateInstruction
-> f UpdateInstruction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([User] -> f [User]) -> [User] -> f [User]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON UpdateInstruction where
parseJSON :: Value -> Parser UpdateInstruction
parseJSON =
String
-> (Object -> Parser UpdateInstruction)
-> Value
-> Parser UpdateInstruction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"UpdateInstruction"
( \Object
x ->
UpdateAction -> Role -> [User] -> UpdateInstruction
UpdateInstruction'
(UpdateAction -> Role -> [User] -> UpdateInstruction)
-> Parser UpdateAction
-> Parser (Role -> [User] -> UpdateInstruction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser UpdateAction
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"action")
Parser (Role -> [User] -> UpdateInstruction)
-> Parser Role -> Parser ([User] -> UpdateInstruction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Role
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"role")
Parser ([User] -> UpdateInstruction)
-> Parser [User] -> Parser UpdateInstruction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [User])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"users" Parser (Maybe [User]) -> [User] -> Parser [User]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [User]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable UpdateInstruction
instance Prelude.NFData UpdateInstruction
instance Core.ToJSON UpdateInstruction where
toJSON :: UpdateInstruction -> Value
toJSON UpdateInstruction' {[User]
Role
UpdateAction
users :: [User]
role' :: Role
action :: UpdateAction
$sel:users:UpdateInstruction' :: UpdateInstruction -> [User]
$sel:role':UpdateInstruction' :: UpdateInstruction -> Role
$sel:action:UpdateInstruction' :: UpdateInstruction -> UpdateAction
..} =
[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 -> UpdateAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UpdateAction
action),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"role" Text -> Role -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Role
role'),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"users" Text -> [User] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [User]
users)
]
)