{-# 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.TcpRouteAction where
import Amazonka.AppMesh.Types.WeightedTarget
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data TcpRouteAction = TcpRouteAction'
{
TcpRouteAction -> NonEmpty WeightedTarget
weightedTargets :: Prelude.NonEmpty WeightedTarget
}
deriving (TcpRouteAction -> TcpRouteAction -> Bool
(TcpRouteAction -> TcpRouteAction -> Bool)
-> (TcpRouteAction -> TcpRouteAction -> Bool) -> Eq TcpRouteAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TcpRouteAction -> TcpRouteAction -> Bool
$c/= :: TcpRouteAction -> TcpRouteAction -> Bool
== :: TcpRouteAction -> TcpRouteAction -> Bool
$c== :: TcpRouteAction -> TcpRouteAction -> Bool
Prelude.Eq, ReadPrec [TcpRouteAction]
ReadPrec TcpRouteAction
Int -> ReadS TcpRouteAction
ReadS [TcpRouteAction]
(Int -> ReadS TcpRouteAction)
-> ReadS [TcpRouteAction]
-> ReadPrec TcpRouteAction
-> ReadPrec [TcpRouteAction]
-> Read TcpRouteAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TcpRouteAction]
$creadListPrec :: ReadPrec [TcpRouteAction]
readPrec :: ReadPrec TcpRouteAction
$creadPrec :: ReadPrec TcpRouteAction
readList :: ReadS [TcpRouteAction]
$creadList :: ReadS [TcpRouteAction]
readsPrec :: Int -> ReadS TcpRouteAction
$creadsPrec :: Int -> ReadS TcpRouteAction
Prelude.Read, Int -> TcpRouteAction -> ShowS
[TcpRouteAction] -> ShowS
TcpRouteAction -> String
(Int -> TcpRouteAction -> ShowS)
-> (TcpRouteAction -> String)
-> ([TcpRouteAction] -> ShowS)
-> Show TcpRouteAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TcpRouteAction] -> ShowS
$cshowList :: [TcpRouteAction] -> ShowS
show :: TcpRouteAction -> String
$cshow :: TcpRouteAction -> String
showsPrec :: Int -> TcpRouteAction -> ShowS
$cshowsPrec :: Int -> TcpRouteAction -> ShowS
Prelude.Show, (forall x. TcpRouteAction -> Rep TcpRouteAction x)
-> (forall x. Rep TcpRouteAction x -> TcpRouteAction)
-> Generic TcpRouteAction
forall x. Rep TcpRouteAction x -> TcpRouteAction
forall x. TcpRouteAction -> Rep TcpRouteAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TcpRouteAction x -> TcpRouteAction
$cfrom :: forall x. TcpRouteAction -> Rep TcpRouteAction x
Prelude.Generic)
newTcpRouteAction ::
Prelude.NonEmpty WeightedTarget ->
TcpRouteAction
newTcpRouteAction :: NonEmpty WeightedTarget -> TcpRouteAction
newTcpRouteAction NonEmpty WeightedTarget
pWeightedTargets_ =
TcpRouteAction' :: NonEmpty WeightedTarget -> TcpRouteAction
TcpRouteAction'
{ $sel:weightedTargets:TcpRouteAction' :: NonEmpty WeightedTarget
weightedTargets =
Tagged
(NonEmpty WeightedTarget) (Identity (NonEmpty WeightedTarget))
-> Tagged
(NonEmpty WeightedTarget) (Identity (NonEmpty WeightedTarget))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty WeightedTarget) (Identity (NonEmpty WeightedTarget))
-> Tagged
(NonEmpty WeightedTarget) (Identity (NonEmpty WeightedTarget)))
-> NonEmpty WeightedTarget -> NonEmpty WeightedTarget
forall t b. AReview t b -> b -> t
Lens.# NonEmpty WeightedTarget
pWeightedTargets_
}
tcpRouteAction_weightedTargets :: Lens.Lens' TcpRouteAction (Prelude.NonEmpty WeightedTarget)
tcpRouteAction_weightedTargets :: (NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> TcpRouteAction -> f TcpRouteAction
tcpRouteAction_weightedTargets = (TcpRouteAction -> NonEmpty WeightedTarget)
-> (TcpRouteAction -> NonEmpty WeightedTarget -> TcpRouteAction)
-> Lens
TcpRouteAction
TcpRouteAction
(NonEmpty WeightedTarget)
(NonEmpty WeightedTarget)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TcpRouteAction' {NonEmpty WeightedTarget
weightedTargets :: NonEmpty WeightedTarget
$sel:weightedTargets:TcpRouteAction' :: TcpRouteAction -> NonEmpty WeightedTarget
weightedTargets} -> NonEmpty WeightedTarget
weightedTargets) (\s :: TcpRouteAction
s@TcpRouteAction' {} NonEmpty WeightedTarget
a -> TcpRouteAction
s {$sel:weightedTargets:TcpRouteAction' :: NonEmpty WeightedTarget
weightedTargets = NonEmpty WeightedTarget
a} :: TcpRouteAction) ((NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> TcpRouteAction -> f TcpRouteAction)
-> ((NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> (NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> TcpRouteAction
-> f TcpRouteAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON TcpRouteAction where
parseJSON :: Value -> Parser TcpRouteAction
parseJSON =
String
-> (Object -> Parser TcpRouteAction)
-> Value
-> Parser TcpRouteAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"TcpRouteAction"
( \Object
x ->
NonEmpty WeightedTarget -> TcpRouteAction
TcpRouteAction'
(NonEmpty WeightedTarget -> TcpRouteAction)
-> Parser (NonEmpty WeightedTarget) -> Parser TcpRouteAction
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (NonEmpty WeightedTarget)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"weightedTargets")
)
instance Prelude.Hashable TcpRouteAction
instance Prelude.NFData TcpRouteAction
instance Core.ToJSON TcpRouteAction where
toJSON :: TcpRouteAction -> Value
toJSON TcpRouteAction' {NonEmpty WeightedTarget
weightedTargets :: NonEmpty WeightedTarget
$sel:weightedTargets:TcpRouteAction' :: TcpRouteAction -> NonEmpty WeightedTarget
..} =
[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
"weightedTargets" Text -> NonEmpty WeightedTarget -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty WeightedTarget
weightedTargets)
]
)