{-# 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.SecurityHub.Types.AwsApiGatewayCanarySettings
-- 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.SecurityHub.Types.AwsApiGatewayCanarySettings where

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

-- | Contains information about settings for canary deployment in the stage.
--
-- /See:/ 'newAwsApiGatewayCanarySettings' smart constructor.
data AwsApiGatewayCanarySettings = AwsApiGatewayCanarySettings'
  { -- | The deployment identifier for the canary deployment.
    AwsApiGatewayCanarySettings -> Maybe Text
deploymentId :: Prelude.Maybe Prelude.Text,
    -- | Stage variables that are overridden in the canary release deployment.
    -- The variables include new stage variables that are introduced in the
    -- canary.
    --
    -- Each variable is represented as a string-to-string map between the stage
    -- variable name and the variable value.
    AwsApiGatewayCanarySettings -> Maybe (HashMap Text Text)
stageVariableOverrides :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Indicates whether the canary deployment uses the stage cache.
    AwsApiGatewayCanarySettings -> Maybe Bool
useStageCache :: Prelude.Maybe Prelude.Bool,
    -- | The percentage of traffic that is diverted to a canary deployment.
    AwsApiGatewayCanarySettings -> Maybe Double
percentTraffic :: Prelude.Maybe Prelude.Double
  }
  deriving (AwsApiGatewayCanarySettings -> AwsApiGatewayCanarySettings -> Bool
(AwsApiGatewayCanarySettings
 -> AwsApiGatewayCanarySettings -> Bool)
-> (AwsApiGatewayCanarySettings
    -> AwsApiGatewayCanarySettings -> Bool)
-> Eq AwsApiGatewayCanarySettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsApiGatewayCanarySettings -> AwsApiGatewayCanarySettings -> Bool
$c/= :: AwsApiGatewayCanarySettings -> AwsApiGatewayCanarySettings -> Bool
== :: AwsApiGatewayCanarySettings -> AwsApiGatewayCanarySettings -> Bool
$c== :: AwsApiGatewayCanarySettings -> AwsApiGatewayCanarySettings -> Bool
Prelude.Eq, ReadPrec [AwsApiGatewayCanarySettings]
ReadPrec AwsApiGatewayCanarySettings
Int -> ReadS AwsApiGatewayCanarySettings
ReadS [AwsApiGatewayCanarySettings]
(Int -> ReadS AwsApiGatewayCanarySettings)
-> ReadS [AwsApiGatewayCanarySettings]
-> ReadPrec AwsApiGatewayCanarySettings
-> ReadPrec [AwsApiGatewayCanarySettings]
-> Read AwsApiGatewayCanarySettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsApiGatewayCanarySettings]
$creadListPrec :: ReadPrec [AwsApiGatewayCanarySettings]
readPrec :: ReadPrec AwsApiGatewayCanarySettings
$creadPrec :: ReadPrec AwsApiGatewayCanarySettings
readList :: ReadS [AwsApiGatewayCanarySettings]
$creadList :: ReadS [AwsApiGatewayCanarySettings]
readsPrec :: Int -> ReadS AwsApiGatewayCanarySettings
$creadsPrec :: Int -> ReadS AwsApiGatewayCanarySettings
Prelude.Read, Int -> AwsApiGatewayCanarySettings -> ShowS
[AwsApiGatewayCanarySettings] -> ShowS
AwsApiGatewayCanarySettings -> String
(Int -> AwsApiGatewayCanarySettings -> ShowS)
-> (AwsApiGatewayCanarySettings -> String)
-> ([AwsApiGatewayCanarySettings] -> ShowS)
-> Show AwsApiGatewayCanarySettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsApiGatewayCanarySettings] -> ShowS
$cshowList :: [AwsApiGatewayCanarySettings] -> ShowS
show :: AwsApiGatewayCanarySettings -> String
$cshow :: AwsApiGatewayCanarySettings -> String
showsPrec :: Int -> AwsApiGatewayCanarySettings -> ShowS
$cshowsPrec :: Int -> AwsApiGatewayCanarySettings -> ShowS
Prelude.Show, (forall x.
 AwsApiGatewayCanarySettings -> Rep AwsApiGatewayCanarySettings x)
-> (forall x.
    Rep AwsApiGatewayCanarySettings x -> AwsApiGatewayCanarySettings)
-> Generic AwsApiGatewayCanarySettings
forall x.
Rep AwsApiGatewayCanarySettings x -> AwsApiGatewayCanarySettings
forall x.
AwsApiGatewayCanarySettings -> Rep AwsApiGatewayCanarySettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsApiGatewayCanarySettings x -> AwsApiGatewayCanarySettings
$cfrom :: forall x.
AwsApiGatewayCanarySettings -> Rep AwsApiGatewayCanarySettings x
Prelude.Generic)

-- |
-- Create a value of 'AwsApiGatewayCanarySettings' 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:
--
-- 'deploymentId', 'awsApiGatewayCanarySettings_deploymentId' - The deployment identifier for the canary deployment.
--
-- 'stageVariableOverrides', 'awsApiGatewayCanarySettings_stageVariableOverrides' - Stage variables that are overridden in the canary release deployment.
-- The variables include new stage variables that are introduced in the
-- canary.
--
-- Each variable is represented as a string-to-string map between the stage
-- variable name and the variable value.
--
-- 'useStageCache', 'awsApiGatewayCanarySettings_useStageCache' - Indicates whether the canary deployment uses the stage cache.
--
-- 'percentTraffic', 'awsApiGatewayCanarySettings_percentTraffic' - The percentage of traffic that is diverted to a canary deployment.
newAwsApiGatewayCanarySettings ::
  AwsApiGatewayCanarySettings
newAwsApiGatewayCanarySettings :: AwsApiGatewayCanarySettings
newAwsApiGatewayCanarySettings =
  AwsApiGatewayCanarySettings' :: Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Bool
-> Maybe Double
-> AwsApiGatewayCanarySettings
AwsApiGatewayCanarySettings'
    { $sel:deploymentId:AwsApiGatewayCanarySettings' :: Maybe Text
deploymentId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stageVariableOverrides:AwsApiGatewayCanarySettings' :: Maybe (HashMap Text Text)
stageVariableOverrides = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:useStageCache:AwsApiGatewayCanarySettings' :: Maybe Bool
useStageCache = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:percentTraffic:AwsApiGatewayCanarySettings' :: Maybe Double
percentTraffic = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The deployment identifier for the canary deployment.
awsApiGatewayCanarySettings_deploymentId :: Lens.Lens' AwsApiGatewayCanarySettings (Prelude.Maybe Prelude.Text)
awsApiGatewayCanarySettings_deploymentId :: (Maybe Text -> f (Maybe Text))
-> AwsApiGatewayCanarySettings -> f AwsApiGatewayCanarySettings
awsApiGatewayCanarySettings_deploymentId = (AwsApiGatewayCanarySettings -> Maybe Text)
-> (AwsApiGatewayCanarySettings
    -> Maybe Text -> AwsApiGatewayCanarySettings)
-> Lens
     AwsApiGatewayCanarySettings
     AwsApiGatewayCanarySettings
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiGatewayCanarySettings' {Maybe Text
deploymentId :: Maybe Text
$sel:deploymentId:AwsApiGatewayCanarySettings' :: AwsApiGatewayCanarySettings -> Maybe Text
deploymentId} -> Maybe Text
deploymentId) (\s :: AwsApiGatewayCanarySettings
s@AwsApiGatewayCanarySettings' {} Maybe Text
a -> AwsApiGatewayCanarySettings
s {$sel:deploymentId:AwsApiGatewayCanarySettings' :: Maybe Text
deploymentId = Maybe Text
a} :: AwsApiGatewayCanarySettings)

-- | Stage variables that are overridden in the canary release deployment.
-- The variables include new stage variables that are introduced in the
-- canary.
--
-- Each variable is represented as a string-to-string map between the stage
-- variable name and the variable value.
awsApiGatewayCanarySettings_stageVariableOverrides :: Lens.Lens' AwsApiGatewayCanarySettings (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
awsApiGatewayCanarySettings_stageVariableOverrides :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> AwsApiGatewayCanarySettings -> f AwsApiGatewayCanarySettings
awsApiGatewayCanarySettings_stageVariableOverrides = (AwsApiGatewayCanarySettings -> Maybe (HashMap Text Text))
-> (AwsApiGatewayCanarySettings
    -> Maybe (HashMap Text Text) -> AwsApiGatewayCanarySettings)
-> Lens
     AwsApiGatewayCanarySettings
     AwsApiGatewayCanarySettings
     (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 (\AwsApiGatewayCanarySettings' {Maybe (HashMap Text Text)
stageVariableOverrides :: Maybe (HashMap Text Text)
$sel:stageVariableOverrides:AwsApiGatewayCanarySettings' :: AwsApiGatewayCanarySettings -> Maybe (HashMap Text Text)
stageVariableOverrides} -> Maybe (HashMap Text Text)
stageVariableOverrides) (\s :: AwsApiGatewayCanarySettings
s@AwsApiGatewayCanarySettings' {} Maybe (HashMap Text Text)
a -> AwsApiGatewayCanarySettings
s {$sel:stageVariableOverrides:AwsApiGatewayCanarySettings' :: Maybe (HashMap Text Text)
stageVariableOverrides = Maybe (HashMap Text Text)
a} :: AwsApiGatewayCanarySettings) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> AwsApiGatewayCanarySettings -> f AwsApiGatewayCanarySettings)
-> ((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)))
-> AwsApiGatewayCanarySettings
-> f AwsApiGatewayCanarySettings
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

-- | Indicates whether the canary deployment uses the stage cache.
awsApiGatewayCanarySettings_useStageCache :: Lens.Lens' AwsApiGatewayCanarySettings (Prelude.Maybe Prelude.Bool)
awsApiGatewayCanarySettings_useStageCache :: (Maybe Bool -> f (Maybe Bool))
-> AwsApiGatewayCanarySettings -> f AwsApiGatewayCanarySettings
awsApiGatewayCanarySettings_useStageCache = (AwsApiGatewayCanarySettings -> Maybe Bool)
-> (AwsApiGatewayCanarySettings
    -> Maybe Bool -> AwsApiGatewayCanarySettings)
-> Lens
     AwsApiGatewayCanarySettings
     AwsApiGatewayCanarySettings
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiGatewayCanarySettings' {Maybe Bool
useStageCache :: Maybe Bool
$sel:useStageCache:AwsApiGatewayCanarySettings' :: AwsApiGatewayCanarySettings -> Maybe Bool
useStageCache} -> Maybe Bool
useStageCache) (\s :: AwsApiGatewayCanarySettings
s@AwsApiGatewayCanarySettings' {} Maybe Bool
a -> AwsApiGatewayCanarySettings
s {$sel:useStageCache:AwsApiGatewayCanarySettings' :: Maybe Bool
useStageCache = Maybe Bool
a} :: AwsApiGatewayCanarySettings)

-- | The percentage of traffic that is diverted to a canary deployment.
awsApiGatewayCanarySettings_percentTraffic :: Lens.Lens' AwsApiGatewayCanarySettings (Prelude.Maybe Prelude.Double)
awsApiGatewayCanarySettings_percentTraffic :: (Maybe Double -> f (Maybe Double))
-> AwsApiGatewayCanarySettings -> f AwsApiGatewayCanarySettings
awsApiGatewayCanarySettings_percentTraffic = (AwsApiGatewayCanarySettings -> Maybe Double)
-> (AwsApiGatewayCanarySettings
    -> Maybe Double -> AwsApiGatewayCanarySettings)
-> Lens
     AwsApiGatewayCanarySettings
     AwsApiGatewayCanarySettings
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsApiGatewayCanarySettings' {Maybe Double
percentTraffic :: Maybe Double
$sel:percentTraffic:AwsApiGatewayCanarySettings' :: AwsApiGatewayCanarySettings -> Maybe Double
percentTraffic} -> Maybe Double
percentTraffic) (\s :: AwsApiGatewayCanarySettings
s@AwsApiGatewayCanarySettings' {} Maybe Double
a -> AwsApiGatewayCanarySettings
s {$sel:percentTraffic:AwsApiGatewayCanarySettings' :: Maybe Double
percentTraffic = Maybe Double
a} :: AwsApiGatewayCanarySettings)

instance Core.FromJSON AwsApiGatewayCanarySettings where
  parseJSON :: Value -> Parser AwsApiGatewayCanarySettings
parseJSON =
    String
-> (Object -> Parser AwsApiGatewayCanarySettings)
-> Value
-> Parser AwsApiGatewayCanarySettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsApiGatewayCanarySettings"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Bool
-> Maybe Double
-> AwsApiGatewayCanarySettings
AwsApiGatewayCanarySettings'
            (Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe Bool
 -> Maybe Double
 -> AwsApiGatewayCanarySettings)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe Bool -> Maybe Double -> AwsApiGatewayCanarySettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeploymentId")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe Bool -> Maybe Double -> AwsApiGatewayCanarySettings)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe Bool -> Maybe Double -> AwsApiGatewayCanarySettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StageVariableOverrides"
                            Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Bool -> Maybe Double -> AwsApiGatewayCanarySettings)
-> Parser (Maybe Bool)
-> Parser (Maybe Double -> AwsApiGatewayCanarySettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UseStageCache")
            Parser (Maybe Double -> AwsApiGatewayCanarySettings)
-> Parser (Maybe Double) -> Parser AwsApiGatewayCanarySettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PercentTraffic")
      )

instance Prelude.Hashable AwsApiGatewayCanarySettings

instance Prelude.NFData AwsApiGatewayCanarySettings

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