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