{-# 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.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data HttpRouteAction = HttpRouteAction'
{
HttpRouteAction -> NonEmpty WeightedTarget
weightedTargets :: Prelude.NonEmpty WeightedTarget
}
deriving (HttpRouteAction -> HttpRouteAction -> Bool
(HttpRouteAction -> HttpRouteAction -> Bool)
-> (HttpRouteAction -> HttpRouteAction -> Bool)
-> Eq HttpRouteAction
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]
(Int -> ReadS HttpRouteAction)
-> ReadS [HttpRouteAction]
-> ReadPrec HttpRouteAction
-> ReadPrec [HttpRouteAction]
-> Read 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
(Int -> HttpRouteAction -> ShowS)
-> (HttpRouteAction -> String)
-> ([HttpRouteAction] -> ShowS)
-> Show HttpRouteAction
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. HttpRouteAction -> Rep HttpRouteAction x)
-> (forall x. Rep HttpRouteAction x -> HttpRouteAction)
-> Generic HttpRouteAction
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' :: NonEmpty WeightedTarget -> HttpRouteAction
HttpRouteAction'
{ $sel:weightedTargets:HttpRouteAction' :: 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_
}
httpRouteAction_weightedTargets :: Lens.Lens' HttpRouteAction (Prelude.NonEmpty WeightedTarget)
httpRouteAction_weightedTargets :: (NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> HttpRouteAction -> f HttpRouteAction
httpRouteAction_weightedTargets = (HttpRouteAction -> NonEmpty WeightedTarget)
-> (HttpRouteAction -> NonEmpty WeightedTarget -> HttpRouteAction)
-> Lens
HttpRouteAction
HttpRouteAction
(NonEmpty WeightedTarget)
(NonEmpty WeightedTarget)
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) ((NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> HttpRouteAction -> f HttpRouteAction)
-> ((NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> (NonEmpty WeightedTarget -> f (NonEmpty WeightedTarget))
-> HttpRouteAction
-> f HttpRouteAction
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 HttpRouteAction where
parseJSON :: Value -> Parser HttpRouteAction
parseJSON =
String
-> (Object -> Parser HttpRouteAction)
-> Value
-> Parser HttpRouteAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"HttpRouteAction"
( \Object
x ->
NonEmpty WeightedTarget -> HttpRouteAction
HttpRouteAction'
(NonEmpty WeightedTarget -> HttpRouteAction)
-> Parser (NonEmpty WeightedTarget) -> Parser HttpRouteAction
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 HttpRouteAction
instance Prelude.NFData HttpRouteAction
instance Core.ToJSON HttpRouteAction where
toJSON :: HttpRouteAction -> Value
toJSON HttpRouteAction' {NonEmpty WeightedTarget
weightedTargets :: NonEmpty WeightedTarget
$sel:weightedTargets:HttpRouteAction' :: HttpRouteAction -> 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)
]
)