{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SageMaker.Types.TrafficRoutingConfig
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.TrafficRoutingConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.CapacitySize
import Amazonka.SageMaker.Types.TrafficRoutingConfigType

-- | Currently, the @TrafficRoutingConfig@ API is not supported.
--
-- /See:/ 'newTrafficRoutingConfig' smart constructor.
data TrafficRoutingConfig = TrafficRoutingConfig'
  { TrafficRoutingConfig -> Maybe CapacitySize
canarySize :: Prelude.Maybe CapacitySize,
    TrafficRoutingConfig -> TrafficRoutingConfigType
type' :: TrafficRoutingConfigType,
    TrafficRoutingConfig -> Natural
waitIntervalInSeconds :: Prelude.Natural
  }
  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)

-- |
-- Create a value of 'TrafficRoutingConfig' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'canarySize', 'trafficRoutingConfig_canarySize' -
--
-- 'type'', 'trafficRoutingConfig_type' -
--
-- 'waitIntervalInSeconds', 'trafficRoutingConfig_waitIntervalInSeconds' -
newTrafficRoutingConfig ::
  -- | 'type''
  TrafficRoutingConfigType ->
  -- | 'waitIntervalInSeconds'
  Prelude.Natural ->
  TrafficRoutingConfig
newTrafficRoutingConfig :: TrafficRoutingConfigType -> Natural -> TrafficRoutingConfig
newTrafficRoutingConfig
  TrafficRoutingConfigType
pType_
  Natural
pWaitIntervalInSeconds_ =
    TrafficRoutingConfig' :: Maybe CapacitySize
-> TrafficRoutingConfigType -> Natural -> TrafficRoutingConfig
TrafficRoutingConfig'
      { $sel:canarySize:TrafficRoutingConfig' :: Maybe CapacitySize
canarySize = Maybe CapacitySize
forall a. Maybe a
Prelude.Nothing,
        $sel:type':TrafficRoutingConfig' :: TrafficRoutingConfigType
type' = TrafficRoutingConfigType
pType_,
        $sel:waitIntervalInSeconds:TrafficRoutingConfig' :: Natural
waitIntervalInSeconds = Natural
pWaitIntervalInSeconds_
      }

-- |
trafficRoutingConfig_canarySize :: Lens.Lens' TrafficRoutingConfig (Prelude.Maybe CapacitySize)
trafficRoutingConfig_canarySize :: (Maybe CapacitySize -> f (Maybe CapacitySize))
-> TrafficRoutingConfig -> f TrafficRoutingConfig
trafficRoutingConfig_canarySize = (TrafficRoutingConfig -> Maybe CapacitySize)
-> (TrafficRoutingConfig
    -> Maybe CapacitySize -> TrafficRoutingConfig)
-> Lens
     TrafficRoutingConfig
     TrafficRoutingConfig
     (Maybe CapacitySize)
     (Maybe CapacitySize)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficRoutingConfig' {Maybe CapacitySize
canarySize :: Maybe CapacitySize
$sel:canarySize:TrafficRoutingConfig' :: TrafficRoutingConfig -> Maybe CapacitySize
canarySize} -> Maybe CapacitySize
canarySize) (\s :: TrafficRoutingConfig
s@TrafficRoutingConfig' {} Maybe CapacitySize
a -> TrafficRoutingConfig
s {$sel:canarySize:TrafficRoutingConfig' :: Maybe CapacitySize
canarySize = Maybe CapacitySize
a} :: TrafficRoutingConfig)

-- |
trafficRoutingConfig_type :: Lens.Lens' TrafficRoutingConfig TrafficRoutingConfigType
trafficRoutingConfig_type :: (TrafficRoutingConfigType -> f TrafficRoutingConfigType)
-> TrafficRoutingConfig -> f TrafficRoutingConfig
trafficRoutingConfig_type = (TrafficRoutingConfig -> TrafficRoutingConfigType)
-> (TrafficRoutingConfig
    -> TrafficRoutingConfigType -> TrafficRoutingConfig)
-> Lens
     TrafficRoutingConfig
     TrafficRoutingConfig
     TrafficRoutingConfigType
     TrafficRoutingConfigType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficRoutingConfig' {TrafficRoutingConfigType
type' :: TrafficRoutingConfigType
$sel:type':TrafficRoutingConfig' :: TrafficRoutingConfig -> TrafficRoutingConfigType
type'} -> TrafficRoutingConfigType
type') (\s :: TrafficRoutingConfig
s@TrafficRoutingConfig' {} TrafficRoutingConfigType
a -> TrafficRoutingConfig
s {$sel:type':TrafficRoutingConfig' :: TrafficRoutingConfigType
type' = TrafficRoutingConfigType
a} :: TrafficRoutingConfig)

-- |
trafficRoutingConfig_waitIntervalInSeconds :: Lens.Lens' TrafficRoutingConfig Prelude.Natural
trafficRoutingConfig_waitIntervalInSeconds :: (Natural -> f Natural)
-> TrafficRoutingConfig -> f TrafficRoutingConfig
trafficRoutingConfig_waitIntervalInSeconds = (TrafficRoutingConfig -> Natural)
-> (TrafficRoutingConfig -> Natural -> TrafficRoutingConfig)
-> Lens TrafficRoutingConfig TrafficRoutingConfig Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficRoutingConfig' {Natural
waitIntervalInSeconds :: Natural
$sel:waitIntervalInSeconds:TrafficRoutingConfig' :: TrafficRoutingConfig -> Natural
waitIntervalInSeconds} -> Natural
waitIntervalInSeconds) (\s :: TrafficRoutingConfig
s@TrafficRoutingConfig' {} Natural
a -> TrafficRoutingConfig
s {$sel:waitIntervalInSeconds:TrafficRoutingConfig' :: Natural
waitIntervalInSeconds = Natural
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 CapacitySize
-> TrafficRoutingConfigType -> Natural -> TrafficRoutingConfig
TrafficRoutingConfig'
            (Maybe CapacitySize
 -> TrafficRoutingConfigType -> Natural -> TrafficRoutingConfig)
-> Parser (Maybe CapacitySize)
-> Parser
     (TrafficRoutingConfigType -> Natural -> TrafficRoutingConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CapacitySize)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CanarySize")
            Parser
  (TrafficRoutingConfigType -> Natural -> TrafficRoutingConfig)
-> Parser TrafficRoutingConfigType
-> Parser (Natural -> TrafficRoutingConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser TrafficRoutingConfigType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
            Parser (Natural -> TrafficRoutingConfig)
-> Parser Natural -> Parser TrafficRoutingConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"WaitIntervalInSeconds")
      )

instance Prelude.Hashable TrafficRoutingConfig

instance Prelude.NFData TrafficRoutingConfig

instance Core.ToJSON TrafficRoutingConfig where
  toJSON :: TrafficRoutingConfig -> Value
toJSON TrafficRoutingConfig' {Natural
Maybe CapacitySize
TrafficRoutingConfigType
waitIntervalInSeconds :: Natural
type' :: TrafficRoutingConfigType
canarySize :: Maybe CapacitySize
$sel:waitIntervalInSeconds:TrafficRoutingConfig' :: TrafficRoutingConfig -> Natural
$sel:type':TrafficRoutingConfig' :: TrafficRoutingConfig -> TrafficRoutingConfigType
$sel:canarySize:TrafficRoutingConfig' :: TrafficRoutingConfig -> Maybe CapacitySize
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CanarySize" Text -> CapacitySize -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CapacitySize -> Pair) -> Maybe CapacitySize -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CapacitySize
canarySize,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> TrafficRoutingConfigType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TrafficRoutingConfigType
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"WaitIntervalInSeconds"
                  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
waitIntervalInSeconds
              )
          ]
      )