{-# 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.GlobalAccelerator.Types.EndpointDescription
-- 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.GlobalAccelerator.Types.EndpointDescription where

import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.Types.HealthState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A complex type for an endpoint. Each endpoint group can include one or
-- more endpoints, such as load balancers.
--
-- /See:/ 'newEndpointDescription' smart constructor.
data EndpointDescription = EndpointDescription'
  { -- | Returns a null result.
    EndpointDescription -> Maybe Text
healthReason :: Prelude.Maybe Prelude.Text,
    -- | The weight associated with the endpoint. When you add weights to
    -- endpoints, you configure AWS Global Accelerator to route traffic based
    -- on proportions that you specify. For example, you might specify endpoint
    -- weights of 4, 5, 5, and 6 (sum=20). The result is that 4\/20 of your
    -- traffic, on average, is routed to the first endpoint, 5\/20 is routed
    -- both to the second and third endpoints, and 6\/20 is routed to the last
    -- endpoint. For more information, see
    -- <https://docs.aws.amazon.com/global-accelerator/latest/dg/about-endpoints-endpoint-weights.html Endpoint Weights>
    -- in the /AWS Global Accelerator Developer Guide/.
    EndpointDescription -> Maybe Natural
weight :: Prelude.Maybe Prelude.Natural,
    -- | Indicates whether client IP address preservation is enabled for an
    -- Application Load Balancer endpoint. The value is true or false. The
    -- default value is true for new accelerators.
    --
    -- If the value is set to true, the client\'s IP address is preserved in
    -- the @X-Forwarded-For@ request header as traffic travels to applications
    -- on the Application Load Balancer endpoint fronted by the accelerator.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/global-accelerator/latest/dg/introduction-how-it-works-client-ip.html Viewing Client IP Addresses in AWS Global Accelerator>
    -- in the /AWS Global Accelerator Developer Guide/.
    EndpointDescription -> Maybe Bool
clientIPPreservationEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The health status of the endpoint.
    EndpointDescription -> Maybe HealthState
healthState :: Prelude.Maybe HealthState,
    -- | An ID for the endpoint. If the endpoint is a Network Load Balancer or
    -- Application Load Balancer, this is the Amazon Resource Name (ARN) of the
    -- resource. If the endpoint is an Elastic IP address, this is the Elastic
    -- IP address allocation ID. For Amazon EC2 instances, this is the EC2
    -- instance ID.
    --
    -- An Application Load Balancer can be either internal or internet-facing.
    EndpointDescription -> Maybe Text
endpointId :: Prelude.Maybe Prelude.Text
  }
  deriving (EndpointDescription -> EndpointDescription -> Bool
(EndpointDescription -> EndpointDescription -> Bool)
-> (EndpointDescription -> EndpointDescription -> Bool)
-> Eq EndpointDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointDescription -> EndpointDescription -> Bool
$c/= :: EndpointDescription -> EndpointDescription -> Bool
== :: EndpointDescription -> EndpointDescription -> Bool
$c== :: EndpointDescription -> EndpointDescription -> Bool
Prelude.Eq, ReadPrec [EndpointDescription]
ReadPrec EndpointDescription
Int -> ReadS EndpointDescription
ReadS [EndpointDescription]
(Int -> ReadS EndpointDescription)
-> ReadS [EndpointDescription]
-> ReadPrec EndpointDescription
-> ReadPrec [EndpointDescription]
-> Read EndpointDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndpointDescription]
$creadListPrec :: ReadPrec [EndpointDescription]
readPrec :: ReadPrec EndpointDescription
$creadPrec :: ReadPrec EndpointDescription
readList :: ReadS [EndpointDescription]
$creadList :: ReadS [EndpointDescription]
readsPrec :: Int -> ReadS EndpointDescription
$creadsPrec :: Int -> ReadS EndpointDescription
Prelude.Read, Int -> EndpointDescription -> ShowS
[EndpointDescription] -> ShowS
EndpointDescription -> String
(Int -> EndpointDescription -> ShowS)
-> (EndpointDescription -> String)
-> ([EndpointDescription] -> ShowS)
-> Show EndpointDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointDescription] -> ShowS
$cshowList :: [EndpointDescription] -> ShowS
show :: EndpointDescription -> String
$cshow :: EndpointDescription -> String
showsPrec :: Int -> EndpointDescription -> ShowS
$cshowsPrec :: Int -> EndpointDescription -> ShowS
Prelude.Show, (forall x. EndpointDescription -> Rep EndpointDescription x)
-> (forall x. Rep EndpointDescription x -> EndpointDescription)
-> Generic EndpointDescription
forall x. Rep EndpointDescription x -> EndpointDescription
forall x. EndpointDescription -> Rep EndpointDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EndpointDescription x -> EndpointDescription
$cfrom :: forall x. EndpointDescription -> Rep EndpointDescription x
Prelude.Generic)

-- |
-- Create a value of 'EndpointDescription' 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:
--
-- 'healthReason', 'endpointDescription_healthReason' - Returns a null result.
--
-- 'weight', 'endpointDescription_weight' - The weight associated with the endpoint. When you add weights to
-- endpoints, you configure AWS Global Accelerator to route traffic based
-- on proportions that you specify. For example, you might specify endpoint
-- weights of 4, 5, 5, and 6 (sum=20). The result is that 4\/20 of your
-- traffic, on average, is routed to the first endpoint, 5\/20 is routed
-- both to the second and third endpoints, and 6\/20 is routed to the last
-- endpoint. For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/about-endpoints-endpoint-weights.html Endpoint Weights>
-- in the /AWS Global Accelerator Developer Guide/.
--
-- 'clientIPPreservationEnabled', 'endpointDescription_clientIPPreservationEnabled' - Indicates whether client IP address preservation is enabled for an
-- Application Load Balancer endpoint. The value is true or false. The
-- default value is true for new accelerators.
--
-- If the value is set to true, the client\'s IP address is preserved in
-- the @X-Forwarded-For@ request header as traffic travels to applications
-- on the Application Load Balancer endpoint fronted by the accelerator.
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/introduction-how-it-works-client-ip.html Viewing Client IP Addresses in AWS Global Accelerator>
-- in the /AWS Global Accelerator Developer Guide/.
--
-- 'healthState', 'endpointDescription_healthState' - The health status of the endpoint.
--
-- 'endpointId', 'endpointDescription_endpointId' - An ID for the endpoint. If the endpoint is a Network Load Balancer or
-- Application Load Balancer, this is the Amazon Resource Name (ARN) of the
-- resource. If the endpoint is an Elastic IP address, this is the Elastic
-- IP address allocation ID. For Amazon EC2 instances, this is the EC2
-- instance ID.
--
-- An Application Load Balancer can be either internal or internet-facing.
newEndpointDescription ::
  EndpointDescription
newEndpointDescription :: EndpointDescription
newEndpointDescription =
  EndpointDescription' :: Maybe Text
-> Maybe Natural
-> Maybe Bool
-> Maybe HealthState
-> Maybe Text
-> EndpointDescription
EndpointDescription'
    { $sel:healthReason:EndpointDescription' :: Maybe Text
healthReason =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:weight:EndpointDescription' :: Maybe Natural
weight = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:clientIPPreservationEnabled:EndpointDescription' :: Maybe Bool
clientIPPreservationEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:healthState:EndpointDescription' :: Maybe HealthState
healthState = Maybe HealthState
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointId:EndpointDescription' :: Maybe Text
endpointId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Returns a null result.
endpointDescription_healthReason :: Lens.Lens' EndpointDescription (Prelude.Maybe Prelude.Text)
endpointDescription_healthReason :: (Maybe Text -> f (Maybe Text))
-> EndpointDescription -> f EndpointDescription
endpointDescription_healthReason = (EndpointDescription -> Maybe Text)
-> (EndpointDescription -> Maybe Text -> EndpointDescription)
-> Lens
     EndpointDescription EndpointDescription (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDescription' {Maybe Text
healthReason :: Maybe Text
$sel:healthReason:EndpointDescription' :: EndpointDescription -> Maybe Text
healthReason} -> Maybe Text
healthReason) (\s :: EndpointDescription
s@EndpointDescription' {} Maybe Text
a -> EndpointDescription
s {$sel:healthReason:EndpointDescription' :: Maybe Text
healthReason = Maybe Text
a} :: EndpointDescription)

-- | The weight associated with the endpoint. When you add weights to
-- endpoints, you configure AWS Global Accelerator to route traffic based
-- on proportions that you specify. For example, you might specify endpoint
-- weights of 4, 5, 5, and 6 (sum=20). The result is that 4\/20 of your
-- traffic, on average, is routed to the first endpoint, 5\/20 is routed
-- both to the second and third endpoints, and 6\/20 is routed to the last
-- endpoint. For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/about-endpoints-endpoint-weights.html Endpoint Weights>
-- in the /AWS Global Accelerator Developer Guide/.
endpointDescription_weight :: Lens.Lens' EndpointDescription (Prelude.Maybe Prelude.Natural)
endpointDescription_weight :: (Maybe Natural -> f (Maybe Natural))
-> EndpointDescription -> f EndpointDescription
endpointDescription_weight = (EndpointDescription -> Maybe Natural)
-> (EndpointDescription -> Maybe Natural -> EndpointDescription)
-> Lens
     EndpointDescription
     EndpointDescription
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDescription' {Maybe Natural
weight :: Maybe Natural
$sel:weight:EndpointDescription' :: EndpointDescription -> Maybe Natural
weight} -> Maybe Natural
weight) (\s :: EndpointDescription
s@EndpointDescription' {} Maybe Natural
a -> EndpointDescription
s {$sel:weight:EndpointDescription' :: Maybe Natural
weight = Maybe Natural
a} :: EndpointDescription)

-- | Indicates whether client IP address preservation is enabled for an
-- Application Load Balancer endpoint. The value is true or false. The
-- default value is true for new accelerators.
--
-- If the value is set to true, the client\'s IP address is preserved in
-- the @X-Forwarded-For@ request header as traffic travels to applications
-- on the Application Load Balancer endpoint fronted by the accelerator.
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/introduction-how-it-works-client-ip.html Viewing Client IP Addresses in AWS Global Accelerator>
-- in the /AWS Global Accelerator Developer Guide/.
endpointDescription_clientIPPreservationEnabled :: Lens.Lens' EndpointDescription (Prelude.Maybe Prelude.Bool)
endpointDescription_clientIPPreservationEnabled :: (Maybe Bool -> f (Maybe Bool))
-> EndpointDescription -> f EndpointDescription
endpointDescription_clientIPPreservationEnabled = (EndpointDescription -> Maybe Bool)
-> (EndpointDescription -> Maybe Bool -> EndpointDescription)
-> Lens
     EndpointDescription EndpointDescription (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDescription' {Maybe Bool
clientIPPreservationEnabled :: Maybe Bool
$sel:clientIPPreservationEnabled:EndpointDescription' :: EndpointDescription -> Maybe Bool
clientIPPreservationEnabled} -> Maybe Bool
clientIPPreservationEnabled) (\s :: EndpointDescription
s@EndpointDescription' {} Maybe Bool
a -> EndpointDescription
s {$sel:clientIPPreservationEnabled:EndpointDescription' :: Maybe Bool
clientIPPreservationEnabled = Maybe Bool
a} :: EndpointDescription)

-- | The health status of the endpoint.
endpointDescription_healthState :: Lens.Lens' EndpointDescription (Prelude.Maybe HealthState)
endpointDescription_healthState :: (Maybe HealthState -> f (Maybe HealthState))
-> EndpointDescription -> f EndpointDescription
endpointDescription_healthState = (EndpointDescription -> Maybe HealthState)
-> (EndpointDescription
    -> Maybe HealthState -> EndpointDescription)
-> Lens
     EndpointDescription
     EndpointDescription
     (Maybe HealthState)
     (Maybe HealthState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDescription' {Maybe HealthState
healthState :: Maybe HealthState
$sel:healthState:EndpointDescription' :: EndpointDescription -> Maybe HealthState
healthState} -> Maybe HealthState
healthState) (\s :: EndpointDescription
s@EndpointDescription' {} Maybe HealthState
a -> EndpointDescription
s {$sel:healthState:EndpointDescription' :: Maybe HealthState
healthState = Maybe HealthState
a} :: EndpointDescription)

-- | An ID for the endpoint. If the endpoint is a Network Load Balancer or
-- Application Load Balancer, this is the Amazon Resource Name (ARN) of the
-- resource. If the endpoint is an Elastic IP address, this is the Elastic
-- IP address allocation ID. For Amazon EC2 instances, this is the EC2
-- instance ID.
--
-- An Application Load Balancer can be either internal or internet-facing.
endpointDescription_endpointId :: Lens.Lens' EndpointDescription (Prelude.Maybe Prelude.Text)
endpointDescription_endpointId :: (Maybe Text -> f (Maybe Text))
-> EndpointDescription -> f EndpointDescription
endpointDescription_endpointId = (EndpointDescription -> Maybe Text)
-> (EndpointDescription -> Maybe Text -> EndpointDescription)
-> Lens
     EndpointDescription EndpointDescription (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointDescription' {Maybe Text
endpointId :: Maybe Text
$sel:endpointId:EndpointDescription' :: EndpointDescription -> Maybe Text
endpointId} -> Maybe Text
endpointId) (\s :: EndpointDescription
s@EndpointDescription' {} Maybe Text
a -> EndpointDescription
s {$sel:endpointId:EndpointDescription' :: Maybe Text
endpointId = Maybe Text
a} :: EndpointDescription)

instance Core.FromJSON EndpointDescription where
  parseJSON :: Value -> Parser EndpointDescription
parseJSON =
    String
-> (Object -> Parser EndpointDescription)
-> Value
-> Parser EndpointDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EndpointDescription"
      ( \Object
x ->
          Maybe Text
-> Maybe Natural
-> Maybe Bool
-> Maybe HealthState
-> Maybe Text
-> EndpointDescription
EndpointDescription'
            (Maybe Text
 -> Maybe Natural
 -> Maybe Bool
 -> Maybe HealthState
 -> Maybe Text
 -> EndpointDescription)
-> Parser (Maybe Text)
-> Parser
     (Maybe Natural
      -> Maybe Bool
      -> Maybe HealthState
      -> Maybe Text
      -> EndpointDescription)
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
"HealthReason")
            Parser
  (Maybe Natural
   -> Maybe Bool
   -> Maybe HealthState
   -> Maybe Text
   -> EndpointDescription)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Bool
      -> Maybe HealthState -> Maybe Text -> EndpointDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Weight")
            Parser
  (Maybe Bool
   -> Maybe HealthState -> Maybe Text -> EndpointDescription)
-> Parser (Maybe Bool)
-> Parser (Maybe HealthState -> Maybe Text -> EndpointDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClientIPPreservationEnabled")
            Parser (Maybe HealthState -> Maybe Text -> EndpointDescription)
-> Parser (Maybe HealthState)
-> Parser (Maybe Text -> EndpointDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HealthState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"HealthState")
            Parser (Maybe Text -> EndpointDescription)
-> Parser (Maybe Text) -> Parser EndpointDescription
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
"EndpointId")
      )

instance Prelude.Hashable EndpointDescription

instance Prelude.NFData EndpointDescription