{-# 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.CloudFront.Types.ContinuousDeploymentSingleWeightConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudFront.Types.ContinuousDeploymentSingleWeightConfig where

import Amazonka.CloudFront.Types.SessionStickinessConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Contains the percentage of traffic to send to a staging distribution.
--
-- /See:/ 'newContinuousDeploymentSingleWeightConfig' smart constructor.
data ContinuousDeploymentSingleWeightConfig = ContinuousDeploymentSingleWeightConfig'
  { ContinuousDeploymentSingleWeightConfig
-> Maybe SessionStickinessConfig
sessionStickinessConfig :: Prelude.Maybe SessionStickinessConfig,
    -- | The percentage of traffic to send to a staging distribution, expressed
    -- as a decimal number between 0 and .15.
    ContinuousDeploymentSingleWeightConfig -> Double
weight :: Prelude.Double
  }
  deriving (ContinuousDeploymentSingleWeightConfig
-> ContinuousDeploymentSingleWeightConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContinuousDeploymentSingleWeightConfig
-> ContinuousDeploymentSingleWeightConfig -> Bool
$c/= :: ContinuousDeploymentSingleWeightConfig
-> ContinuousDeploymentSingleWeightConfig -> Bool
== :: ContinuousDeploymentSingleWeightConfig
-> ContinuousDeploymentSingleWeightConfig -> Bool
$c== :: ContinuousDeploymentSingleWeightConfig
-> ContinuousDeploymentSingleWeightConfig -> Bool
Prelude.Eq, ReadPrec [ContinuousDeploymentSingleWeightConfig]
ReadPrec ContinuousDeploymentSingleWeightConfig
Int -> ReadS ContinuousDeploymentSingleWeightConfig
ReadS [ContinuousDeploymentSingleWeightConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContinuousDeploymentSingleWeightConfig]
$creadListPrec :: ReadPrec [ContinuousDeploymentSingleWeightConfig]
readPrec :: ReadPrec ContinuousDeploymentSingleWeightConfig
$creadPrec :: ReadPrec ContinuousDeploymentSingleWeightConfig
readList :: ReadS [ContinuousDeploymentSingleWeightConfig]
$creadList :: ReadS [ContinuousDeploymentSingleWeightConfig]
readsPrec :: Int -> ReadS ContinuousDeploymentSingleWeightConfig
$creadsPrec :: Int -> ReadS ContinuousDeploymentSingleWeightConfig
Prelude.Read, Int -> ContinuousDeploymentSingleWeightConfig -> ShowS
[ContinuousDeploymentSingleWeightConfig] -> ShowS
ContinuousDeploymentSingleWeightConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContinuousDeploymentSingleWeightConfig] -> ShowS
$cshowList :: [ContinuousDeploymentSingleWeightConfig] -> ShowS
show :: ContinuousDeploymentSingleWeightConfig -> String
$cshow :: ContinuousDeploymentSingleWeightConfig -> String
showsPrec :: Int -> ContinuousDeploymentSingleWeightConfig -> ShowS
$cshowsPrec :: Int -> ContinuousDeploymentSingleWeightConfig -> ShowS
Prelude.Show, forall x.
Rep ContinuousDeploymentSingleWeightConfig x
-> ContinuousDeploymentSingleWeightConfig
forall x.
ContinuousDeploymentSingleWeightConfig
-> Rep ContinuousDeploymentSingleWeightConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ContinuousDeploymentSingleWeightConfig x
-> ContinuousDeploymentSingleWeightConfig
$cfrom :: forall x.
ContinuousDeploymentSingleWeightConfig
-> Rep ContinuousDeploymentSingleWeightConfig x
Prelude.Generic)

-- |
-- Create a value of 'ContinuousDeploymentSingleWeightConfig' 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:
--
-- 'sessionStickinessConfig', 'continuousDeploymentSingleWeightConfig_sessionStickinessConfig' - Undocumented member.
--
-- 'weight', 'continuousDeploymentSingleWeightConfig_weight' - The percentage of traffic to send to a staging distribution, expressed
-- as a decimal number between 0 and .15.
newContinuousDeploymentSingleWeightConfig ::
  -- | 'weight'
  Prelude.Double ->
  ContinuousDeploymentSingleWeightConfig
newContinuousDeploymentSingleWeightConfig :: Double -> ContinuousDeploymentSingleWeightConfig
newContinuousDeploymentSingleWeightConfig Double
pWeight_ =
  ContinuousDeploymentSingleWeightConfig'
    { $sel:sessionStickinessConfig:ContinuousDeploymentSingleWeightConfig' :: Maybe SessionStickinessConfig
sessionStickinessConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:weight:ContinuousDeploymentSingleWeightConfig' :: Double
weight = Double
pWeight_
    }

-- | Undocumented member.
continuousDeploymentSingleWeightConfig_sessionStickinessConfig :: Lens.Lens' ContinuousDeploymentSingleWeightConfig (Prelude.Maybe SessionStickinessConfig)
continuousDeploymentSingleWeightConfig_sessionStickinessConfig :: Lens'
  ContinuousDeploymentSingleWeightConfig
  (Maybe SessionStickinessConfig)
continuousDeploymentSingleWeightConfig_sessionStickinessConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousDeploymentSingleWeightConfig' {Maybe SessionStickinessConfig
sessionStickinessConfig :: Maybe SessionStickinessConfig
$sel:sessionStickinessConfig:ContinuousDeploymentSingleWeightConfig' :: ContinuousDeploymentSingleWeightConfig
-> Maybe SessionStickinessConfig
sessionStickinessConfig} -> Maybe SessionStickinessConfig
sessionStickinessConfig) (\s :: ContinuousDeploymentSingleWeightConfig
s@ContinuousDeploymentSingleWeightConfig' {} Maybe SessionStickinessConfig
a -> ContinuousDeploymentSingleWeightConfig
s {$sel:sessionStickinessConfig:ContinuousDeploymentSingleWeightConfig' :: Maybe SessionStickinessConfig
sessionStickinessConfig = Maybe SessionStickinessConfig
a} :: ContinuousDeploymentSingleWeightConfig)

-- | The percentage of traffic to send to a staging distribution, expressed
-- as a decimal number between 0 and .15.
continuousDeploymentSingleWeightConfig_weight :: Lens.Lens' ContinuousDeploymentSingleWeightConfig Prelude.Double
continuousDeploymentSingleWeightConfig_weight :: Lens' ContinuousDeploymentSingleWeightConfig Double
continuousDeploymentSingleWeightConfig_weight = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContinuousDeploymentSingleWeightConfig' {Double
weight :: Double
$sel:weight:ContinuousDeploymentSingleWeightConfig' :: ContinuousDeploymentSingleWeightConfig -> Double
weight} -> Double
weight) (\s :: ContinuousDeploymentSingleWeightConfig
s@ContinuousDeploymentSingleWeightConfig' {} Double
a -> ContinuousDeploymentSingleWeightConfig
s {$sel:weight:ContinuousDeploymentSingleWeightConfig' :: Double
weight = Double
a} :: ContinuousDeploymentSingleWeightConfig)

instance
  Data.FromXML
    ContinuousDeploymentSingleWeightConfig
  where
  parseXML :: [Node] -> Either String ContinuousDeploymentSingleWeightConfig
parseXML [Node]
x =
    Maybe SessionStickinessConfig
-> Double -> ContinuousDeploymentSingleWeightConfig
ContinuousDeploymentSingleWeightConfig'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"SessionStickinessConfig")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Weight")

instance
  Prelude.Hashable
    ContinuousDeploymentSingleWeightConfig
  where
  hashWithSalt :: Int -> ContinuousDeploymentSingleWeightConfig -> Int
hashWithSalt
    Int
_salt
    ContinuousDeploymentSingleWeightConfig' {Double
Maybe SessionStickinessConfig
weight :: Double
sessionStickinessConfig :: Maybe SessionStickinessConfig
$sel:weight:ContinuousDeploymentSingleWeightConfig' :: ContinuousDeploymentSingleWeightConfig -> Double
$sel:sessionStickinessConfig:ContinuousDeploymentSingleWeightConfig' :: ContinuousDeploymentSingleWeightConfig
-> Maybe SessionStickinessConfig
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SessionStickinessConfig
sessionStickinessConfig
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
weight

instance
  Prelude.NFData
    ContinuousDeploymentSingleWeightConfig
  where
  rnf :: ContinuousDeploymentSingleWeightConfig -> ()
rnf ContinuousDeploymentSingleWeightConfig' {Double
Maybe SessionStickinessConfig
weight :: Double
sessionStickinessConfig :: Maybe SessionStickinessConfig
$sel:weight:ContinuousDeploymentSingleWeightConfig' :: ContinuousDeploymentSingleWeightConfig -> Double
$sel:sessionStickinessConfig:ContinuousDeploymentSingleWeightConfig' :: ContinuousDeploymentSingleWeightConfig
-> Maybe SessionStickinessConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SessionStickinessConfig
sessionStickinessConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
weight

instance
  Data.ToXML
    ContinuousDeploymentSingleWeightConfig
  where
  toXML :: ContinuousDeploymentSingleWeightConfig -> XML
toXML ContinuousDeploymentSingleWeightConfig' {Double
Maybe SessionStickinessConfig
weight :: Double
sessionStickinessConfig :: Maybe SessionStickinessConfig
$sel:weight:ContinuousDeploymentSingleWeightConfig' :: ContinuousDeploymentSingleWeightConfig -> Double
$sel:sessionStickinessConfig:ContinuousDeploymentSingleWeightConfig' :: ContinuousDeploymentSingleWeightConfig
-> Maybe SessionStickinessConfig
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"SessionStickinessConfig"
          forall a. ToXML a => Name -> a -> XML
Data.@= Maybe SessionStickinessConfig
sessionStickinessConfig,
        Name
"Weight" forall a. ToXML a => Name -> a -> XML
Data.@= Double
weight
      ]