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

import qualified Amazonka.Core as Core
import Amazonka.ELB.Internal
import Amazonka.ELB.Types.AppCookieStickinessPolicy
import Amazonka.ELB.Types.LBCookieStickinessPolicy
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The policies for a load balancer.
--
-- /See:/ 'newPolicies' smart constructor.
data Policies = Policies'
  { -- | The policies other than the stickiness policies.
    Policies -> Maybe [Text]
otherPolicies :: Prelude.Maybe [Prelude.Text],
    -- | The stickiness policies created using CreateLBCookieStickinessPolicy.
    Policies -> Maybe [LBCookieStickinessPolicy]
lBCookieStickinessPolicies :: Prelude.Maybe [LBCookieStickinessPolicy],
    -- | The stickiness policies created using CreateAppCookieStickinessPolicy.
    Policies -> Maybe [AppCookieStickinessPolicy]
appCookieStickinessPolicies :: Prelude.Maybe [AppCookieStickinessPolicy]
  }
  deriving (Policies -> Policies -> Bool
(Policies -> Policies -> Bool)
-> (Policies -> Policies -> Bool) -> Eq Policies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Policies -> Policies -> Bool
$c/= :: Policies -> Policies -> Bool
== :: Policies -> Policies -> Bool
$c== :: Policies -> Policies -> Bool
Prelude.Eq, ReadPrec [Policies]
ReadPrec Policies
Int -> ReadS Policies
ReadS [Policies]
(Int -> ReadS Policies)
-> ReadS [Policies]
-> ReadPrec Policies
-> ReadPrec [Policies]
-> Read Policies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Policies]
$creadListPrec :: ReadPrec [Policies]
readPrec :: ReadPrec Policies
$creadPrec :: ReadPrec Policies
readList :: ReadS [Policies]
$creadList :: ReadS [Policies]
readsPrec :: Int -> ReadS Policies
$creadsPrec :: Int -> ReadS Policies
Prelude.Read, Int -> Policies -> ShowS
[Policies] -> ShowS
Policies -> String
(Int -> Policies -> ShowS)
-> (Policies -> String) -> ([Policies] -> ShowS) -> Show Policies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Policies] -> ShowS
$cshowList :: [Policies] -> ShowS
show :: Policies -> String
$cshow :: Policies -> String
showsPrec :: Int -> Policies -> ShowS
$cshowsPrec :: Int -> Policies -> ShowS
Prelude.Show, (forall x. Policies -> Rep Policies x)
-> (forall x. Rep Policies x -> Policies) -> Generic Policies
forall x. Rep Policies x -> Policies
forall x. Policies -> Rep Policies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Policies x -> Policies
$cfrom :: forall x. Policies -> Rep Policies x
Prelude.Generic)

-- |
-- Create a value of 'Policies' 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:
--
-- 'otherPolicies', 'policies_otherPolicies' - The policies other than the stickiness policies.
--
-- 'lBCookieStickinessPolicies', 'policies_lBCookieStickinessPolicies' - The stickiness policies created using CreateLBCookieStickinessPolicy.
--
-- 'appCookieStickinessPolicies', 'policies_appCookieStickinessPolicies' - The stickiness policies created using CreateAppCookieStickinessPolicy.
newPolicies ::
  Policies
newPolicies :: Policies
newPolicies =
  Policies' :: Maybe [Text]
-> Maybe [LBCookieStickinessPolicy]
-> Maybe [AppCookieStickinessPolicy]
-> Policies
Policies'
    { $sel:otherPolicies:Policies' :: Maybe [Text]
otherPolicies = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:lBCookieStickinessPolicies:Policies' :: Maybe [LBCookieStickinessPolicy]
lBCookieStickinessPolicies = Maybe [LBCookieStickinessPolicy]
forall a. Maybe a
Prelude.Nothing,
      $sel:appCookieStickinessPolicies:Policies' :: Maybe [AppCookieStickinessPolicy]
appCookieStickinessPolicies = Maybe [AppCookieStickinessPolicy]
forall a. Maybe a
Prelude.Nothing
    }

-- | The policies other than the stickiness policies.
policies_otherPolicies :: Lens.Lens' Policies (Prelude.Maybe [Prelude.Text])
policies_otherPolicies :: (Maybe [Text] -> f (Maybe [Text])) -> Policies -> f Policies
policies_otherPolicies = (Policies -> Maybe [Text])
-> (Policies -> Maybe [Text] -> Policies)
-> Lens Policies Policies (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Policies' {Maybe [Text]
otherPolicies :: Maybe [Text]
$sel:otherPolicies:Policies' :: Policies -> Maybe [Text]
otherPolicies} -> Maybe [Text]
otherPolicies) (\s :: Policies
s@Policies' {} Maybe [Text]
a -> Policies
s {$sel:otherPolicies:Policies' :: Maybe [Text]
otherPolicies = Maybe [Text]
a} :: Policies) ((Maybe [Text] -> f (Maybe [Text])) -> Policies -> f Policies)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Policies
-> f Policies
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The stickiness policies created using CreateLBCookieStickinessPolicy.
policies_lBCookieStickinessPolicies :: Lens.Lens' Policies (Prelude.Maybe [LBCookieStickinessPolicy])
policies_lBCookieStickinessPolicies :: (Maybe [LBCookieStickinessPolicy]
 -> f (Maybe [LBCookieStickinessPolicy]))
-> Policies -> f Policies
policies_lBCookieStickinessPolicies = (Policies -> Maybe [LBCookieStickinessPolicy])
-> (Policies -> Maybe [LBCookieStickinessPolicy] -> Policies)
-> Lens
     Policies
     Policies
     (Maybe [LBCookieStickinessPolicy])
     (Maybe [LBCookieStickinessPolicy])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Policies' {Maybe [LBCookieStickinessPolicy]
lBCookieStickinessPolicies :: Maybe [LBCookieStickinessPolicy]
$sel:lBCookieStickinessPolicies:Policies' :: Policies -> Maybe [LBCookieStickinessPolicy]
lBCookieStickinessPolicies} -> Maybe [LBCookieStickinessPolicy]
lBCookieStickinessPolicies) (\s :: Policies
s@Policies' {} Maybe [LBCookieStickinessPolicy]
a -> Policies
s {$sel:lBCookieStickinessPolicies:Policies' :: Maybe [LBCookieStickinessPolicy]
lBCookieStickinessPolicies = Maybe [LBCookieStickinessPolicy]
a} :: Policies) ((Maybe [LBCookieStickinessPolicy]
  -> f (Maybe [LBCookieStickinessPolicy]))
 -> Policies -> f Policies)
-> ((Maybe [LBCookieStickinessPolicy]
     -> f (Maybe [LBCookieStickinessPolicy]))
    -> Maybe [LBCookieStickinessPolicy]
    -> f (Maybe [LBCookieStickinessPolicy]))
-> (Maybe [LBCookieStickinessPolicy]
    -> f (Maybe [LBCookieStickinessPolicy]))
-> Policies
-> f Policies
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LBCookieStickinessPolicy]
  [LBCookieStickinessPolicy]
  [LBCookieStickinessPolicy]
  [LBCookieStickinessPolicy]
-> Iso
     (Maybe [LBCookieStickinessPolicy])
     (Maybe [LBCookieStickinessPolicy])
     (Maybe [LBCookieStickinessPolicy])
     (Maybe [LBCookieStickinessPolicy])
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
  [LBCookieStickinessPolicy]
  [LBCookieStickinessPolicy]
  [LBCookieStickinessPolicy]
  [LBCookieStickinessPolicy]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The stickiness policies created using CreateAppCookieStickinessPolicy.
policies_appCookieStickinessPolicies :: Lens.Lens' Policies (Prelude.Maybe [AppCookieStickinessPolicy])
policies_appCookieStickinessPolicies :: (Maybe [AppCookieStickinessPolicy]
 -> f (Maybe [AppCookieStickinessPolicy]))
-> Policies -> f Policies
policies_appCookieStickinessPolicies = (Policies -> Maybe [AppCookieStickinessPolicy])
-> (Policies -> Maybe [AppCookieStickinessPolicy] -> Policies)
-> Lens
     Policies
     Policies
     (Maybe [AppCookieStickinessPolicy])
     (Maybe [AppCookieStickinessPolicy])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Policies' {Maybe [AppCookieStickinessPolicy]
appCookieStickinessPolicies :: Maybe [AppCookieStickinessPolicy]
$sel:appCookieStickinessPolicies:Policies' :: Policies -> Maybe [AppCookieStickinessPolicy]
appCookieStickinessPolicies} -> Maybe [AppCookieStickinessPolicy]
appCookieStickinessPolicies) (\s :: Policies
s@Policies' {} Maybe [AppCookieStickinessPolicy]
a -> Policies
s {$sel:appCookieStickinessPolicies:Policies' :: Maybe [AppCookieStickinessPolicy]
appCookieStickinessPolicies = Maybe [AppCookieStickinessPolicy]
a} :: Policies) ((Maybe [AppCookieStickinessPolicy]
  -> f (Maybe [AppCookieStickinessPolicy]))
 -> Policies -> f Policies)
-> ((Maybe [AppCookieStickinessPolicy]
     -> f (Maybe [AppCookieStickinessPolicy]))
    -> Maybe [AppCookieStickinessPolicy]
    -> f (Maybe [AppCookieStickinessPolicy]))
-> (Maybe [AppCookieStickinessPolicy]
    -> f (Maybe [AppCookieStickinessPolicy]))
-> Policies
-> f Policies
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AppCookieStickinessPolicy]
  [AppCookieStickinessPolicy]
  [AppCookieStickinessPolicy]
  [AppCookieStickinessPolicy]
-> Iso
     (Maybe [AppCookieStickinessPolicy])
     (Maybe [AppCookieStickinessPolicy])
     (Maybe [AppCookieStickinessPolicy])
     (Maybe [AppCookieStickinessPolicy])
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
  [AppCookieStickinessPolicy]
  [AppCookieStickinessPolicy]
  [AppCookieStickinessPolicy]
  [AppCookieStickinessPolicy]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML Policies where
  parseXML :: [Node] -> Either String Policies
parseXML [Node]
x =
    Maybe [Text]
-> Maybe [LBCookieStickinessPolicy]
-> Maybe [AppCookieStickinessPolicy]
-> Policies
Policies'
      (Maybe [Text]
 -> Maybe [LBCookieStickinessPolicy]
 -> Maybe [AppCookieStickinessPolicy]
 -> Policies)
-> Either String (Maybe [Text])
-> Either
     String
     (Maybe [LBCookieStickinessPolicy]
      -> Maybe [AppCookieStickinessPolicy] -> Policies)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"OtherPolicies" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either
  String
  (Maybe [LBCookieStickinessPolicy]
   -> Maybe [AppCookieStickinessPolicy] -> Policies)
-> Either String (Maybe [LBCookieStickinessPolicy])
-> Either String (Maybe [AppCookieStickinessPolicy] -> Policies)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LBCookieStickinessPolicies"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [LBCookieStickinessPolicy]))
-> Either String (Maybe [LBCookieStickinessPolicy])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [LBCookieStickinessPolicy])
-> [Node] -> Either String (Maybe [LBCookieStickinessPolicy])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [LBCookieStickinessPolicy]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either String (Maybe [AppCookieStickinessPolicy] -> Policies)
-> Either String (Maybe [AppCookieStickinessPolicy])
-> Either String Policies
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AppCookieStickinessPolicies"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [AppCookieStickinessPolicy]))
-> Either String (Maybe [AppCookieStickinessPolicy])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [AppCookieStickinessPolicy])
-> [Node] -> Either String (Maybe [AppCookieStickinessPolicy])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [AppCookieStickinessPolicy]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )

instance Prelude.Hashable Policies

instance Prelude.NFData Policies