{-# 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.CodeDeploy.Types.TrafficRoutingConfig where
import Amazonka.CodeDeploy.Types.TimeBasedCanary
import Amazonka.CodeDeploy.Types.TimeBasedLinear
import Amazonka.CodeDeploy.Types.TrafficRoutingType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data TrafficRoutingConfig = TrafficRoutingConfig'
{
TrafficRoutingConfig -> Maybe TimeBasedCanary
timeBasedCanary :: Prelude.Maybe TimeBasedCanary,
TrafficRoutingConfig -> Maybe TimeBasedLinear
timeBasedLinear :: Prelude.Maybe TimeBasedLinear,
TrafficRoutingConfig -> Maybe TrafficRoutingType
type' :: Prelude.Maybe TrafficRoutingType
}
deriving (TrafficRoutingConfig -> TrafficRoutingConfig -> Bool
(TrafficRoutingConfig -> TrafficRoutingConfig -> Bool)
-> (TrafficRoutingConfig -> TrafficRoutingConfig -> Bool)
-> Eq TrafficRoutingConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrafficRoutingConfig -> TrafficRoutingConfig -> Bool
$c/= :: TrafficRoutingConfig -> TrafficRoutingConfig -> Bool
== :: TrafficRoutingConfig -> TrafficRoutingConfig -> Bool
$c== :: TrafficRoutingConfig -> TrafficRoutingConfig -> Bool
Prelude.Eq, ReadPrec [TrafficRoutingConfig]
ReadPrec TrafficRoutingConfig
Int -> ReadS TrafficRoutingConfig
ReadS [TrafficRoutingConfig]
(Int -> ReadS TrafficRoutingConfig)
-> ReadS [TrafficRoutingConfig]
-> ReadPrec TrafficRoutingConfig
-> ReadPrec [TrafficRoutingConfig]
-> Read TrafficRoutingConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrafficRoutingConfig]
$creadListPrec :: ReadPrec [TrafficRoutingConfig]
readPrec :: ReadPrec TrafficRoutingConfig
$creadPrec :: ReadPrec TrafficRoutingConfig
readList :: ReadS [TrafficRoutingConfig]
$creadList :: ReadS [TrafficRoutingConfig]
readsPrec :: Int -> ReadS TrafficRoutingConfig
$creadsPrec :: Int -> ReadS TrafficRoutingConfig
Prelude.Read, Int -> TrafficRoutingConfig -> ShowS
[TrafficRoutingConfig] -> ShowS
TrafficRoutingConfig -> String
(Int -> TrafficRoutingConfig -> ShowS)
-> (TrafficRoutingConfig -> String)
-> ([TrafficRoutingConfig] -> ShowS)
-> Show TrafficRoutingConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrafficRoutingConfig] -> ShowS
$cshowList :: [TrafficRoutingConfig] -> ShowS
show :: TrafficRoutingConfig -> String
$cshow :: TrafficRoutingConfig -> String
showsPrec :: Int -> TrafficRoutingConfig -> ShowS
$cshowsPrec :: Int -> TrafficRoutingConfig -> ShowS
Prelude.Show, (forall x. TrafficRoutingConfig -> Rep TrafficRoutingConfig x)
-> (forall x. Rep TrafficRoutingConfig x -> TrafficRoutingConfig)
-> Generic TrafficRoutingConfig
forall x. Rep TrafficRoutingConfig x -> TrafficRoutingConfig
forall x. TrafficRoutingConfig -> Rep TrafficRoutingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrafficRoutingConfig x -> TrafficRoutingConfig
$cfrom :: forall x. TrafficRoutingConfig -> Rep TrafficRoutingConfig x
Prelude.Generic)
newTrafficRoutingConfig ::
TrafficRoutingConfig
newTrafficRoutingConfig :: TrafficRoutingConfig
newTrafficRoutingConfig =
TrafficRoutingConfig' :: Maybe TimeBasedCanary
-> Maybe TimeBasedLinear
-> Maybe TrafficRoutingType
-> TrafficRoutingConfig
TrafficRoutingConfig'
{ $sel:timeBasedCanary:TrafficRoutingConfig' :: Maybe TimeBasedCanary
timeBasedCanary =
Maybe TimeBasedCanary
forall a. Maybe a
Prelude.Nothing,
$sel:timeBasedLinear:TrafficRoutingConfig' :: Maybe TimeBasedLinear
timeBasedLinear = Maybe TimeBasedLinear
forall a. Maybe a
Prelude.Nothing,
$sel:type':TrafficRoutingConfig' :: Maybe TrafficRoutingType
type' = Maybe TrafficRoutingType
forall a. Maybe a
Prelude.Nothing
}
trafficRoutingConfig_timeBasedCanary :: Lens.Lens' TrafficRoutingConfig (Prelude.Maybe TimeBasedCanary)
trafficRoutingConfig_timeBasedCanary :: (Maybe TimeBasedCanary -> f (Maybe TimeBasedCanary))
-> TrafficRoutingConfig -> f TrafficRoutingConfig
trafficRoutingConfig_timeBasedCanary = (TrafficRoutingConfig -> Maybe TimeBasedCanary)
-> (TrafficRoutingConfig
-> Maybe TimeBasedCanary -> TrafficRoutingConfig)
-> Lens
TrafficRoutingConfig
TrafficRoutingConfig
(Maybe TimeBasedCanary)
(Maybe TimeBasedCanary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficRoutingConfig' {Maybe TimeBasedCanary
timeBasedCanary :: Maybe TimeBasedCanary
$sel:timeBasedCanary:TrafficRoutingConfig' :: TrafficRoutingConfig -> Maybe TimeBasedCanary
timeBasedCanary} -> Maybe TimeBasedCanary
timeBasedCanary) (\s :: TrafficRoutingConfig
s@TrafficRoutingConfig' {} Maybe TimeBasedCanary
a -> TrafficRoutingConfig
s {$sel:timeBasedCanary:TrafficRoutingConfig' :: Maybe TimeBasedCanary
timeBasedCanary = Maybe TimeBasedCanary
a} :: TrafficRoutingConfig)
trafficRoutingConfig_timeBasedLinear :: Lens.Lens' TrafficRoutingConfig (Prelude.Maybe TimeBasedLinear)
trafficRoutingConfig_timeBasedLinear :: (Maybe TimeBasedLinear -> f (Maybe TimeBasedLinear))
-> TrafficRoutingConfig -> f TrafficRoutingConfig
trafficRoutingConfig_timeBasedLinear = (TrafficRoutingConfig -> Maybe TimeBasedLinear)
-> (TrafficRoutingConfig
-> Maybe TimeBasedLinear -> TrafficRoutingConfig)
-> Lens
TrafficRoutingConfig
TrafficRoutingConfig
(Maybe TimeBasedLinear)
(Maybe TimeBasedLinear)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficRoutingConfig' {Maybe TimeBasedLinear
timeBasedLinear :: Maybe TimeBasedLinear
$sel:timeBasedLinear:TrafficRoutingConfig' :: TrafficRoutingConfig -> Maybe TimeBasedLinear
timeBasedLinear} -> Maybe TimeBasedLinear
timeBasedLinear) (\s :: TrafficRoutingConfig
s@TrafficRoutingConfig' {} Maybe TimeBasedLinear
a -> TrafficRoutingConfig
s {$sel:timeBasedLinear:TrafficRoutingConfig' :: Maybe TimeBasedLinear
timeBasedLinear = Maybe TimeBasedLinear
a} :: TrafficRoutingConfig)
trafficRoutingConfig_type :: Lens.Lens' TrafficRoutingConfig (Prelude.Maybe TrafficRoutingType)
trafficRoutingConfig_type :: (Maybe TrafficRoutingType -> f (Maybe TrafficRoutingType))
-> TrafficRoutingConfig -> f TrafficRoutingConfig
trafficRoutingConfig_type = (TrafficRoutingConfig -> Maybe TrafficRoutingType)
-> (TrafficRoutingConfig
-> Maybe TrafficRoutingType -> TrafficRoutingConfig)
-> Lens
TrafficRoutingConfig
TrafficRoutingConfig
(Maybe TrafficRoutingType)
(Maybe TrafficRoutingType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficRoutingConfig' {Maybe TrafficRoutingType
type' :: Maybe TrafficRoutingType
$sel:type':TrafficRoutingConfig' :: TrafficRoutingConfig -> Maybe TrafficRoutingType
type'} -> Maybe TrafficRoutingType
type') (\s :: TrafficRoutingConfig
s@TrafficRoutingConfig' {} Maybe TrafficRoutingType
a -> TrafficRoutingConfig
s {$sel:type':TrafficRoutingConfig' :: Maybe TrafficRoutingType
type' = Maybe TrafficRoutingType
a} :: TrafficRoutingConfig)
instance Core.FromJSON TrafficRoutingConfig where
parseJSON :: Value -> Parser TrafficRoutingConfig
parseJSON =
String
-> (Object -> Parser TrafficRoutingConfig)
-> Value
-> Parser TrafficRoutingConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"TrafficRoutingConfig"
( \Object
x ->
Maybe TimeBasedCanary
-> Maybe TimeBasedLinear
-> Maybe TrafficRoutingType
-> TrafficRoutingConfig
TrafficRoutingConfig'
(Maybe TimeBasedCanary
-> Maybe TimeBasedLinear
-> Maybe TrafficRoutingType
-> TrafficRoutingConfig)
-> Parser (Maybe TimeBasedCanary)
-> Parser
(Maybe TimeBasedLinear
-> Maybe TrafficRoutingType -> TrafficRoutingConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TimeBasedCanary)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timeBasedCanary")
Parser
(Maybe TimeBasedLinear
-> Maybe TrafficRoutingType -> TrafficRoutingConfig)
-> Parser (Maybe TimeBasedLinear)
-> Parser (Maybe TrafficRoutingType -> TrafficRoutingConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TimeBasedLinear)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timeBasedLinear")
Parser (Maybe TrafficRoutingType -> TrafficRoutingConfig)
-> Parser (Maybe TrafficRoutingType) -> Parser TrafficRoutingConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TrafficRoutingType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
)
instance Prelude.Hashable TrafficRoutingConfig
instance Prelude.NFData TrafficRoutingConfig
instance Core.ToJSON TrafficRoutingConfig where
toJSON :: TrafficRoutingConfig -> Value
toJSON TrafficRoutingConfig' {Maybe TimeBasedCanary
Maybe TimeBasedLinear
Maybe TrafficRoutingType
type' :: Maybe TrafficRoutingType
timeBasedLinear :: Maybe TimeBasedLinear
timeBasedCanary :: Maybe TimeBasedCanary
$sel:type':TrafficRoutingConfig' :: TrafficRoutingConfig -> Maybe TrafficRoutingType
$sel:timeBasedLinear:TrafficRoutingConfig' :: TrafficRoutingConfig -> Maybe TimeBasedLinear
$sel:timeBasedCanary:TrafficRoutingConfig' :: TrafficRoutingConfig -> Maybe TimeBasedCanary
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"timeBasedCanary" Text -> TimeBasedCanary -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(TimeBasedCanary -> Pair) -> Maybe TimeBasedCanary -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimeBasedCanary
timeBasedCanary,
(Text
"timeBasedLinear" Text -> TimeBasedLinear -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(TimeBasedLinear -> Pair) -> Maybe TimeBasedLinear -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimeBasedLinear
timeBasedLinear,
(Text
"type" Text -> TrafficRoutingType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TrafficRoutingType -> Pair)
-> Maybe TrafficRoutingType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TrafficRoutingType
type'
]
)