{-# 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.Chime.Types.OriginationRoute where
import Amazonka.Chime.Types.OriginationRouteProtocol
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data OriginationRoute = OriginationRoute'
{
OriginationRoute -> Maybe Natural
priority :: Prelude.Maybe Prelude.Natural,
OriginationRoute -> Maybe Natural
weight :: Prelude.Maybe Prelude.Natural,
OriginationRoute -> Maybe OriginationRouteProtocol
protocol :: Prelude.Maybe OriginationRouteProtocol,
OriginationRoute -> Maybe Text
host :: Prelude.Maybe Prelude.Text,
OriginationRoute -> Maybe Natural
port :: Prelude.Maybe Prelude.Natural
}
deriving (OriginationRoute -> OriginationRoute -> Bool
(OriginationRoute -> OriginationRoute -> Bool)
-> (OriginationRoute -> OriginationRoute -> Bool)
-> Eq OriginationRoute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OriginationRoute -> OriginationRoute -> Bool
$c/= :: OriginationRoute -> OriginationRoute -> Bool
== :: OriginationRoute -> OriginationRoute -> Bool
$c== :: OriginationRoute -> OriginationRoute -> Bool
Prelude.Eq, ReadPrec [OriginationRoute]
ReadPrec OriginationRoute
Int -> ReadS OriginationRoute
ReadS [OriginationRoute]
(Int -> ReadS OriginationRoute)
-> ReadS [OriginationRoute]
-> ReadPrec OriginationRoute
-> ReadPrec [OriginationRoute]
-> Read OriginationRoute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OriginationRoute]
$creadListPrec :: ReadPrec [OriginationRoute]
readPrec :: ReadPrec OriginationRoute
$creadPrec :: ReadPrec OriginationRoute
readList :: ReadS [OriginationRoute]
$creadList :: ReadS [OriginationRoute]
readsPrec :: Int -> ReadS OriginationRoute
$creadsPrec :: Int -> ReadS OriginationRoute
Prelude.Read, Int -> OriginationRoute -> ShowS
[OriginationRoute] -> ShowS
OriginationRoute -> String
(Int -> OriginationRoute -> ShowS)
-> (OriginationRoute -> String)
-> ([OriginationRoute] -> ShowS)
-> Show OriginationRoute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OriginationRoute] -> ShowS
$cshowList :: [OriginationRoute] -> ShowS
show :: OriginationRoute -> String
$cshow :: OriginationRoute -> String
showsPrec :: Int -> OriginationRoute -> ShowS
$cshowsPrec :: Int -> OriginationRoute -> ShowS
Prelude.Show, (forall x. OriginationRoute -> Rep OriginationRoute x)
-> (forall x. Rep OriginationRoute x -> OriginationRoute)
-> Generic OriginationRoute
forall x. Rep OriginationRoute x -> OriginationRoute
forall x. OriginationRoute -> Rep OriginationRoute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OriginationRoute x -> OriginationRoute
$cfrom :: forall x. OriginationRoute -> Rep OriginationRoute x
Prelude.Generic)
newOriginationRoute ::
OriginationRoute
newOriginationRoute :: OriginationRoute
newOriginationRoute =
OriginationRoute' :: Maybe Natural
-> Maybe Natural
-> Maybe OriginationRouteProtocol
-> Maybe Text
-> Maybe Natural
-> OriginationRoute
OriginationRoute'
{ $sel:priority:OriginationRoute' :: Maybe Natural
priority = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:weight:OriginationRoute' :: Maybe Natural
weight = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:protocol:OriginationRoute' :: Maybe OriginationRouteProtocol
protocol = Maybe OriginationRouteProtocol
forall a. Maybe a
Prelude.Nothing,
$sel:host:OriginationRoute' :: Maybe Text
host = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:port:OriginationRoute' :: Maybe Natural
port = Maybe Natural
forall a. Maybe a
Prelude.Nothing
}
originationRoute_priority :: Lens.Lens' OriginationRoute (Prelude.Maybe Prelude.Natural)
originationRoute_priority :: (Maybe Natural -> f (Maybe Natural))
-> OriginationRoute -> f OriginationRoute
originationRoute_priority = (OriginationRoute -> Maybe Natural)
-> (OriginationRoute -> Maybe Natural -> OriginationRoute)
-> Lens
OriginationRoute OriginationRoute (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginationRoute' {Maybe Natural
priority :: Maybe Natural
$sel:priority:OriginationRoute' :: OriginationRoute -> Maybe Natural
priority} -> Maybe Natural
priority) (\s :: OriginationRoute
s@OriginationRoute' {} Maybe Natural
a -> OriginationRoute
s {$sel:priority:OriginationRoute' :: Maybe Natural
priority = Maybe Natural
a} :: OriginationRoute)
originationRoute_weight :: Lens.Lens' OriginationRoute (Prelude.Maybe Prelude.Natural)
originationRoute_weight :: (Maybe Natural -> f (Maybe Natural))
-> OriginationRoute -> f OriginationRoute
originationRoute_weight = (OriginationRoute -> Maybe Natural)
-> (OriginationRoute -> Maybe Natural -> OriginationRoute)
-> Lens
OriginationRoute OriginationRoute (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginationRoute' {Maybe Natural
weight :: Maybe Natural
$sel:weight:OriginationRoute' :: OriginationRoute -> Maybe Natural
weight} -> Maybe Natural
weight) (\s :: OriginationRoute
s@OriginationRoute' {} Maybe Natural
a -> OriginationRoute
s {$sel:weight:OriginationRoute' :: Maybe Natural
weight = Maybe Natural
a} :: OriginationRoute)
originationRoute_protocol :: Lens.Lens' OriginationRoute (Prelude.Maybe OriginationRouteProtocol)
originationRoute_protocol :: (Maybe OriginationRouteProtocol
-> f (Maybe OriginationRouteProtocol))
-> OriginationRoute -> f OriginationRoute
originationRoute_protocol = (OriginationRoute -> Maybe OriginationRouteProtocol)
-> (OriginationRoute
-> Maybe OriginationRouteProtocol -> OriginationRoute)
-> Lens
OriginationRoute
OriginationRoute
(Maybe OriginationRouteProtocol)
(Maybe OriginationRouteProtocol)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginationRoute' {Maybe OriginationRouteProtocol
protocol :: Maybe OriginationRouteProtocol
$sel:protocol:OriginationRoute' :: OriginationRoute -> Maybe OriginationRouteProtocol
protocol} -> Maybe OriginationRouteProtocol
protocol) (\s :: OriginationRoute
s@OriginationRoute' {} Maybe OriginationRouteProtocol
a -> OriginationRoute
s {$sel:protocol:OriginationRoute' :: Maybe OriginationRouteProtocol
protocol = Maybe OriginationRouteProtocol
a} :: OriginationRoute)
originationRoute_host :: Lens.Lens' OriginationRoute (Prelude.Maybe Prelude.Text)
originationRoute_host :: (Maybe Text -> f (Maybe Text))
-> OriginationRoute -> f OriginationRoute
originationRoute_host = (OriginationRoute -> Maybe Text)
-> (OriginationRoute -> Maybe Text -> OriginationRoute)
-> Lens OriginationRoute OriginationRoute (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginationRoute' {Maybe Text
host :: Maybe Text
$sel:host:OriginationRoute' :: OriginationRoute -> Maybe Text
host} -> Maybe Text
host) (\s :: OriginationRoute
s@OriginationRoute' {} Maybe Text
a -> OriginationRoute
s {$sel:host:OriginationRoute' :: Maybe Text
host = Maybe Text
a} :: OriginationRoute)
originationRoute_port :: Lens.Lens' OriginationRoute (Prelude.Maybe Prelude.Natural)
originationRoute_port :: (Maybe Natural -> f (Maybe Natural))
-> OriginationRoute -> f OriginationRoute
originationRoute_port = (OriginationRoute -> Maybe Natural)
-> (OriginationRoute -> Maybe Natural -> OriginationRoute)
-> Lens
OriginationRoute OriginationRoute (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginationRoute' {Maybe Natural
port :: Maybe Natural
$sel:port:OriginationRoute' :: OriginationRoute -> Maybe Natural
port} -> Maybe Natural
port) (\s :: OriginationRoute
s@OriginationRoute' {} Maybe Natural
a -> OriginationRoute
s {$sel:port:OriginationRoute' :: Maybe Natural
port = Maybe Natural
a} :: OriginationRoute)
instance Core.FromJSON OriginationRoute where
parseJSON :: Value -> Parser OriginationRoute
parseJSON =
String
-> (Object -> Parser OriginationRoute)
-> Value
-> Parser OriginationRoute
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"OriginationRoute"
( \Object
x ->
Maybe Natural
-> Maybe Natural
-> Maybe OriginationRouteProtocol
-> Maybe Text
-> Maybe Natural
-> OriginationRoute
OriginationRoute'
(Maybe Natural
-> Maybe Natural
-> Maybe OriginationRouteProtocol
-> Maybe Text
-> Maybe Natural
-> OriginationRoute)
-> Parser (Maybe Natural)
-> Parser
(Maybe Natural
-> Maybe OriginationRouteProtocol
-> Maybe Text
-> Maybe Natural
-> OriginationRoute)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Priority")
Parser
(Maybe Natural
-> Maybe OriginationRouteProtocol
-> Maybe Text
-> Maybe Natural
-> OriginationRoute)
-> Parser (Maybe Natural)
-> Parser
(Maybe OriginationRouteProtocol
-> Maybe Text -> Maybe Natural -> OriginationRoute)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Weight")
Parser
(Maybe OriginationRouteProtocol
-> Maybe Text -> Maybe Natural -> OriginationRoute)
-> Parser (Maybe OriginationRouteProtocol)
-> Parser (Maybe Text -> Maybe Natural -> OriginationRoute)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe OriginationRouteProtocol)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Protocol")
Parser (Maybe Text -> Maybe Natural -> OriginationRoute)
-> Parser (Maybe Text)
-> Parser (Maybe Natural -> OriginationRoute)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Host")
Parser (Maybe Natural -> OriginationRoute)
-> Parser (Maybe Natural) -> Parser OriginationRoute
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Port")
)
instance Prelude.Hashable OriginationRoute
instance Prelude.NFData OriginationRoute
instance Core.ToJSON OriginationRoute where
toJSON :: OriginationRoute -> Value
toJSON OriginationRoute' {Maybe Natural
Maybe Text
Maybe OriginationRouteProtocol
port :: Maybe Natural
host :: Maybe Text
protocol :: Maybe OriginationRouteProtocol
weight :: Maybe Natural
priority :: Maybe Natural
$sel:port:OriginationRoute' :: OriginationRoute -> Maybe Natural
$sel:host:OriginationRoute' :: OriginationRoute -> Maybe Text
$sel:protocol:OriginationRoute' :: OriginationRoute -> Maybe OriginationRouteProtocol
$sel:weight:OriginationRoute' :: OriginationRoute -> Maybe Natural
$sel:priority:OriginationRoute' :: OriginationRoute -> Maybe Natural
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Priority" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
priority,
(Text
"Weight" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
weight,
(Text
"Protocol" Text -> OriginationRouteProtocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OriginationRouteProtocol -> Pair)
-> Maybe OriginationRouteProtocol -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OriginationRouteProtocol
protocol,
(Text
"Host" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
host,
(Text
"Port" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
port
]
)