{-# 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.GrpcRouteAction 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 GrpcRouteAction = GrpcRouteAction'
{
GrpcRouteAction -> NonEmpty WeightedTarget
weightedTargets :: Prelude.NonEmpty WeightedTarget
}
deriving (GrpcRouteAction -> GrpcRouteAction -> Bool
(GrpcRouteAction -> GrpcRouteAction -> Bool)
-> (GrpcRouteAction -> GrpcRouteAction -> Bool)
-> Eq GrpcRouteAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GrpcRouteAction -> GrpcRouteAction -> Bool
$c/= :: GrpcRouteAction -> GrpcRouteAction -> Bool
== :: GrpcRouteAction -> GrpcRouteAction -> Bool
$c== :: GrpcRouteAction -> GrpcRouteAction -> Bool
Prelude.Eq, ReadPrec [GrpcRouteAction]
ReadPrec GrpcRouteAction
Int -> ReadS GrpcRouteAction
ReadS [GrpcRouteAction]
(Int -> ReadS GrpcRouteAction)
-> ReadS [GrpcRouteAction]
-> ReadPrec GrpcRouteAction
-> ReadPrec [GrpcRouteAction]
-> Read GrpcRouteAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GrpcRouteAction]
$creadListPrec :: ReadPrec [GrpcRouteAction]
readPrec :: ReadPrec GrpcRouteAction
$creadPrec :: ReadPrec GrpcRouteAction
readList :: ReadS [GrpcRouteAction]
$creadList :: ReadS [GrpcRouteAction]
readsPrec :: Int -> ReadS GrpcRouteAction
$creadsPrec :: Int -> ReadS GrpcRouteAction
Prelude.Read, Int -> GrpcRouteAction -> ShowS
[GrpcRouteAction] -> ShowS
GrpcRouteAction -> String
(Int -> GrpcRouteAction -> ShowS)
-> (GrpcRouteAction -> String)
-> ([GrpcRouteAction] -> ShowS)
-> Show GrpcRouteAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GrpcRouteAction] -> ShowS
$cshowList :: [GrpcRouteAction] -> ShowS
show :: GrpcRouteAction -> String
$cshow :: GrpcRouteAction -> String
showsPrec :: Int -> GrpcRouteAction -> ShowS
$cshowsPrec :: Int -> GrpcRouteAction -> ShowS
Prelude.Show, (forall x. GrpcRouteAction -> Rep GrpcRouteAction x)
-> (forall x. Rep GrpcRouteAction x -> GrpcRouteAction)
-> Generic GrpcRouteAction
forall x. Rep GrpcRouteAction x -> GrpcRouteAction
forall x. GrpcRouteAction -> Rep GrpcRouteAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GrpcRouteAction x -> GrpcRouteAction
$cfrom :: forall x. GrpcRouteAction -> Rep GrpcRouteAction x
Prelude.Generic)
newGrpcRouteAction ::
Prelude.NonEmpty WeightedTarget ->
GrpcRouteAction
newGrpcRouteAction :: NonEmpty WeightedTarget -> GrpcRouteAction
newGrpcRouteAction NonEmpty WeightedTarget
pWeightedTargets_ =
GrpcRouteAction' :: NonEmpty WeightedTarget -> GrpcRouteAction
GrpcRouteAction'
{ $sel:weightedTargets:GrpcRouteAction' :: 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_
}
grpcRouteAction_weightedTargets :: Lens.Lens' GrpcRouteAction (Prelude.NonEmpty WeightedTarget)
grpcRouteAction_weightedTargets :: (NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> GrpcRouteAction -> f GrpcRouteAction
grpcRouteAction_weightedTargets = (GrpcRouteAction -> NonEmpty WeightedTarget)
-> (GrpcRouteAction -> NonEmpty WeightedTarget -> GrpcRouteAction)
-> Lens
GrpcRouteAction
GrpcRouteAction
(NonEmpty WeightedTarget)
(NonEmpty WeightedTarget)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GrpcRouteAction' {NonEmpty WeightedTarget
weightedTargets :: NonEmpty WeightedTarget
$sel:weightedTargets:GrpcRouteAction' :: GrpcRouteAction -> NonEmpty WeightedTarget
weightedTargets} -> NonEmpty WeightedTarget
weightedTargets) (\s :: GrpcRouteAction
s@GrpcRouteAction' {} NonEmpty WeightedTarget
a -> GrpcRouteAction
s {$sel:weightedTargets:GrpcRouteAction' :: NonEmpty WeightedTarget
weightedTargets = NonEmpty WeightedTarget
a} :: GrpcRouteAction) ((NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> GrpcRouteAction -> f GrpcRouteAction)
-> ((NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> (NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> GrpcRouteAction
-> f GrpcRouteAction
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 GrpcRouteAction where
parseJSON :: Value -> Parser GrpcRouteAction
parseJSON =
String
-> (Object -> Parser GrpcRouteAction)
-> Value
-> Parser GrpcRouteAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"GrpcRouteAction"
( \Object
x ->
NonEmpty WeightedTarget -> GrpcRouteAction
GrpcRouteAction'
(NonEmpty WeightedTarget -> GrpcRouteAction)
-> Parser (NonEmpty WeightedTarget) -> Parser GrpcRouteAction
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 GrpcRouteAction
instance Prelude.NFData GrpcRouteAction
instance Core.ToJSON GrpcRouteAction where
toJSON :: GrpcRouteAction -> Value
toJSON GrpcRouteAction' {NonEmpty WeightedTarget
weightedTargets :: NonEmpty WeightedTarget
$sel:weightedTargets:GrpcRouteAction' :: GrpcRouteAction -> 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)
]
)