{-# 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.AwsElbAppCookieStickinessPolicy
-- 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.AwsElbAppCookieStickinessPolicy 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
-- @CreateAppCookieStickinessPolicy@.
--
-- /See:/ 'newAwsElbAppCookieStickinessPolicy' smart constructor.
data AwsElbAppCookieStickinessPolicy = AwsElbAppCookieStickinessPolicy'
  { -- | The mnemonic name for the policy being created. The name must be unique
    -- within the set of policies for the load balancer.
    AwsElbAppCookieStickinessPolicy -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text,
    -- | The name of the application cookie used for stickiness.
    AwsElbAppCookieStickinessPolicy -> Maybe Text
cookieName :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsElbAppCookieStickinessPolicy
-> AwsElbAppCookieStickinessPolicy -> Bool
(AwsElbAppCookieStickinessPolicy
 -> AwsElbAppCookieStickinessPolicy -> Bool)
-> (AwsElbAppCookieStickinessPolicy
    -> AwsElbAppCookieStickinessPolicy -> Bool)
-> Eq AwsElbAppCookieStickinessPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsElbAppCookieStickinessPolicy
-> AwsElbAppCookieStickinessPolicy -> Bool
$c/= :: AwsElbAppCookieStickinessPolicy
-> AwsElbAppCookieStickinessPolicy -> Bool
== :: AwsElbAppCookieStickinessPolicy
-> AwsElbAppCookieStickinessPolicy -> Bool
$c== :: AwsElbAppCookieStickinessPolicy
-> AwsElbAppCookieStickinessPolicy -> Bool
Prelude.Eq, ReadPrec [AwsElbAppCookieStickinessPolicy]
ReadPrec AwsElbAppCookieStickinessPolicy
Int -> ReadS AwsElbAppCookieStickinessPolicy
ReadS [AwsElbAppCookieStickinessPolicy]
(Int -> ReadS AwsElbAppCookieStickinessPolicy)
-> ReadS [AwsElbAppCookieStickinessPolicy]
-> ReadPrec AwsElbAppCookieStickinessPolicy
-> ReadPrec [AwsElbAppCookieStickinessPolicy]
-> Read AwsElbAppCookieStickinessPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsElbAppCookieStickinessPolicy]
$creadListPrec :: ReadPrec [AwsElbAppCookieStickinessPolicy]
readPrec :: ReadPrec AwsElbAppCookieStickinessPolicy
$creadPrec :: ReadPrec AwsElbAppCookieStickinessPolicy
readList :: ReadS [AwsElbAppCookieStickinessPolicy]
$creadList :: ReadS [AwsElbAppCookieStickinessPolicy]
readsPrec :: Int -> ReadS AwsElbAppCookieStickinessPolicy
$creadsPrec :: Int -> ReadS AwsElbAppCookieStickinessPolicy
Prelude.Read, Int -> AwsElbAppCookieStickinessPolicy -> ShowS
[AwsElbAppCookieStickinessPolicy] -> ShowS
AwsElbAppCookieStickinessPolicy -> String
(Int -> AwsElbAppCookieStickinessPolicy -> ShowS)
-> (AwsElbAppCookieStickinessPolicy -> String)
-> ([AwsElbAppCookieStickinessPolicy] -> ShowS)
-> Show AwsElbAppCookieStickinessPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsElbAppCookieStickinessPolicy] -> ShowS
$cshowList :: [AwsElbAppCookieStickinessPolicy] -> ShowS
show :: AwsElbAppCookieStickinessPolicy -> String
$cshow :: AwsElbAppCookieStickinessPolicy -> String
showsPrec :: Int -> AwsElbAppCookieStickinessPolicy -> ShowS
$cshowsPrec :: Int -> AwsElbAppCookieStickinessPolicy -> ShowS
Prelude.Show, (forall x.
 AwsElbAppCookieStickinessPolicy
 -> Rep AwsElbAppCookieStickinessPolicy x)
-> (forall x.
    Rep AwsElbAppCookieStickinessPolicy x
    -> AwsElbAppCookieStickinessPolicy)
-> Generic AwsElbAppCookieStickinessPolicy
forall x.
Rep AwsElbAppCookieStickinessPolicy x
-> AwsElbAppCookieStickinessPolicy
forall x.
AwsElbAppCookieStickinessPolicy
-> Rep AwsElbAppCookieStickinessPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsElbAppCookieStickinessPolicy x
-> AwsElbAppCookieStickinessPolicy
$cfrom :: forall x.
AwsElbAppCookieStickinessPolicy
-> Rep AwsElbAppCookieStickinessPolicy x
Prelude.Generic)

-- |
-- Create a value of 'AwsElbAppCookieStickinessPolicy' 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', 'awsElbAppCookieStickinessPolicy_policyName' - The mnemonic name for the policy being created. The name must be unique
-- within the set of policies for the load balancer.
--
-- 'cookieName', 'awsElbAppCookieStickinessPolicy_cookieName' - The name of the application cookie used for stickiness.
newAwsElbAppCookieStickinessPolicy ::
  AwsElbAppCookieStickinessPolicy
newAwsElbAppCookieStickinessPolicy :: AwsElbAppCookieStickinessPolicy
newAwsElbAppCookieStickinessPolicy =
  AwsElbAppCookieStickinessPolicy' :: Maybe Text -> Maybe Text -> AwsElbAppCookieStickinessPolicy
AwsElbAppCookieStickinessPolicy'
    { $sel:policyName:AwsElbAppCookieStickinessPolicy' :: Maybe Text
policyName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:cookieName:AwsElbAppCookieStickinessPolicy' :: Maybe Text
cookieName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The name of the application cookie used for stickiness.
awsElbAppCookieStickinessPolicy_cookieName :: Lens.Lens' AwsElbAppCookieStickinessPolicy (Prelude.Maybe Prelude.Text)
awsElbAppCookieStickinessPolicy_cookieName :: (Maybe Text -> f (Maybe Text))
-> AwsElbAppCookieStickinessPolicy
-> f AwsElbAppCookieStickinessPolicy
awsElbAppCookieStickinessPolicy_cookieName = (AwsElbAppCookieStickinessPolicy -> Maybe Text)
-> (AwsElbAppCookieStickinessPolicy
    -> Maybe Text -> AwsElbAppCookieStickinessPolicy)
-> Lens
     AwsElbAppCookieStickinessPolicy
     AwsElbAppCookieStickinessPolicy
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsElbAppCookieStickinessPolicy' {Maybe Text
cookieName :: Maybe Text
$sel:cookieName:AwsElbAppCookieStickinessPolicy' :: AwsElbAppCookieStickinessPolicy -> Maybe Text
cookieName} -> Maybe Text
cookieName) (\s :: AwsElbAppCookieStickinessPolicy
s@AwsElbAppCookieStickinessPolicy' {} Maybe Text
a -> AwsElbAppCookieStickinessPolicy
s {$sel:cookieName:AwsElbAppCookieStickinessPolicy' :: Maybe Text
cookieName = Maybe Text
a} :: AwsElbAppCookieStickinessPolicy)

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

instance
  Prelude.Hashable
    AwsElbAppCookieStickinessPolicy

instance
  Prelude.NFData
    AwsElbAppCookieStickinessPolicy

instance Core.ToJSON AwsElbAppCookieStickinessPolicy where
  toJSON :: AwsElbAppCookieStickinessPolicy -> Value
toJSON AwsElbAppCookieStickinessPolicy' {Maybe Text
cookieName :: Maybe Text
policyName :: Maybe Text
$sel:cookieName:AwsElbAppCookieStickinessPolicy' :: AwsElbAppCookieStickinessPolicy -> Maybe Text
$sel:policyName:AwsElbAppCookieStickinessPolicy' :: AwsElbAppCookieStickinessPolicy -> 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
"CookieName" 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
cookieName
          ]
      )