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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ELB.Internal
import Amazonka.ELB.Types.PolicyAttributeDescription
import qualified Amazonka.Prelude as Prelude

-- | Information about a policy.
--
-- /See:/ 'newPolicyDescription' smart constructor.
data PolicyDescription = PolicyDescription'
  { -- | The policy attributes.
    PolicyDescription -> Maybe [PolicyAttributeDescription]
policyAttributeDescriptions :: Prelude.Maybe [PolicyAttributeDescription],
    -- | The name of the policy.
    PolicyDescription -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text,
    -- | The name of the policy type.
    PolicyDescription -> Maybe Text
policyTypeName :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyDescription -> PolicyDescription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyDescription -> PolicyDescription -> Bool
$c/= :: PolicyDescription -> PolicyDescription -> Bool
== :: PolicyDescription -> PolicyDescription -> Bool
$c== :: PolicyDescription -> PolicyDescription -> Bool
Prelude.Eq, ReadPrec [PolicyDescription]
ReadPrec PolicyDescription
Int -> ReadS PolicyDescription
ReadS [PolicyDescription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyDescription]
$creadListPrec :: ReadPrec [PolicyDescription]
readPrec :: ReadPrec PolicyDescription
$creadPrec :: ReadPrec PolicyDescription
readList :: ReadS [PolicyDescription]
$creadList :: ReadS [PolicyDescription]
readsPrec :: Int -> ReadS PolicyDescription
$creadsPrec :: Int -> ReadS PolicyDescription
Prelude.Read, Int -> PolicyDescription -> ShowS
[PolicyDescription] -> ShowS
PolicyDescription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyDescription] -> ShowS
$cshowList :: [PolicyDescription] -> ShowS
show :: PolicyDescription -> String
$cshow :: PolicyDescription -> String
showsPrec :: Int -> PolicyDescription -> ShowS
$cshowsPrec :: Int -> PolicyDescription -> ShowS
Prelude.Show, forall x. Rep PolicyDescription x -> PolicyDescription
forall x. PolicyDescription -> Rep PolicyDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyDescription x -> PolicyDescription
$cfrom :: forall x. PolicyDescription -> Rep PolicyDescription x
Prelude.Generic)

-- |
-- Create a value of 'PolicyDescription' 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:
--
-- 'policyAttributeDescriptions', 'policyDescription_policyAttributeDescriptions' - The policy attributes.
--
-- 'policyName', 'policyDescription_policyName' - The name of the policy.
--
-- 'policyTypeName', 'policyDescription_policyTypeName' - The name of the policy type.
newPolicyDescription ::
  PolicyDescription
newPolicyDescription :: PolicyDescription
newPolicyDescription =
  PolicyDescription'
    { $sel:policyAttributeDescriptions:PolicyDescription' :: Maybe [PolicyAttributeDescription]
policyAttributeDescriptions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:policyName:PolicyDescription' :: Maybe Text
policyName = forall a. Maybe a
Prelude.Nothing,
      $sel:policyTypeName:PolicyDescription' :: Maybe Text
policyTypeName = forall a. Maybe a
Prelude.Nothing
    }

-- | The policy attributes.
policyDescription_policyAttributeDescriptions :: Lens.Lens' PolicyDescription (Prelude.Maybe [PolicyAttributeDescription])
policyDescription_policyAttributeDescriptions :: Lens' PolicyDescription (Maybe [PolicyAttributeDescription])
policyDescription_policyAttributeDescriptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDescription' {Maybe [PolicyAttributeDescription]
policyAttributeDescriptions :: Maybe [PolicyAttributeDescription]
$sel:policyAttributeDescriptions:PolicyDescription' :: PolicyDescription -> Maybe [PolicyAttributeDescription]
policyAttributeDescriptions} -> Maybe [PolicyAttributeDescription]
policyAttributeDescriptions) (\s :: PolicyDescription
s@PolicyDescription' {} Maybe [PolicyAttributeDescription]
a -> PolicyDescription
s {$sel:policyAttributeDescriptions:PolicyDescription' :: Maybe [PolicyAttributeDescription]
policyAttributeDescriptions = Maybe [PolicyAttributeDescription]
a} :: PolicyDescription) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the policy.
policyDescription_policyName :: Lens.Lens' PolicyDescription (Prelude.Maybe Prelude.Text)
policyDescription_policyName :: Lens' PolicyDescription (Maybe Text)
policyDescription_policyName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDescription' {Maybe Text
policyName :: Maybe Text
$sel:policyName:PolicyDescription' :: PolicyDescription -> Maybe Text
policyName} -> Maybe Text
policyName) (\s :: PolicyDescription
s@PolicyDescription' {} Maybe Text
a -> PolicyDescription
s {$sel:policyName:PolicyDescription' :: Maybe Text
policyName = Maybe Text
a} :: PolicyDescription)

-- | The name of the policy type.
policyDescription_policyTypeName :: Lens.Lens' PolicyDescription (Prelude.Maybe Prelude.Text)
policyDescription_policyTypeName :: Lens' PolicyDescription (Maybe Text)
policyDescription_policyTypeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDescription' {Maybe Text
policyTypeName :: Maybe Text
$sel:policyTypeName:PolicyDescription' :: PolicyDescription -> Maybe Text
policyTypeName} -> Maybe Text
policyTypeName) (\s :: PolicyDescription
s@PolicyDescription' {} Maybe Text
a -> PolicyDescription
s {$sel:policyTypeName:PolicyDescription' :: Maybe Text
policyTypeName = Maybe Text
a} :: PolicyDescription)

instance Data.FromXML PolicyDescription where
  parseXML :: [Node] -> Either String PolicyDescription
parseXML [Node]
x =
    Maybe [PolicyAttributeDescription]
-> Maybe Text -> Maybe Text -> PolicyDescription
PolicyDescription'
      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
"PolicyAttributeDescriptions"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"PolicyName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"PolicyTypeName")

instance Prelude.Hashable PolicyDescription where
  hashWithSalt :: Int -> PolicyDescription -> Int
hashWithSalt Int
_salt PolicyDescription' {Maybe [PolicyAttributeDescription]
Maybe Text
policyTypeName :: Maybe Text
policyName :: Maybe Text
policyAttributeDescriptions :: Maybe [PolicyAttributeDescription]
$sel:policyTypeName:PolicyDescription' :: PolicyDescription -> Maybe Text
$sel:policyName:PolicyDescription' :: PolicyDescription -> Maybe Text
$sel:policyAttributeDescriptions:PolicyDescription' :: PolicyDescription -> Maybe [PolicyAttributeDescription]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PolicyAttributeDescription]
policyAttributeDescriptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policyName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policyTypeName

instance Prelude.NFData PolicyDescription where
  rnf :: PolicyDescription -> ()
rnf PolicyDescription' {Maybe [PolicyAttributeDescription]
Maybe Text
policyTypeName :: Maybe Text
policyName :: Maybe Text
policyAttributeDescriptions :: Maybe [PolicyAttributeDescription]
$sel:policyTypeName:PolicyDescription' :: PolicyDescription -> Maybe Text
$sel:policyName:PolicyDescription' :: PolicyDescription -> Maybe Text
$sel:policyAttributeDescriptions:PolicyDescription' :: PolicyDescription -> Maybe [PolicyAttributeDescription]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PolicyAttributeDescription]
policyAttributeDescriptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyTypeName