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

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

-- |
-- Create a value of 'CustomRoutingDestinationDescription' 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', 'customRoutingDestinationDescription_fromPort' - The first port, inclusive, in the range of ports for the endpoint group
-- that is associated with a custom routing accelerator.
--
-- 'protocols', 'customRoutingDestinationDescription_protocols' - The protocol for the endpoint group that is associated with a custom
-- routing accelerator. The protocol can be either TCP or UDP.
--
-- 'toPort', 'customRoutingDestinationDescription_toPort' - The last port, inclusive, in the range of ports for the endpoint group
-- that is associated with a custom routing accelerator.
newCustomRoutingDestinationDescription ::
  CustomRoutingDestinationDescription
newCustomRoutingDestinationDescription :: CustomRoutingDestinationDescription
newCustomRoutingDestinationDescription =
  CustomRoutingDestinationDescription'
    { $sel:fromPort:CustomRoutingDestinationDescription' :: Maybe Natural
fromPort =
        forall a. Maybe a
Prelude.Nothing,
      $sel:protocols:CustomRoutingDestinationDescription' :: Maybe [Protocol]
protocols = forall a. Maybe a
Prelude.Nothing,
      $sel:toPort:CustomRoutingDestinationDescription' :: Maybe Natural
toPort = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The protocol for the endpoint group that is associated with a custom
-- routing accelerator. The protocol can be either TCP or UDP.
customRoutingDestinationDescription_protocols :: Lens.Lens' CustomRoutingDestinationDescription (Prelude.Maybe [Protocol])
customRoutingDestinationDescription_protocols :: Lens' CustomRoutingDestinationDescription (Maybe [Protocol])
customRoutingDestinationDescription_protocols = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomRoutingDestinationDescription' {Maybe [Protocol]
protocols :: Maybe [Protocol]
$sel:protocols:CustomRoutingDestinationDescription' :: CustomRoutingDestinationDescription -> Maybe [Protocol]
protocols} -> Maybe [Protocol]
protocols) (\s :: CustomRoutingDestinationDescription
s@CustomRoutingDestinationDescription' {} Maybe [Protocol]
a -> CustomRoutingDestinationDescription
s {$sel:protocols:CustomRoutingDestinationDescription' :: Maybe [Protocol]
protocols = Maybe [Protocol]
a} :: CustomRoutingDestinationDescription) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Data.FromJSON
    CustomRoutingDestinationDescription
  where
  parseJSON :: Value -> Parser CustomRoutingDestinationDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomRoutingDestinationDescription"
      ( \Object
x ->
          Maybe Natural
-> Maybe [Protocol]
-> Maybe Natural
-> CustomRoutingDestinationDescription
CustomRoutingDestinationDescription'
            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
"FromPort")
            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
"Protocols" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"ToPort")
      )

instance
  Prelude.Hashable
    CustomRoutingDestinationDescription
  where
  hashWithSalt :: Int -> CustomRoutingDestinationDescription -> Int
hashWithSalt
    Int
_salt
    CustomRoutingDestinationDescription' {Maybe Natural
Maybe [Protocol]
toPort :: Maybe Natural
protocols :: Maybe [Protocol]
fromPort :: Maybe Natural
$sel:toPort:CustomRoutingDestinationDescription' :: CustomRoutingDestinationDescription -> Maybe Natural
$sel:protocols:CustomRoutingDestinationDescription' :: CustomRoutingDestinationDescription -> Maybe [Protocol]
$sel:fromPort:CustomRoutingDestinationDescription' :: CustomRoutingDestinationDescription -> Maybe Natural
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
fromPort
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Protocol]
protocols
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
toPort

instance
  Prelude.NFData
    CustomRoutingDestinationDescription
  where
  rnf :: CustomRoutingDestinationDescription -> ()
rnf CustomRoutingDestinationDescription' {Maybe Natural
Maybe [Protocol]
toPort :: Maybe Natural
protocols :: Maybe [Protocol]
fromPort :: Maybe Natural
$sel:toPort:CustomRoutingDestinationDescription' :: CustomRoutingDestinationDescription -> Maybe Natural
$sel:protocols:CustomRoutingDestinationDescription' :: CustomRoutingDestinationDescription -> Maybe [Protocol]
$sel:fromPort:CustomRoutingDestinationDescription' :: CustomRoutingDestinationDescription -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
fromPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Protocol]
protocols
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
toPort