{-# 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.APIGateway.Types.DeploymentCanarySettings
-- 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.APIGateway.Types.DeploymentCanarySettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The input configuration for a canary deployment.
--
-- /See:/ 'newDeploymentCanarySettings' smart constructor.
data DeploymentCanarySettings = DeploymentCanarySettings'
  { -- | A stage variable overrides used for the canary release deployment. They
    -- can override existing stage variables or add new stage variables for the
    -- canary release deployment. These stage variables are represented as a
    -- string-to-string map between stage variable names and their values.
    DeploymentCanarySettings -> Maybe (HashMap Text Text)
stageVariableOverrides :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A Boolean flag to indicate whether the canary release deployment uses
    -- the stage cache or not.
    DeploymentCanarySettings -> Maybe Bool
useStageCache :: Prelude.Maybe Prelude.Bool,
    -- | The percentage (0.0-100.0) of traffic routed to the canary deployment.
    DeploymentCanarySettings -> Maybe Double
percentTraffic :: Prelude.Maybe Prelude.Double
  }
  deriving (DeploymentCanarySettings -> DeploymentCanarySettings -> Bool
(DeploymentCanarySettings -> DeploymentCanarySettings -> Bool)
-> (DeploymentCanarySettings -> DeploymentCanarySettings -> Bool)
-> Eq DeploymentCanarySettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeploymentCanarySettings -> DeploymentCanarySettings -> Bool
$c/= :: DeploymentCanarySettings -> DeploymentCanarySettings -> Bool
== :: DeploymentCanarySettings -> DeploymentCanarySettings -> Bool
$c== :: DeploymentCanarySettings -> DeploymentCanarySettings -> Bool
Prelude.Eq, ReadPrec [DeploymentCanarySettings]
ReadPrec DeploymentCanarySettings
Int -> ReadS DeploymentCanarySettings
ReadS [DeploymentCanarySettings]
(Int -> ReadS DeploymentCanarySettings)
-> ReadS [DeploymentCanarySettings]
-> ReadPrec DeploymentCanarySettings
-> ReadPrec [DeploymentCanarySettings]
-> Read DeploymentCanarySettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeploymentCanarySettings]
$creadListPrec :: ReadPrec [DeploymentCanarySettings]
readPrec :: ReadPrec DeploymentCanarySettings
$creadPrec :: ReadPrec DeploymentCanarySettings
readList :: ReadS [DeploymentCanarySettings]
$creadList :: ReadS [DeploymentCanarySettings]
readsPrec :: Int -> ReadS DeploymentCanarySettings
$creadsPrec :: Int -> ReadS DeploymentCanarySettings
Prelude.Read, Int -> DeploymentCanarySettings -> ShowS
[DeploymentCanarySettings] -> ShowS
DeploymentCanarySettings -> String
(Int -> DeploymentCanarySettings -> ShowS)
-> (DeploymentCanarySettings -> String)
-> ([DeploymentCanarySettings] -> ShowS)
-> Show DeploymentCanarySettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeploymentCanarySettings] -> ShowS
$cshowList :: [DeploymentCanarySettings] -> ShowS
show :: DeploymentCanarySettings -> String
$cshow :: DeploymentCanarySettings -> String
showsPrec :: Int -> DeploymentCanarySettings -> ShowS
$cshowsPrec :: Int -> DeploymentCanarySettings -> ShowS
Prelude.Show, (forall x.
 DeploymentCanarySettings -> Rep DeploymentCanarySettings x)
-> (forall x.
    Rep DeploymentCanarySettings x -> DeploymentCanarySettings)
-> Generic DeploymentCanarySettings
forall x.
Rep DeploymentCanarySettings x -> DeploymentCanarySettings
forall x.
DeploymentCanarySettings -> Rep DeploymentCanarySettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeploymentCanarySettings x -> DeploymentCanarySettings
$cfrom :: forall x.
DeploymentCanarySettings -> Rep DeploymentCanarySettings x
Prelude.Generic)

-- |
-- Create a value of 'DeploymentCanarySettings' 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:
--
-- 'stageVariableOverrides', 'deploymentCanarySettings_stageVariableOverrides' - A stage variable overrides used for the canary release deployment. They
-- can override existing stage variables or add new stage variables for the
-- canary release deployment. These stage variables are represented as a
-- string-to-string map between stage variable names and their values.
--
-- 'useStageCache', 'deploymentCanarySettings_useStageCache' - A Boolean flag to indicate whether the canary release deployment uses
-- the stage cache or not.
--
-- 'percentTraffic', 'deploymentCanarySettings_percentTraffic' - The percentage (0.0-100.0) of traffic routed to the canary deployment.
newDeploymentCanarySettings ::
  DeploymentCanarySettings
newDeploymentCanarySettings :: DeploymentCanarySettings
newDeploymentCanarySettings =
  DeploymentCanarySettings' :: Maybe (HashMap Text Text)
-> Maybe Bool -> Maybe Double -> DeploymentCanarySettings
DeploymentCanarySettings'
    { $sel:stageVariableOverrides:DeploymentCanarySettings' :: Maybe (HashMap Text Text)
stageVariableOverrides =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:useStageCache:DeploymentCanarySettings' :: Maybe Bool
useStageCache = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:percentTraffic:DeploymentCanarySettings' :: Maybe Double
percentTraffic = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | A stage variable overrides used for the canary release deployment. They
-- can override existing stage variables or add new stage variables for the
-- canary release deployment. These stage variables are represented as a
-- string-to-string map between stage variable names and their values.
deploymentCanarySettings_stageVariableOverrides :: Lens.Lens' DeploymentCanarySettings (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
deploymentCanarySettings_stageVariableOverrides :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DeploymentCanarySettings -> f DeploymentCanarySettings
deploymentCanarySettings_stageVariableOverrides = (DeploymentCanarySettings -> Maybe (HashMap Text Text))
-> (DeploymentCanarySettings
    -> Maybe (HashMap Text Text) -> DeploymentCanarySettings)
-> Lens
     DeploymentCanarySettings
     DeploymentCanarySettings
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentCanarySettings' {Maybe (HashMap Text Text)
stageVariableOverrides :: Maybe (HashMap Text Text)
$sel:stageVariableOverrides:DeploymentCanarySettings' :: DeploymentCanarySettings -> Maybe (HashMap Text Text)
stageVariableOverrides} -> Maybe (HashMap Text Text)
stageVariableOverrides) (\s :: DeploymentCanarySettings
s@DeploymentCanarySettings' {} Maybe (HashMap Text Text)
a -> DeploymentCanarySettings
s {$sel:stageVariableOverrides:DeploymentCanarySettings' :: Maybe (HashMap Text Text)
stageVariableOverrides = Maybe (HashMap Text Text)
a} :: DeploymentCanarySettings) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> DeploymentCanarySettings -> f DeploymentCanarySettings)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DeploymentCanarySettings
-> f DeploymentCanarySettings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A Boolean flag to indicate whether the canary release deployment uses
-- the stage cache or not.
deploymentCanarySettings_useStageCache :: Lens.Lens' DeploymentCanarySettings (Prelude.Maybe Prelude.Bool)
deploymentCanarySettings_useStageCache :: (Maybe Bool -> f (Maybe Bool))
-> DeploymentCanarySettings -> f DeploymentCanarySettings
deploymentCanarySettings_useStageCache = (DeploymentCanarySettings -> Maybe Bool)
-> (DeploymentCanarySettings
    -> Maybe Bool -> DeploymentCanarySettings)
-> Lens
     DeploymentCanarySettings
     DeploymentCanarySettings
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentCanarySettings' {Maybe Bool
useStageCache :: Maybe Bool
$sel:useStageCache:DeploymentCanarySettings' :: DeploymentCanarySettings -> Maybe Bool
useStageCache} -> Maybe Bool
useStageCache) (\s :: DeploymentCanarySettings
s@DeploymentCanarySettings' {} Maybe Bool
a -> DeploymentCanarySettings
s {$sel:useStageCache:DeploymentCanarySettings' :: Maybe Bool
useStageCache = Maybe Bool
a} :: DeploymentCanarySettings)

-- | The percentage (0.0-100.0) of traffic routed to the canary deployment.
deploymentCanarySettings_percentTraffic :: Lens.Lens' DeploymentCanarySettings (Prelude.Maybe Prelude.Double)
deploymentCanarySettings_percentTraffic :: (Maybe Double -> f (Maybe Double))
-> DeploymentCanarySettings -> f DeploymentCanarySettings
deploymentCanarySettings_percentTraffic = (DeploymentCanarySettings -> Maybe Double)
-> (DeploymentCanarySettings
    -> Maybe Double -> DeploymentCanarySettings)
-> Lens
     DeploymentCanarySettings
     DeploymentCanarySettings
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentCanarySettings' {Maybe Double
percentTraffic :: Maybe Double
$sel:percentTraffic:DeploymentCanarySettings' :: DeploymentCanarySettings -> Maybe Double
percentTraffic} -> Maybe Double
percentTraffic) (\s :: DeploymentCanarySettings
s@DeploymentCanarySettings' {} Maybe Double
a -> DeploymentCanarySettings
s {$sel:percentTraffic:DeploymentCanarySettings' :: Maybe Double
percentTraffic = Maybe Double
a} :: DeploymentCanarySettings)

instance Prelude.Hashable DeploymentCanarySettings

instance Prelude.NFData DeploymentCanarySettings

instance Core.ToJSON DeploymentCanarySettings where
  toJSON :: DeploymentCanarySettings -> Value
toJSON DeploymentCanarySettings' {Maybe Bool
Maybe Double
Maybe (HashMap Text Text)
percentTraffic :: Maybe Double
useStageCache :: Maybe Bool
stageVariableOverrides :: Maybe (HashMap Text Text)
$sel:percentTraffic:DeploymentCanarySettings' :: DeploymentCanarySettings -> Maybe Double
$sel:useStageCache:DeploymentCanarySettings' :: DeploymentCanarySettings -> Maybe Bool
$sel:stageVariableOverrides:DeploymentCanarySettings' :: DeploymentCanarySettings -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"stageVariableOverrides" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
stageVariableOverrides,
            (Text
"useStageCache" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
useStageCache,
            (Text
"percentTraffic" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
percentTraffic
          ]
      )