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

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

-- | Information about a policy.
--
-- /See:/ 'newPolicyDescription' smart constructor.
data PolicyDescription = PolicyDescription'
  { -- | The name of the policy.
    PolicyDescription -> Maybe Text
policyName :: Prelude.Maybe Prelude.Text,
    -- | The policy attributes.
    PolicyDescription -> Maybe [PolicyAttributeDescription]
policyAttributeDescriptions :: Prelude.Maybe [PolicyAttributeDescription],
    -- | The name of the policy type.
    PolicyDescription -> Maybe Text
policyTypeName :: Prelude.Maybe Prelude.Text
  }
  deriving (PolicyDescription -> PolicyDescription -> Bool
(PolicyDescription -> PolicyDescription -> Bool)
-> (PolicyDescription -> PolicyDescription -> Bool)
-> Eq PolicyDescription
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]
(Int -> ReadS PolicyDescription)
-> ReadS [PolicyDescription]
-> ReadPrec PolicyDescription
-> ReadPrec [PolicyDescription]
-> Read 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
(Int -> PolicyDescription -> ShowS)
-> (PolicyDescription -> String)
-> ([PolicyDescription] -> ShowS)
-> Show PolicyDescription
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. PolicyDescription -> Rep PolicyDescription x)
-> (forall x. Rep PolicyDescription x -> PolicyDescription)
-> Generic PolicyDescription
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:
--
-- 'policyName', 'policyDescription_policyName' - The name of the policy.
--
-- 'policyAttributeDescriptions', 'policyDescription_policyAttributeDescriptions' - The policy attributes.
--
-- 'policyTypeName', 'policyDescription_policyTypeName' - The name of the policy type.
newPolicyDescription ::
  PolicyDescription
newPolicyDescription :: PolicyDescription
newPolicyDescription =
  PolicyDescription' :: Maybe Text
-> Maybe [PolicyAttributeDescription]
-> Maybe Text
-> PolicyDescription
PolicyDescription'
    { $sel:policyName:PolicyDescription' :: Maybe Text
policyName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policyAttributeDescriptions:PolicyDescription' :: Maybe [PolicyAttributeDescription]
policyAttributeDescriptions = Maybe [PolicyAttributeDescription]
forall a. Maybe a
Prelude.Nothing,
      $sel:policyTypeName:PolicyDescription' :: Maybe Text
policyTypeName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the policy.
policyDescription_policyName :: Lens.Lens' PolicyDescription (Prelude.Maybe Prelude.Text)
policyDescription_policyName :: (Maybe Text -> f (Maybe Text))
-> PolicyDescription -> f PolicyDescription
policyDescription_policyName = (PolicyDescription -> Maybe Text)
-> (PolicyDescription -> Maybe Text -> PolicyDescription)
-> Lens
     PolicyDescription PolicyDescription (Maybe Text) (Maybe Text)
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 policy attributes.
policyDescription_policyAttributeDescriptions :: Lens.Lens' PolicyDescription (Prelude.Maybe [PolicyAttributeDescription])
policyDescription_policyAttributeDescriptions :: (Maybe [PolicyAttributeDescription]
 -> f (Maybe [PolicyAttributeDescription]))
-> PolicyDescription -> f PolicyDescription
policyDescription_policyAttributeDescriptions = (PolicyDescription -> Maybe [PolicyAttributeDescription])
-> (PolicyDescription
    -> Maybe [PolicyAttributeDescription] -> PolicyDescription)
-> Lens
     PolicyDescription
     PolicyDescription
     (Maybe [PolicyAttributeDescription])
     (Maybe [PolicyAttributeDescription])
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) ((Maybe [PolicyAttributeDescription]
  -> f (Maybe [PolicyAttributeDescription]))
 -> PolicyDescription -> f PolicyDescription)
-> ((Maybe [PolicyAttributeDescription]
     -> f (Maybe [PolicyAttributeDescription]))
    -> Maybe [PolicyAttributeDescription]
    -> f (Maybe [PolicyAttributeDescription]))
-> (Maybe [PolicyAttributeDescription]
    -> f (Maybe [PolicyAttributeDescription]))
-> PolicyDescription
-> f PolicyDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PolicyAttributeDescription]
  [PolicyAttributeDescription]
  [PolicyAttributeDescription]
  [PolicyAttributeDescription]
-> Iso
     (Maybe [PolicyAttributeDescription])
     (Maybe [PolicyAttributeDescription])
     (Maybe [PolicyAttributeDescription])
     (Maybe [PolicyAttributeDescription])
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
  [PolicyAttributeDescription]
  [PolicyAttributeDescription]
  [PolicyAttributeDescription]
  [PolicyAttributeDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the policy type.
policyDescription_policyTypeName :: Lens.Lens' PolicyDescription (Prelude.Maybe Prelude.Text)
policyDescription_policyTypeName :: (Maybe Text -> f (Maybe Text))
-> PolicyDescription -> f PolicyDescription
policyDescription_policyTypeName = (PolicyDescription -> Maybe Text)
-> (PolicyDescription -> Maybe Text -> PolicyDescription)
-> Lens
     PolicyDescription PolicyDescription (Maybe Text) (Maybe Text)
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 Core.FromXML PolicyDescription where
  parseXML :: [Node] -> Either String PolicyDescription
parseXML [Node]
x =
    Maybe Text
-> Maybe [PolicyAttributeDescription]
-> Maybe Text
-> PolicyDescription
PolicyDescription'
      (Maybe Text
 -> Maybe [PolicyAttributeDescription]
 -> Maybe Text
 -> PolicyDescription)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [PolicyAttributeDescription]
      -> Maybe Text -> PolicyDescription)
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 [PolicyAttributeDescription]
   -> Maybe Text -> PolicyDescription)
-> Either String (Maybe [PolicyAttributeDescription])
-> Either String (Maybe Text -> PolicyDescription)
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
"PolicyAttributeDescriptions"
                      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 [PolicyAttributeDescription]))
-> Either String (Maybe [PolicyAttributeDescription])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [PolicyAttributeDescription])
-> [Node] -> Either String (Maybe [PolicyAttributeDescription])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [PolicyAttributeDescription]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either String (Maybe Text -> PolicyDescription)
-> Either String (Maybe Text) -> Either String PolicyDescription
forall (f :: * -> *) a b. Applicative f => 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
"PolicyTypeName")

instance Prelude.Hashable PolicyDescription

instance Prelude.NFData PolicyDescription