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

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

-- | A complex type for an endpoint. Specifies information about the endpoint
-- to remove from the endpoint group.
--
-- /See:/ 'newEndpointIdentifier' smart constructor.
data EndpointIdentifier = EndpointIdentifier'
  { -- | Indicates whether client IP address preservation is enabled for an
    -- endpoint. The value is true or false.
    --
    -- 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.
    EndpointIdentifier -> 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.
    EndpointIdentifier -> Text
endpointId :: Prelude.Text
  }
  deriving (EndpointIdentifier -> EndpointIdentifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointIdentifier -> EndpointIdentifier -> Bool
$c/= :: EndpointIdentifier -> EndpointIdentifier -> Bool
== :: EndpointIdentifier -> EndpointIdentifier -> Bool
$c== :: EndpointIdentifier -> EndpointIdentifier -> Bool
Prelude.Eq, ReadPrec [EndpointIdentifier]
ReadPrec EndpointIdentifier
Int -> ReadS EndpointIdentifier
ReadS [EndpointIdentifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndpointIdentifier]
$creadListPrec :: ReadPrec [EndpointIdentifier]
readPrec :: ReadPrec EndpointIdentifier
$creadPrec :: ReadPrec EndpointIdentifier
readList :: ReadS [EndpointIdentifier]
$creadList :: ReadS [EndpointIdentifier]
readsPrec :: Int -> ReadS EndpointIdentifier
$creadsPrec :: Int -> ReadS EndpointIdentifier
Prelude.Read, Int -> EndpointIdentifier -> ShowS
[EndpointIdentifier] -> ShowS
EndpointIdentifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointIdentifier] -> ShowS
$cshowList :: [EndpointIdentifier] -> ShowS
show :: EndpointIdentifier -> String
$cshow :: EndpointIdentifier -> String
showsPrec :: Int -> EndpointIdentifier -> ShowS
$cshowsPrec :: Int -> EndpointIdentifier -> ShowS
Prelude.Show, forall x. Rep EndpointIdentifier x -> EndpointIdentifier
forall x. EndpointIdentifier -> Rep EndpointIdentifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EndpointIdentifier x -> EndpointIdentifier
$cfrom :: forall x. EndpointIdentifier -> Rep EndpointIdentifier x
Prelude.Generic)

-- |
-- Create a value of 'EndpointIdentifier' 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', 'endpointIdentifier_clientIPPreservationEnabled' - Indicates whether client IP address preservation is enabled for an
-- endpoint. The value is true or false.
--
-- 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.
--
-- 'endpointId', 'endpointIdentifier_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.
newEndpointIdentifier ::
  -- | 'endpointId'
  Prelude.Text ->
  EndpointIdentifier
newEndpointIdentifier :: Text -> EndpointIdentifier
newEndpointIdentifier Text
pEndpointId_ =
  EndpointIdentifier'
    { $sel:clientIPPreservationEnabled:EndpointIdentifier' :: Maybe Bool
clientIPPreservationEnabled =
        forall a. Maybe a
Prelude.Nothing,
      $sel:endpointId:EndpointIdentifier' :: Text
endpointId = Text
pEndpointId_
    }

-- | Indicates whether client IP address preservation is enabled for an
-- endpoint. The value is true or false.
--
-- 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.
endpointIdentifier_clientIPPreservationEnabled :: Lens.Lens' EndpointIdentifier (Prelude.Maybe Prelude.Bool)
endpointIdentifier_clientIPPreservationEnabled :: Lens' EndpointIdentifier (Maybe Bool)
endpointIdentifier_clientIPPreservationEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointIdentifier' {Maybe Bool
clientIPPreservationEnabled :: Maybe Bool
$sel:clientIPPreservationEnabled:EndpointIdentifier' :: EndpointIdentifier -> Maybe Bool
clientIPPreservationEnabled} -> Maybe Bool
clientIPPreservationEnabled) (\s :: EndpointIdentifier
s@EndpointIdentifier' {} Maybe Bool
a -> EndpointIdentifier
s {$sel:clientIPPreservationEnabled:EndpointIdentifier' :: Maybe Bool
clientIPPreservationEnabled = Maybe Bool
a} :: EndpointIdentifier)

-- | 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.
endpointIdentifier_endpointId :: Lens.Lens' EndpointIdentifier Prelude.Text
endpointIdentifier_endpointId :: Lens' EndpointIdentifier Text
endpointIdentifier_endpointId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointIdentifier' {Text
endpointId :: Text
$sel:endpointId:EndpointIdentifier' :: EndpointIdentifier -> Text
endpointId} -> Text
endpointId) (\s :: EndpointIdentifier
s@EndpointIdentifier' {} Text
a -> EndpointIdentifier
s {$sel:endpointId:EndpointIdentifier' :: Text
endpointId = Text
a} :: EndpointIdentifier)

instance Prelude.Hashable EndpointIdentifier where
  hashWithSalt :: Int -> EndpointIdentifier -> Int
hashWithSalt Int
_salt EndpointIdentifier' {Maybe Bool
Text
endpointId :: Text
clientIPPreservationEnabled :: Maybe Bool
$sel:endpointId:EndpointIdentifier' :: EndpointIdentifier -> Text
$sel:clientIPPreservationEnabled:EndpointIdentifier' :: EndpointIdentifier -> 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` Text
endpointId

instance Prelude.NFData EndpointIdentifier where
  rnf :: EndpointIdentifier -> ()
rnf EndpointIdentifier' {Maybe Bool
Text
endpointId :: Text
clientIPPreservationEnabled :: Maybe Bool
$sel:endpointId:EndpointIdentifier' :: EndpointIdentifier -> Text
$sel:clientIPPreservationEnabled:EndpointIdentifier' :: EndpointIdentifier -> 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 Text
endpointId

instance Data.ToJSON EndpointIdentifier where
  toJSON :: EndpointIdentifier -> Value
toJSON EndpointIdentifier' {Maybe Bool
Text
endpointId :: Text
clientIPPreservationEnabled :: Maybe Bool
$sel:endpointId:EndpointIdentifier' :: EndpointIdentifier -> Text
$sel:clientIPPreservationEnabled:EndpointIdentifier' :: EndpointIdentifier -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ClientIPPreservationEnabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
clientIPPreservationEnabled,
            forall a. a -> Maybe a
Prelude.Just (Key
"EndpointId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
endpointId)
          ]
      )