{-# 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.ELB.Types.LBCookieStickinessPolicy
-- 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.ELB.Types.LBCookieStickinessPolicy where

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

-- | Information about a policy for duration-based session stickiness.
--
-- /See:/ 'newLBCookieStickinessPolicy' smart constructor.
data LBCookieStickinessPolicy = LBCookieStickinessPolicy'
  { -- | The name of the policy. This name must be unique within the set of
    -- policies for this load balancer.
    LBCookieStickinessPolicy -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text,
    -- | The time period, in seconds, after which the cookie should be considered
    -- stale. If this parameter is not specified, the stickiness session lasts
    -- for the duration of the browser session.
    LBCookieStickinessPolicy -> Maybe Integer
cookieExpirationPeriod :: Prelude.Maybe Prelude.Integer
  }
  deriving (LBCookieStickinessPolicy -> LBCookieStickinessPolicy -> Bool
(LBCookieStickinessPolicy -> LBCookieStickinessPolicy -> Bool)
-> (LBCookieStickinessPolicy -> LBCookieStickinessPolicy -> Bool)
-> Eq LBCookieStickinessPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LBCookieStickinessPolicy -> LBCookieStickinessPolicy -> Bool
$c/= :: LBCookieStickinessPolicy -> LBCookieStickinessPolicy -> Bool
== :: LBCookieStickinessPolicy -> LBCookieStickinessPolicy -> Bool
$c== :: LBCookieStickinessPolicy -> LBCookieStickinessPolicy -> Bool
Prelude.Eq, ReadPrec [LBCookieStickinessPolicy]
ReadPrec LBCookieStickinessPolicy
Int -> ReadS LBCookieStickinessPolicy
ReadS [LBCookieStickinessPolicy]
(Int -> ReadS LBCookieStickinessPolicy)
-> ReadS [LBCookieStickinessPolicy]
-> ReadPrec LBCookieStickinessPolicy
-> ReadPrec [LBCookieStickinessPolicy]
-> Read LBCookieStickinessPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LBCookieStickinessPolicy]
$creadListPrec :: ReadPrec [LBCookieStickinessPolicy]
readPrec :: ReadPrec LBCookieStickinessPolicy
$creadPrec :: ReadPrec LBCookieStickinessPolicy
readList :: ReadS [LBCookieStickinessPolicy]
$creadList :: ReadS [LBCookieStickinessPolicy]
readsPrec :: Int -> ReadS LBCookieStickinessPolicy
$creadsPrec :: Int -> ReadS LBCookieStickinessPolicy
Prelude.Read, Int -> LBCookieStickinessPolicy -> ShowS
[LBCookieStickinessPolicy] -> ShowS
LBCookieStickinessPolicy -> String
(Int -> LBCookieStickinessPolicy -> ShowS)
-> (LBCookieStickinessPolicy -> String)
-> ([LBCookieStickinessPolicy] -> ShowS)
-> Show LBCookieStickinessPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LBCookieStickinessPolicy] -> ShowS
$cshowList :: [LBCookieStickinessPolicy] -> ShowS
show :: LBCookieStickinessPolicy -> String
$cshow :: LBCookieStickinessPolicy -> String
showsPrec :: Int -> LBCookieStickinessPolicy -> ShowS
$cshowsPrec :: Int -> LBCookieStickinessPolicy -> ShowS
Prelude.Show, (forall x.
 LBCookieStickinessPolicy -> Rep LBCookieStickinessPolicy x)
-> (forall x.
    Rep LBCookieStickinessPolicy x -> LBCookieStickinessPolicy)
-> Generic LBCookieStickinessPolicy
forall x.
Rep LBCookieStickinessPolicy x -> LBCookieStickinessPolicy
forall x.
LBCookieStickinessPolicy -> Rep LBCookieStickinessPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LBCookieStickinessPolicy x -> LBCookieStickinessPolicy
$cfrom :: forall x.
LBCookieStickinessPolicy -> Rep LBCookieStickinessPolicy x
Prelude.Generic)

-- |
-- Create a value of 'LBCookieStickinessPolicy' 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:
--
-- 'policyName', 'lBCookieStickinessPolicy_policyName' - The name of the policy. This name must be unique within the set of
-- policies for this load balancer.
--
-- 'cookieExpirationPeriod', 'lBCookieStickinessPolicy_cookieExpirationPeriod' - The time period, in seconds, after which the cookie should be considered
-- stale. If this parameter is not specified, the stickiness session lasts
-- for the duration of the browser session.
newLBCookieStickinessPolicy ::
  LBCookieStickinessPolicy
newLBCookieStickinessPolicy :: LBCookieStickinessPolicy
newLBCookieStickinessPolicy =
  LBCookieStickinessPolicy' :: Maybe Text -> Maybe Integer -> LBCookieStickinessPolicy
LBCookieStickinessPolicy'
    { $sel:policyName:LBCookieStickinessPolicy' :: Maybe Text
policyName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:cookieExpirationPeriod:LBCookieStickinessPolicy' :: Maybe Integer
cookieExpirationPeriod = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the policy. This name must be unique within the set of
-- policies for this load balancer.
lBCookieStickinessPolicy_policyName :: Lens.Lens' LBCookieStickinessPolicy (Prelude.Maybe Prelude.Text)
lBCookieStickinessPolicy_policyName :: (Maybe Text -> f (Maybe Text))
-> LBCookieStickinessPolicy -> f LBCookieStickinessPolicy
lBCookieStickinessPolicy_policyName = (LBCookieStickinessPolicy -> Maybe Text)
-> (LBCookieStickinessPolicy
    -> Maybe Text -> LBCookieStickinessPolicy)
-> Lens
     LBCookieStickinessPolicy
     LBCookieStickinessPolicy
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LBCookieStickinessPolicy' {Maybe Text
policyName :: Maybe Text
$sel:policyName:LBCookieStickinessPolicy' :: LBCookieStickinessPolicy -> Maybe Text
policyName} -> Maybe Text
policyName) (\s :: LBCookieStickinessPolicy
s@LBCookieStickinessPolicy' {} Maybe Text
a -> LBCookieStickinessPolicy
s {$sel:policyName:LBCookieStickinessPolicy' :: Maybe Text
policyName = Maybe Text
a} :: LBCookieStickinessPolicy)

-- | The time period, in seconds, after which the cookie should be considered
-- stale. If this parameter is not specified, the stickiness session lasts
-- for the duration of the browser session.
lBCookieStickinessPolicy_cookieExpirationPeriod :: Lens.Lens' LBCookieStickinessPolicy (Prelude.Maybe Prelude.Integer)
lBCookieStickinessPolicy_cookieExpirationPeriod :: (Maybe Integer -> f (Maybe Integer))
-> LBCookieStickinessPolicy -> f LBCookieStickinessPolicy
lBCookieStickinessPolicy_cookieExpirationPeriod = (LBCookieStickinessPolicy -> Maybe Integer)
-> (LBCookieStickinessPolicy
    -> Maybe Integer -> LBCookieStickinessPolicy)
-> Lens
     LBCookieStickinessPolicy
     LBCookieStickinessPolicy
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LBCookieStickinessPolicy' {Maybe Integer
cookieExpirationPeriod :: Maybe Integer
$sel:cookieExpirationPeriod:LBCookieStickinessPolicy' :: LBCookieStickinessPolicy -> Maybe Integer
cookieExpirationPeriod} -> Maybe Integer
cookieExpirationPeriod) (\s :: LBCookieStickinessPolicy
s@LBCookieStickinessPolicy' {} Maybe Integer
a -> LBCookieStickinessPolicy
s {$sel:cookieExpirationPeriod:LBCookieStickinessPolicy' :: Maybe Integer
cookieExpirationPeriod = Maybe Integer
a} :: LBCookieStickinessPolicy)

instance Core.FromXML LBCookieStickinessPolicy where
  parseXML :: [Node] -> Either String LBCookieStickinessPolicy
parseXML [Node]
x =
    Maybe Text -> Maybe Integer -> LBCookieStickinessPolicy
LBCookieStickinessPolicy'
      (Maybe Text -> Maybe Integer -> LBCookieStickinessPolicy)
-> Either String (Maybe Text)
-> Either String (Maybe Integer -> LBCookieStickinessPolicy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PolicyName")
      Either String (Maybe Integer -> LBCookieStickinessPolicy)
-> Either String (Maybe Integer)
-> Either String LBCookieStickinessPolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Integer)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CookieExpirationPeriod")

instance Prelude.Hashable LBCookieStickinessPolicy

instance Prelude.NFData LBCookieStickinessPolicy