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

import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.Types.CustomRoutingProtocol
import qualified Amazonka.Lens as Lens
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
(CustomRoutingDestinationConfiguration
 -> CustomRoutingDestinationConfiguration -> Bool)
-> (CustomRoutingDestinationConfiguration
    -> CustomRoutingDestinationConfiguration -> Bool)
-> Eq CustomRoutingDestinationConfiguration
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]
(Int -> ReadS CustomRoutingDestinationConfiguration)
-> ReadS [CustomRoutingDestinationConfiguration]
-> ReadPrec CustomRoutingDestinationConfiguration
-> ReadPrec [CustomRoutingDestinationConfiguration]
-> Read 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
(Int -> CustomRoutingDestinationConfiguration -> ShowS)
-> (CustomRoutingDestinationConfiguration -> String)
-> ([CustomRoutingDestinationConfiguration] -> ShowS)
-> Show CustomRoutingDestinationConfiguration
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.
 CustomRoutingDestinationConfiguration
 -> Rep CustomRoutingDestinationConfiguration x)
-> (forall x.
    Rep CustomRoutingDestinationConfiguration x
    -> CustomRoutingDestinationConfiguration)
-> Generic CustomRoutingDestinationConfiguration
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' :: Natural
-> Natural
-> NonEmpty CustomRoutingProtocol
-> CustomRoutingDestinationConfiguration
CustomRoutingDestinationConfiguration'
      { $sel:fromPort:CustomRoutingDestinationConfiguration' :: Natural
fromPort =
          Natural
pFromPort_,
        $sel:toPort:CustomRoutingDestinationConfiguration' :: Natural
toPort = Natural
pToPort_,
        $sel:protocols:CustomRoutingDestinationConfiguration' :: NonEmpty CustomRoutingProtocol
protocols =
          Tagged
  (NonEmpty CustomRoutingProtocol)
  (Identity (NonEmpty CustomRoutingProtocol))
-> Tagged
     (NonEmpty CustomRoutingProtocol)
     (Identity (NonEmpty CustomRoutingProtocol))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty CustomRoutingProtocol)
   (Identity (NonEmpty CustomRoutingProtocol))
 -> Tagged
      (NonEmpty CustomRoutingProtocol)
      (Identity (NonEmpty CustomRoutingProtocol)))
-> NonEmpty CustomRoutingProtocol -> NonEmpty CustomRoutingProtocol
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 :: (Natural -> f Natural)
-> CustomRoutingDestinationConfiguration
-> f CustomRoutingDestinationConfiguration
customRoutingDestinationConfiguration_fromPort = (CustomRoutingDestinationConfiguration -> Natural)
-> (CustomRoutingDestinationConfiguration
    -> Natural -> CustomRoutingDestinationConfiguration)
-> Lens
     CustomRoutingDestinationConfiguration
     CustomRoutingDestinationConfiguration
     Natural
     Natural
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 :: (Natural -> f Natural)
-> CustomRoutingDestinationConfiguration
-> f CustomRoutingDestinationConfiguration
customRoutingDestinationConfiguration_toPort = (CustomRoutingDestinationConfiguration -> Natural)
-> (CustomRoutingDestinationConfiguration
    -> Natural -> CustomRoutingDestinationConfiguration)
-> Lens
     CustomRoutingDestinationConfiguration
     CustomRoutingDestinationConfiguration
     Natural
     Natural
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 :: (NonEmpty CustomRoutingProtocol
 -> f (NonEmpty CustomRoutingProtocol))
-> CustomRoutingDestinationConfiguration
-> f CustomRoutingDestinationConfiguration
customRoutingDestinationConfiguration_protocols = (CustomRoutingDestinationConfiguration
 -> NonEmpty CustomRoutingProtocol)
-> (CustomRoutingDestinationConfiguration
    -> NonEmpty CustomRoutingProtocol
    -> CustomRoutingDestinationConfiguration)
-> Lens
     CustomRoutingDestinationConfiguration
     CustomRoutingDestinationConfiguration
     (NonEmpty CustomRoutingProtocol)
     (NonEmpty CustomRoutingProtocol)
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) ((NonEmpty CustomRoutingProtocol
  -> f (NonEmpty CustomRoutingProtocol))
 -> CustomRoutingDestinationConfiguration
 -> f CustomRoutingDestinationConfiguration)
-> ((NonEmpty CustomRoutingProtocol
     -> f (NonEmpty CustomRoutingProtocol))
    -> NonEmpty CustomRoutingProtocol
    -> f (NonEmpty CustomRoutingProtocol))
-> (NonEmpty CustomRoutingProtocol
    -> f (NonEmpty CustomRoutingProtocol))
-> CustomRoutingDestinationConfiguration
-> f CustomRoutingDestinationConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty CustomRoutingProtocol
 -> f (NonEmpty CustomRoutingProtocol))
-> NonEmpty CustomRoutingProtocol
-> f (NonEmpty CustomRoutingProtocol)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.Hashable
    CustomRoutingDestinationConfiguration

instance
  Prelude.NFData
    CustomRoutingDestinationConfiguration

instance
  Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FromPort" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
fromPort),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ToPort" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
toPort),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Protocols" Text -> NonEmpty CustomRoutingProtocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty CustomRoutingProtocol
protocols)
          ]
      )