{-# 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.AppMesh.Types.WeightedTarget where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data WeightedTarget = WeightedTarget'
{
WeightedTarget -> Text
virtualNode :: Prelude.Text,
WeightedTarget -> Natural
weight :: Prelude.Natural
}
deriving (WeightedTarget -> WeightedTarget -> Bool
(WeightedTarget -> WeightedTarget -> Bool)
-> (WeightedTarget -> WeightedTarget -> Bool) -> Eq WeightedTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WeightedTarget -> WeightedTarget -> Bool
$c/= :: WeightedTarget -> WeightedTarget -> Bool
== :: WeightedTarget -> WeightedTarget -> Bool
$c== :: WeightedTarget -> WeightedTarget -> Bool
Prelude.Eq, ReadPrec [WeightedTarget]
ReadPrec WeightedTarget
Int -> ReadS WeightedTarget
ReadS [WeightedTarget]
(Int -> ReadS WeightedTarget)
-> ReadS [WeightedTarget]
-> ReadPrec WeightedTarget
-> ReadPrec [WeightedTarget]
-> Read WeightedTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WeightedTarget]
$creadListPrec :: ReadPrec [WeightedTarget]
readPrec :: ReadPrec WeightedTarget
$creadPrec :: ReadPrec WeightedTarget
readList :: ReadS [WeightedTarget]
$creadList :: ReadS [WeightedTarget]
readsPrec :: Int -> ReadS WeightedTarget
$creadsPrec :: Int -> ReadS WeightedTarget
Prelude.Read, Int -> WeightedTarget -> ShowS
[WeightedTarget] -> ShowS
WeightedTarget -> String
(Int -> WeightedTarget -> ShowS)
-> (WeightedTarget -> String)
-> ([WeightedTarget] -> ShowS)
-> Show WeightedTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WeightedTarget] -> ShowS
$cshowList :: [WeightedTarget] -> ShowS
show :: WeightedTarget -> String
$cshow :: WeightedTarget -> String
showsPrec :: Int -> WeightedTarget -> ShowS
$cshowsPrec :: Int -> WeightedTarget -> ShowS
Prelude.Show, (forall x. WeightedTarget -> Rep WeightedTarget x)
-> (forall x. Rep WeightedTarget x -> WeightedTarget)
-> Generic WeightedTarget
forall x. Rep WeightedTarget x -> WeightedTarget
forall x. WeightedTarget -> Rep WeightedTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WeightedTarget x -> WeightedTarget
$cfrom :: forall x. WeightedTarget -> Rep WeightedTarget x
Prelude.Generic)
newWeightedTarget ::
Prelude.Text ->
Prelude.Natural ->
WeightedTarget
newWeightedTarget :: Text -> Natural -> WeightedTarget
newWeightedTarget Text
pVirtualNode_ Natural
pWeight_ =
WeightedTarget' :: Text -> Natural -> WeightedTarget
WeightedTarget'
{ $sel:virtualNode:WeightedTarget' :: Text
virtualNode = Text
pVirtualNode_,
$sel:weight:WeightedTarget' :: Natural
weight = Natural
pWeight_
}
weightedTarget_virtualNode :: Lens.Lens' WeightedTarget Prelude.Text
weightedTarget_virtualNode :: (Text -> f Text) -> WeightedTarget -> f WeightedTarget
weightedTarget_virtualNode = (WeightedTarget -> Text)
-> (WeightedTarget -> Text -> WeightedTarget)
-> Lens WeightedTarget WeightedTarget Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WeightedTarget' {Text
virtualNode :: Text
$sel:virtualNode:WeightedTarget' :: WeightedTarget -> Text
virtualNode} -> Text
virtualNode) (\s :: WeightedTarget
s@WeightedTarget' {} Text
a -> WeightedTarget
s {$sel:virtualNode:WeightedTarget' :: Text
virtualNode = Text
a} :: WeightedTarget)
weightedTarget_weight :: Lens.Lens' WeightedTarget Prelude.Natural
weightedTarget_weight :: (Natural -> f Natural) -> WeightedTarget -> f WeightedTarget
weightedTarget_weight = (WeightedTarget -> Natural)
-> (WeightedTarget -> Natural -> WeightedTarget)
-> Lens WeightedTarget WeightedTarget Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WeightedTarget' {Natural
weight :: Natural
$sel:weight:WeightedTarget' :: WeightedTarget -> Natural
weight} -> Natural
weight) (\s :: WeightedTarget
s@WeightedTarget' {} Natural
a -> WeightedTarget
s {$sel:weight:WeightedTarget' :: Natural
weight = Natural
a} :: WeightedTarget)
instance Core.FromJSON WeightedTarget where
parseJSON :: Value -> Parser WeightedTarget
parseJSON =
String
-> (Object -> Parser WeightedTarget)
-> Value
-> Parser WeightedTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"WeightedTarget"
( \Object
x ->
Text -> Natural -> WeightedTarget
WeightedTarget'
(Text -> Natural -> WeightedTarget)
-> Parser Text -> Parser (Natural -> WeightedTarget)
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
"virtualNode")
Parser (Natural -> WeightedTarget)
-> Parser Natural -> Parser WeightedTarget
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
"weight")
)
instance Prelude.Hashable WeightedTarget
instance Prelude.NFData WeightedTarget
instance Core.ToJSON WeightedTarget where
toJSON :: WeightedTarget -> Value
toJSON WeightedTarget' {Natural
Text
weight :: Natural
virtualNode :: Text
$sel:weight:WeightedTarget' :: WeightedTarget -> Natural
$sel:virtualNode:WeightedTarget' :: WeightedTarget -> 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
"virtualNode" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
virtualNode),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"weight" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
weight)
]
)