{-# 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.AwsElbLbCookieStickinessPolicy
-- 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.AwsElbLbCookieStickinessPolicy where

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

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

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

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

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

instance Core.FromJSON AwsElbLbCookieStickinessPolicy where
  parseJSON :: Value -> Parser AwsElbLbCookieStickinessPolicy
parseJSON =
    String
-> (Object -> Parser AwsElbLbCookieStickinessPolicy)
-> Value
-> Parser AwsElbLbCookieStickinessPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsElbLbCookieStickinessPolicy"
      ( \Object
x ->
          Maybe Text -> Maybe Integer -> AwsElbLbCookieStickinessPolicy
AwsElbLbCookieStickinessPolicy'
            (Maybe Text -> Maybe Integer -> AwsElbLbCookieStickinessPolicy)
-> Parser (Maybe Text)
-> Parser (Maybe Integer -> AwsElbLbCookieStickinessPolicy)
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
"PolicyName")
            Parser (Maybe Integer -> AwsElbLbCookieStickinessPolicy)
-> Parser (Maybe Integer) -> Parser AwsElbLbCookieStickinessPolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CookieExpirationPeriod")
      )

instance
  Prelude.Hashable
    AwsElbLbCookieStickinessPolicy

instance
  Prelude.NFData
    AwsElbLbCookieStickinessPolicy

instance Core.ToJSON AwsElbLbCookieStickinessPolicy where
  toJSON :: AwsElbLbCookieStickinessPolicy -> Value
toJSON AwsElbLbCookieStickinessPolicy' {Maybe Integer
Maybe Text
cookieExpirationPeriod :: Maybe Integer
policyName :: Maybe Text
$sel:cookieExpirationPeriod:AwsElbLbCookieStickinessPolicy' :: AwsElbLbCookieStickinessPolicy -> Maybe Integer
$sel:policyName:AwsElbLbCookieStickinessPolicy' :: AwsElbLbCookieStickinessPolicy -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PolicyName" 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
policyName,
            (Text
"CookieExpirationPeriod" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
cookieExpirationPeriod
          ]
      )