{-# 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.CustomRoutingDestinationConfiguration
-- 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.CustomRoutingDestinationConfiguration 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.CustomRoutingProtocol
import qualified Amazonka.Prelude as Prelude

-- | For a custom routing accelerator, sets the port range and protocol for
-- all endpoints (virtual private cloud subnets) in an endpoint group to
-- accept client traffic on.
--
-- /See:/ 'newCustomRoutingDestinationConfiguration' smart constructor.
data CustomRoutingDestinationConfiguration = CustomRoutingDestinationConfiguration'
  { -- | The first port, inclusive, in the range of ports for the endpoint group
    -- that is associated with a custom routing accelerator.
    CustomRoutingDestinationConfiguration -> Natural
fromPort :: Prelude.Natural,
    -- | The last port, inclusive, in the range of ports for the endpoint group
    -- that is associated with a custom routing accelerator.
    CustomRoutingDestinationConfiguration -> Natural
toPort :: Prelude.Natural,
    -- | The protocol for the endpoint group that is associated with a custom
    -- routing accelerator. The protocol can be either TCP or UDP.
    CustomRoutingDestinationConfiguration
-> NonEmpty CustomRoutingProtocol
protocols :: Prelude.NonEmpty CustomRoutingProtocol
  }
  deriving (CustomRoutingDestinationConfiguration
-> CustomRoutingDestinationConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomRoutingDestinationConfiguration
-> CustomRoutingDestinationConfiguration -> Bool
$c/= :: CustomRoutingDestinationConfiguration
-> CustomRoutingDestinationConfiguration -> Bool
== :: CustomRoutingDestinationConfiguration
-> CustomRoutingDestinationConfiguration -> Bool
$c== :: CustomRoutingDestinationConfiguration
-> CustomRoutingDestinationConfiguration -> Bool
Prelude.Eq, ReadPrec [CustomRoutingDestinationConfiguration]
ReadPrec CustomRoutingDestinationConfiguration
Int -> ReadS CustomRoutingDestinationConfiguration
ReadS [CustomRoutingDestinationConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomRoutingDestinationConfiguration]
$creadListPrec :: ReadPrec [CustomRoutingDestinationConfiguration]
readPrec :: ReadPrec CustomRoutingDestinationConfiguration
$creadPrec :: ReadPrec CustomRoutingDestinationConfiguration
readList :: ReadS [CustomRoutingDestinationConfiguration]
$creadList :: ReadS [CustomRoutingDestinationConfiguration]
readsPrec :: Int -> ReadS CustomRoutingDestinationConfiguration
$creadsPrec :: Int -> ReadS CustomRoutingDestinationConfiguration
Prelude.Read, Int -> CustomRoutingDestinationConfiguration -> ShowS
[CustomRoutingDestinationConfiguration] -> ShowS
CustomRoutingDestinationConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomRoutingDestinationConfiguration] -> ShowS
$cshowList :: [CustomRoutingDestinationConfiguration] -> ShowS
show :: CustomRoutingDestinationConfiguration -> String
$cshow :: CustomRoutingDestinationConfiguration -> String
showsPrec :: Int -> CustomRoutingDestinationConfiguration -> ShowS
$cshowsPrec :: Int -> CustomRoutingDestinationConfiguration -> ShowS
Prelude.Show, forall x.
Rep CustomRoutingDestinationConfiguration x
-> CustomRoutingDestinationConfiguration
forall x.
CustomRoutingDestinationConfiguration
-> Rep CustomRoutingDestinationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomRoutingDestinationConfiguration x
-> CustomRoutingDestinationConfiguration
$cfrom :: forall x.
CustomRoutingDestinationConfiguration
-> Rep CustomRoutingDestinationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CustomRoutingDestinationConfiguration' 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:
--
-- 'fromPort', 'customRoutingDestinationConfiguration_fromPort' - The first port, inclusive, in the range of ports for the endpoint group
-- that is associated with a custom routing accelerator.
--
-- 'toPort', 'customRoutingDestinationConfiguration_toPort' - The last port, inclusive, in the range of ports for the endpoint group
-- that is associated with a custom routing accelerator.
--
-- 'protocols', 'customRoutingDestinationConfiguration_protocols' - The protocol for the endpoint group that is associated with a custom
-- routing accelerator. The protocol can be either TCP or UDP.
newCustomRoutingDestinationConfiguration ::
  -- | 'fromPort'
  Prelude.Natural ->
  -- | 'toPort'
  Prelude.Natural ->
  -- | 'protocols'
  Prelude.NonEmpty CustomRoutingProtocol ->
  CustomRoutingDestinationConfiguration
newCustomRoutingDestinationConfiguration :: Natural
-> Natural
-> NonEmpty CustomRoutingProtocol
-> CustomRoutingDestinationConfiguration
newCustomRoutingDestinationConfiguration
  Natural
pFromPort_
  Natural
pToPort_
  NonEmpty CustomRoutingProtocol
pProtocols_ =
    CustomRoutingDestinationConfiguration'
      { $sel:fromPort:CustomRoutingDestinationConfiguration' :: Natural
fromPort =
          Natural
pFromPort_,
        $sel:toPort:CustomRoutingDestinationConfiguration' :: Natural
toPort = Natural
pToPort_,
        $sel:protocols:CustomRoutingDestinationConfiguration' :: NonEmpty CustomRoutingProtocol
protocols =
          forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty CustomRoutingProtocol
pProtocols_
      }

-- | The first port, inclusive, in the range of ports for the endpoint group
-- that is associated with a custom routing accelerator.
customRoutingDestinationConfiguration_fromPort :: Lens.Lens' CustomRoutingDestinationConfiguration Prelude.Natural
customRoutingDestinationConfiguration_fromPort :: Lens' CustomRoutingDestinationConfiguration Natural
customRoutingDestinationConfiguration_fromPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRoutingDestinationConfiguration' {Natural
fromPort :: Natural
$sel:fromPort:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration -> Natural
fromPort} -> Natural
fromPort) (\s :: CustomRoutingDestinationConfiguration
s@CustomRoutingDestinationConfiguration' {} Natural
a -> CustomRoutingDestinationConfiguration
s {$sel:fromPort:CustomRoutingDestinationConfiguration' :: Natural
fromPort = Natural
a} :: CustomRoutingDestinationConfiguration)

-- | The last port, inclusive, in the range of ports for the endpoint group
-- that is associated with a custom routing accelerator.
customRoutingDestinationConfiguration_toPort :: Lens.Lens' CustomRoutingDestinationConfiguration Prelude.Natural
customRoutingDestinationConfiguration_toPort :: Lens' CustomRoutingDestinationConfiguration Natural
customRoutingDestinationConfiguration_toPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRoutingDestinationConfiguration' {Natural
toPort :: Natural
$sel:toPort:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration -> Natural
toPort} -> Natural
toPort) (\s :: CustomRoutingDestinationConfiguration
s@CustomRoutingDestinationConfiguration' {} Natural
a -> CustomRoutingDestinationConfiguration
s {$sel:toPort:CustomRoutingDestinationConfiguration' :: Natural
toPort = Natural
a} :: CustomRoutingDestinationConfiguration)

-- | The protocol for the endpoint group that is associated with a custom
-- routing accelerator. The protocol can be either TCP or UDP.
customRoutingDestinationConfiguration_protocols :: Lens.Lens' CustomRoutingDestinationConfiguration (Prelude.NonEmpty CustomRoutingProtocol)
customRoutingDestinationConfiguration_protocols :: Lens'
  CustomRoutingDestinationConfiguration
  (NonEmpty CustomRoutingProtocol)
customRoutingDestinationConfiguration_protocols = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRoutingDestinationConfiguration' {NonEmpty CustomRoutingProtocol
protocols :: NonEmpty CustomRoutingProtocol
$sel:protocols:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration
-> NonEmpty CustomRoutingProtocol
protocols} -> NonEmpty CustomRoutingProtocol
protocols) (\s :: CustomRoutingDestinationConfiguration
s@CustomRoutingDestinationConfiguration' {} NonEmpty CustomRoutingProtocol
a -> CustomRoutingDestinationConfiguration
s {$sel:protocols:CustomRoutingDestinationConfiguration' :: NonEmpty CustomRoutingProtocol
protocols = NonEmpty CustomRoutingProtocol
a} :: CustomRoutingDestinationConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.Hashable
    CustomRoutingDestinationConfiguration
  where
  hashWithSalt :: Int -> CustomRoutingDestinationConfiguration -> Int
hashWithSalt
    Int
_salt
    CustomRoutingDestinationConfiguration' {Natural
NonEmpty CustomRoutingProtocol
protocols :: NonEmpty CustomRoutingProtocol
toPort :: Natural
fromPort :: Natural
$sel:protocols:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration
-> NonEmpty CustomRoutingProtocol
$sel:toPort:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration -> Natural
$sel:fromPort:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration -> Natural
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
fromPort
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
toPort
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty CustomRoutingProtocol
protocols

instance
  Prelude.NFData
    CustomRoutingDestinationConfiguration
  where
  rnf :: CustomRoutingDestinationConfiguration -> ()
rnf CustomRoutingDestinationConfiguration' {Natural
NonEmpty CustomRoutingProtocol
protocols :: NonEmpty CustomRoutingProtocol
toPort :: Natural
fromPort :: Natural
$sel:protocols:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration
-> NonEmpty CustomRoutingProtocol
$sel:toPort:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration -> Natural
$sel:fromPort:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
fromPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
toPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty CustomRoutingProtocol
protocols

instance
  Data.ToJSON
    CustomRoutingDestinationConfiguration
  where
  toJSON :: CustomRoutingDestinationConfiguration -> Value
toJSON CustomRoutingDestinationConfiguration' {Natural
NonEmpty CustomRoutingProtocol
protocols :: NonEmpty CustomRoutingProtocol
toPort :: Natural
fromPort :: Natural
$sel:protocols:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration
-> NonEmpty CustomRoutingProtocol
$sel:toPort:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration -> Natural
$sel:fromPort:CustomRoutingDestinationConfiguration' :: CustomRoutingDestinationConfiguration -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"FromPort" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
fromPort),
            forall a. a -> Maybe a
Prelude.Just (Key
"ToPort" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
toPort),
            forall a. a -> Maybe a
Prelude.Just (Key
"Protocols" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty CustomRoutingProtocol
protocols)
          ]
      )