{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GlobalAccelerator.Types.EndpointDescription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GlobalAccelerator.Types.HealthState
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'
  { -- | Indicates whether client IP address preservation is enabled for an
    -- 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 endpoint fronted by the accelerator.
    --
    -- Client IP address preservation is supported, in specific Amazon Web
    -- Services Regions, for endpoints that are Application Load Balancers and
    -- Amazon EC2 instances.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/global-accelerator/latest/dg/preserve-client-ip-address.html Preserve client IP addresses in Global Accelerator>
    -- in the /Global Accelerator Developer Guide/.
    EndpointDescription -> Maybe Bool
clientIPPreservationEnabled :: Prelude.Maybe Prelude.Bool,
    -- | 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,
    -- | Returns a null result.
    EndpointDescription -> Maybe Text
healthReason :: Prelude.Maybe Prelude.Text,
    -- | The health status of the endpoint.
    EndpointDescription -> Maybe HealthState
healthState :: Prelude.Maybe HealthState,
    -- | The weight associated with the endpoint. When you add weights to
    -- endpoints, you configure 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 /Global Accelerator Developer Guide/.
    EndpointDescription -> Maybe Natural
weight :: Prelude.Maybe Prelude.Natural
  }
  deriving (EndpointDescription -> EndpointDescription -> Bool
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]
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
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. 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:
--
-- 'clientIPPreservationEnabled', 'endpointDescription_clientIPPreservationEnabled' - Indicates whether client IP address preservation is enabled for an
-- 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 endpoint fronted by the accelerator.
--
-- Client IP address preservation is supported, in specific Amazon Web
-- Services Regions, for endpoints that are Application Load Balancers and
-- Amazon EC2 instances.
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/preserve-client-ip-address.html Preserve client IP addresses in Global Accelerator>
-- in the /Global Accelerator Developer Guide/.
--
-- '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.
--
-- 'healthReason', 'endpointDescription_healthReason' - Returns a null result.
--
-- 'healthState', 'endpointDescription_healthState' - The health status of the endpoint.
--
-- 'weight', 'endpointDescription_weight' - The weight associated with the endpoint. When you add weights to
-- endpoints, you configure 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 /Global Accelerator Developer Guide/.
newEndpointDescription ::
  EndpointDescription
newEndpointDescription :: EndpointDescription
newEndpointDescription =
  EndpointDescription'
    { $sel:clientIPPreservationEnabled:EndpointDescription' :: Maybe Bool
clientIPPreservationEnabled =
        forall a. Maybe a
Prelude.Nothing,
      $sel:endpointId:EndpointDescription' :: Maybe Text
endpointId = forall a. Maybe a
Prelude.Nothing,
      $sel:healthReason:EndpointDescription' :: Maybe Text
healthReason = forall a. Maybe a
Prelude.Nothing,
      $sel:healthState:EndpointDescription' :: Maybe HealthState
healthState = forall a. Maybe a
Prelude.Nothing,
      $sel:weight:EndpointDescription' :: Maybe Natural
weight = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether client IP address preservation is enabled for an
-- 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 endpoint fronted by the accelerator.
--
-- Client IP address preservation is supported, in specific Amazon Web
-- Services Regions, for endpoints that are Application Load Balancers and
-- Amazon EC2 instances.
--
-- For more information, see
-- <https://docs.aws.amazon.com/global-accelerator/latest/dg/preserve-client-ip-address.html Preserve client IP addresses in Global Accelerator>
-- in the /Global Accelerator Developer Guide/.
endpointDescription_clientIPPreservationEnabled :: Lens.Lens' EndpointDescription (Prelude.Maybe Prelude.Bool)
endpointDescription_clientIPPreservationEnabled :: Lens' EndpointDescription (Maybe Bool)
endpointDescription_clientIPPreservationEnabled = 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)

-- | 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 :: Lens' EndpointDescription (Maybe Text)
endpointDescription_endpointId = 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)

-- | Returns a null result.
endpointDescription_healthReason :: Lens.Lens' EndpointDescription (Prelude.Maybe Prelude.Text)
endpointDescription_healthReason :: Lens' EndpointDescription (Maybe Text)
endpointDescription_healthReason = 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 health status of the endpoint.
endpointDescription_healthState :: Lens.Lens' EndpointDescription (Prelude.Maybe HealthState)
endpointDescription_healthState :: Lens' EndpointDescription (Maybe HealthState)
endpointDescription_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)

-- | The weight associated with the endpoint. When you add weights to
-- endpoints, you configure 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 /Global Accelerator Developer Guide/.
endpointDescription_weight :: Lens.Lens' EndpointDescription (Prelude.Maybe Prelude.Natural)
endpointDescription_weight :: Lens' EndpointDescription (Maybe Natural)
endpointDescription_weight = 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)

instance Data.FromJSON EndpointDescription where
  parseJSON :: Value -> Parser EndpointDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EndpointDescription"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe HealthState
-> Maybe Natural
-> EndpointDescription
EndpointDescription'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ClientIPPreservationEnabled")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EndpointId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"HealthReason")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"HealthState")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Weight")
      )

instance Prelude.Hashable EndpointDescription where
  hashWithSalt :: Int -> EndpointDescription -> Int
hashWithSalt Int
_salt EndpointDescription' {Maybe Bool
Maybe Natural
Maybe Text
Maybe HealthState
weight :: Maybe Natural
healthState :: Maybe HealthState
healthReason :: Maybe Text
endpointId :: Maybe Text
clientIPPreservationEnabled :: Maybe Bool
$sel:weight:EndpointDescription' :: EndpointDescription -> Maybe Natural
$sel:healthState:EndpointDescription' :: EndpointDescription -> Maybe HealthState
$sel:healthReason:EndpointDescription' :: EndpointDescription -> Maybe Text
$sel:endpointId:EndpointDescription' :: EndpointDescription -> Maybe Text
$sel:clientIPPreservationEnabled:EndpointDescription' :: EndpointDescription -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
clientIPPreservationEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
endpointId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
healthReason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HealthState
healthState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
weight

instance Prelude.NFData EndpointDescription where
  rnf :: EndpointDescription -> ()
rnf EndpointDescription' {Maybe Bool
Maybe Natural
Maybe Text
Maybe HealthState
weight :: Maybe Natural
healthState :: Maybe HealthState
healthReason :: Maybe Text
endpointId :: Maybe Text
clientIPPreservationEnabled :: Maybe Bool
$sel:weight:EndpointDescription' :: EndpointDescription -> Maybe Natural
$sel:healthState:EndpointDescription' :: EndpointDescription -> Maybe HealthState
$sel:healthReason:EndpointDescription' :: EndpointDescription -> Maybe Text
$sel:endpointId:EndpointDescription' :: EndpointDescription -> Maybe Text
$sel:clientIPPreservationEnabled:EndpointDescription' :: EndpointDescription -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
clientIPPreservationEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
endpointId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
healthReason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HealthState
healthState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
weight