{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
data GrpcRouteAction = GrpcRouteAction'
{
GrpcRouteAction -> NonEmpty WeightedTarget
weightedTargets :: Prelude.NonEmpty WeightedTarget
}
deriving (GrpcRouteAction -> GrpcRouteAction -> Bool
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]
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
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. 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'
{ $sel:weightedTargets:GrpcRouteAction' :: NonEmpty WeightedTarget
weightedTargets =
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty WeightedTarget
pWeightedTargets_
}
grpcRouteAction_weightedTargets :: Lens.Lens' GrpcRouteAction (Prelude.NonEmpty WeightedTarget)
grpcRouteAction_weightedTargets :: Lens' GrpcRouteAction (NonEmpty WeightedTarget)
grpcRouteAction_weightedTargets = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Data.FromJSON GrpcRouteAction where
parseJSON :: Value -> Parser GrpcRouteAction
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"GrpcRouteAction"
( \Object
x ->
NonEmpty WeightedTarget -> GrpcRouteAction
GrpcRouteAction'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"weightedTargets")
)
instance Prelude.Hashable GrpcRouteAction where
hashWithSalt :: Int -> GrpcRouteAction -> Int
hashWithSalt Int
_salt GrpcRouteAction' {NonEmpty WeightedTarget
weightedTargets :: NonEmpty WeightedTarget
$sel:weightedTargets:GrpcRouteAction' :: GrpcRouteAction -> NonEmpty WeightedTarget
..} =
Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty WeightedTarget
weightedTargets
instance Prelude.NFData GrpcRouteAction where
rnf :: GrpcRouteAction -> ()
rnf GrpcRouteAction' {NonEmpty WeightedTarget
weightedTargets :: NonEmpty WeightedTarget
$sel:weightedTargets:GrpcRouteAction' :: GrpcRouteAction -> NonEmpty WeightedTarget
..} =
forall a. NFData a => a -> ()
Prelude.rnf NonEmpty WeightedTarget
weightedTargets
instance Data.ToJSON GrpcRouteAction where
toJSON :: GrpcRouteAction -> Value
toJSON GrpcRouteAction' {NonEmpty WeightedTarget
weightedTargets :: NonEmpty WeightedTarget
$sel:weightedTargets:GrpcRouteAction' :: GrpcRouteAction -> NonEmpty WeightedTarget
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just
(Key
"weightedTargets" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty WeightedTarget
weightedTargets)
]
)