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

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

-- | Information about the configuration of an EC2 instance.
--
-- /See:/ 'newBackendServerDescription' smart constructor.
data BackendServerDescription = BackendServerDescription'
  { -- | The names of the policies enabled for the EC2 instance.
    BackendServerDescription -> Maybe [Text]
policyNames :: Prelude.Maybe [Prelude.Text],
    -- | The port on which the EC2 instance is listening.
    BackendServerDescription -> Maybe Natural
instancePort :: Prelude.Maybe Prelude.Natural
  }
  deriving (BackendServerDescription -> BackendServerDescription -> Bool
(BackendServerDescription -> BackendServerDescription -> Bool)
-> (BackendServerDescription -> BackendServerDescription -> Bool)
-> Eq BackendServerDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackendServerDescription -> BackendServerDescription -> Bool
$c/= :: BackendServerDescription -> BackendServerDescription -> Bool
== :: BackendServerDescription -> BackendServerDescription -> Bool
$c== :: BackendServerDescription -> BackendServerDescription -> Bool
Prelude.Eq, ReadPrec [BackendServerDescription]
ReadPrec BackendServerDescription
Int -> ReadS BackendServerDescription
ReadS [BackendServerDescription]
(Int -> ReadS BackendServerDescription)
-> ReadS [BackendServerDescription]
-> ReadPrec BackendServerDescription
-> ReadPrec [BackendServerDescription]
-> Read BackendServerDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackendServerDescription]
$creadListPrec :: ReadPrec [BackendServerDescription]
readPrec :: ReadPrec BackendServerDescription
$creadPrec :: ReadPrec BackendServerDescription
readList :: ReadS [BackendServerDescription]
$creadList :: ReadS [BackendServerDescription]
readsPrec :: Int -> ReadS BackendServerDescription
$creadsPrec :: Int -> ReadS BackendServerDescription
Prelude.Read, Int -> BackendServerDescription -> ShowS
[BackendServerDescription] -> ShowS
BackendServerDescription -> String
(Int -> BackendServerDescription -> ShowS)
-> (BackendServerDescription -> String)
-> ([BackendServerDescription] -> ShowS)
-> Show BackendServerDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackendServerDescription] -> ShowS
$cshowList :: [BackendServerDescription] -> ShowS
show :: BackendServerDescription -> String
$cshow :: BackendServerDescription -> String
showsPrec :: Int -> BackendServerDescription -> ShowS
$cshowsPrec :: Int -> BackendServerDescription -> ShowS
Prelude.Show, (forall x.
 BackendServerDescription -> Rep BackendServerDescription x)
-> (forall x.
    Rep BackendServerDescription x -> BackendServerDescription)
-> Generic BackendServerDescription
forall x.
Rep BackendServerDescription x -> BackendServerDescription
forall x.
BackendServerDescription -> Rep BackendServerDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BackendServerDescription x -> BackendServerDescription
$cfrom :: forall x.
BackendServerDescription -> Rep BackendServerDescription x
Prelude.Generic)

-- |
-- Create a value of 'BackendServerDescription' 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:
--
-- 'policyNames', 'backendServerDescription_policyNames' - The names of the policies enabled for the EC2 instance.
--
-- 'instancePort', 'backendServerDescription_instancePort' - The port on which the EC2 instance is listening.
newBackendServerDescription ::
  BackendServerDescription
newBackendServerDescription :: BackendServerDescription
newBackendServerDescription =
  BackendServerDescription' :: Maybe [Text] -> Maybe Natural -> BackendServerDescription
BackendServerDescription'
    { $sel:policyNames:BackendServerDescription' :: Maybe [Text]
policyNames =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:instancePort:BackendServerDescription' :: Maybe Natural
instancePort = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The names of the policies enabled for the EC2 instance.
backendServerDescription_policyNames :: Lens.Lens' BackendServerDescription (Prelude.Maybe [Prelude.Text])
backendServerDescription_policyNames :: (Maybe [Text] -> f (Maybe [Text]))
-> BackendServerDescription -> f BackendServerDescription
backendServerDescription_policyNames = (BackendServerDescription -> Maybe [Text])
-> (BackendServerDescription
    -> Maybe [Text] -> BackendServerDescription)
-> Lens
     BackendServerDescription
     BackendServerDescription
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendServerDescription' {Maybe [Text]
policyNames :: Maybe [Text]
$sel:policyNames:BackendServerDescription' :: BackendServerDescription -> Maybe [Text]
policyNames} -> Maybe [Text]
policyNames) (\s :: BackendServerDescription
s@BackendServerDescription' {} Maybe [Text]
a -> BackendServerDescription
s {$sel:policyNames:BackendServerDescription' :: Maybe [Text]
policyNames = Maybe [Text]
a} :: BackendServerDescription) ((Maybe [Text] -> f (Maybe [Text]))
 -> BackendServerDescription -> f BackendServerDescription)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> BackendServerDescription
-> f BackendServerDescription
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 port on which the EC2 instance is listening.
backendServerDescription_instancePort :: Lens.Lens' BackendServerDescription (Prelude.Maybe Prelude.Natural)
backendServerDescription_instancePort :: (Maybe Natural -> f (Maybe Natural))
-> BackendServerDescription -> f BackendServerDescription
backendServerDescription_instancePort = (BackendServerDescription -> Maybe Natural)
-> (BackendServerDescription
    -> Maybe Natural -> BackendServerDescription)
-> Lens
     BackendServerDescription
     BackendServerDescription
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendServerDescription' {Maybe Natural
instancePort :: Maybe Natural
$sel:instancePort:BackendServerDescription' :: BackendServerDescription -> Maybe Natural
instancePort} -> Maybe Natural
instancePort) (\s :: BackendServerDescription
s@BackendServerDescription' {} Maybe Natural
a -> BackendServerDescription
s {$sel:instancePort:BackendServerDescription' :: Maybe Natural
instancePort = Maybe Natural
a} :: BackendServerDescription)

instance Core.FromXML BackendServerDescription where
  parseXML :: [Node] -> Either String BackendServerDescription
parseXML [Node]
x =
    Maybe [Text] -> Maybe Natural -> BackendServerDescription
BackendServerDescription'
      (Maybe [Text] -> Maybe Natural -> BackendServerDescription)
-> Either String (Maybe [Text])
-> Either String (Maybe Natural -> BackendServerDescription)
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
"PolicyNames" 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 Natural -> BackendServerDescription)
-> Either String (Maybe Natural)
-> Either String BackendServerDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Natural)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"InstancePort")

instance Prelude.Hashable BackendServerDescription

instance Prelude.NFData BackendServerDescription