{-# 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.FMS.Types.App where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data App = App'
{
App -> Text
appName :: Prelude.Text,
App -> Text
protocol :: Prelude.Text,
App -> Natural
port :: Prelude.Natural
}
deriving (App -> App -> Bool
(App -> App -> Bool) -> (App -> App -> Bool) -> Eq App
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: App -> App -> Bool
$c/= :: App -> App -> Bool
== :: App -> App -> Bool
$c== :: App -> App -> Bool
Prelude.Eq, ReadPrec [App]
ReadPrec App
Int -> ReadS App
ReadS [App]
(Int -> ReadS App)
-> ReadS [App] -> ReadPrec App -> ReadPrec [App] -> Read App
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [App]
$creadListPrec :: ReadPrec [App]
readPrec :: ReadPrec App
$creadPrec :: ReadPrec App
readList :: ReadS [App]
$creadList :: ReadS [App]
readsPrec :: Int -> ReadS App
$creadsPrec :: Int -> ReadS App
Prelude.Read, Int -> App -> ShowS
[App] -> ShowS
App -> String
(Int -> App -> ShowS)
-> (App -> String) -> ([App] -> ShowS) -> Show App
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [App] -> ShowS
$cshowList :: [App] -> ShowS
show :: App -> String
$cshow :: App -> String
showsPrec :: Int -> App -> ShowS
$cshowsPrec :: Int -> App -> ShowS
Prelude.Show, (forall x. App -> Rep App x)
-> (forall x. Rep App x -> App) -> Generic App
forall x. Rep App x -> App
forall x. App -> Rep App x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep App x -> App
$cfrom :: forall x. App -> Rep App x
Prelude.Generic)
newApp ::
Prelude.Text ->
Prelude.Text ->
Prelude.Natural ->
App
newApp :: Text -> Text -> Natural -> App
newApp Text
pAppName_ Text
pProtocol_ Natural
pPort_ =
App' :: Text -> Text -> Natural -> App
App'
{ $sel:appName:App' :: Text
appName = Text
pAppName_,
$sel:protocol:App' :: Text
protocol = Text
pProtocol_,
$sel:port:App' :: Natural
port = Natural
pPort_
}
app_appName :: Lens.Lens' App Prelude.Text
app_appName :: (Text -> f Text) -> App -> f App
app_appName = (App -> Text) -> (App -> Text -> App) -> Lens App App Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\App' {Text
appName :: Text
$sel:appName:App' :: App -> Text
appName} -> Text
appName) (\s :: App
s@App' {} Text
a -> App
s {$sel:appName:App' :: Text
appName = Text
a} :: App)
app_protocol :: Lens.Lens' App Prelude.Text
app_protocol :: (Text -> f Text) -> App -> f App
app_protocol = (App -> Text) -> (App -> Text -> App) -> Lens App App Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\App' {Text
protocol :: Text
$sel:protocol:App' :: App -> Text
protocol} -> Text
protocol) (\s :: App
s@App' {} Text
a -> App
s {$sel:protocol:App' :: Text
protocol = Text
a} :: App)
app_port :: Lens.Lens' App Prelude.Natural
app_port :: (Natural -> f Natural) -> App -> f App
app_port = (App -> Natural)
-> (App -> Natural -> App) -> Lens App App Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\App' {Natural
port :: Natural
$sel:port:App' :: App -> Natural
port} -> Natural
port) (\s :: App
s@App' {} Natural
a -> App
s {$sel:port:App' :: Natural
port = Natural
a} :: App)
instance Core.FromJSON App where
parseJSON :: Value -> Parser App
parseJSON =
String -> (Object -> Parser App) -> Value -> Parser App
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"App"
( \Object
x ->
Text -> Text -> Natural -> App
App'
(Text -> Text -> Natural -> App)
-> Parser Text -> Parser (Text -> Natural -> App)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AppName")
Parser (Text -> Natural -> App)
-> Parser Text -> Parser (Natural -> App)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Protocol")
Parser (Natural -> App) -> Parser Natural -> Parser App
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Port")
)
instance Prelude.Hashable App
instance Prelude.NFData App
instance Core.ToJSON App where
toJSON :: App -> Value
toJSON App' {Natural
Text
port :: Natural
protocol :: Text
appName :: Text
$sel:port:App' :: App -> Natural
$sel:protocol:App' :: App -> Text
$sel:appName:App' :: App -> Text
..} =
[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
"AppName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
appName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Protocol" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
protocol),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Port" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
port)
]
)