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

import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.Types.Protocol
import qualified Amazonka.Lens as Lens
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
(CustomRoutingDestinationDescription
 -> CustomRoutingDestinationDescription -> Bool)
-> (CustomRoutingDestinationDescription
    -> CustomRoutingDestinationDescription -> Bool)
-> Eq CustomRoutingDestinationDescription
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]
(Int -> ReadS CustomRoutingDestinationDescription)
-> ReadS [CustomRoutingDestinationDescription]
-> ReadPrec CustomRoutingDestinationDescription
-> ReadPrec [CustomRoutingDestinationDescription]
-> Read 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
(Int -> CustomRoutingDestinationDescription -> ShowS)
-> (CustomRoutingDestinationDescription -> String)
-> ([CustomRoutingDestinationDescription] -> ShowS)
-> Show CustomRoutingDestinationDescription
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.
 CustomRoutingDestinationDescription
 -> Rep CustomRoutingDestinationDescription x)
-> (forall x.
    Rep CustomRoutingDestinationDescription x
    -> CustomRoutingDestinationDescription)
-> Generic CustomRoutingDestinationDescription
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' :: Maybe Natural
-> Maybe [Protocol]
-> Maybe Natural
-> CustomRoutingDestinationDescription
CustomRoutingDestinationDescription'
    { $sel:fromPort:CustomRoutingDestinationDescription' :: Maybe Natural
fromPort =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:protocols:CustomRoutingDestinationDescription' :: Maybe [Protocol]
protocols = Maybe [Protocol]
forall a. Maybe a
Prelude.Nothing,
      $sel:toPort:CustomRoutingDestinationDescription' :: Maybe Natural
toPort = Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural))
-> CustomRoutingDestinationDescription
-> f CustomRoutingDestinationDescription
customRoutingDestinationDescription_fromPort = (CustomRoutingDestinationDescription -> Maybe Natural)
-> (CustomRoutingDestinationDescription
    -> Maybe Natural -> CustomRoutingDestinationDescription)
-> Lens
     CustomRoutingDestinationDescription
     CustomRoutingDestinationDescription
     (Maybe Natural)
     (Maybe Natural)
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 :: (Maybe [Protocol] -> f (Maybe [Protocol]))
-> CustomRoutingDestinationDescription
-> f CustomRoutingDestinationDescription
customRoutingDestinationDescription_protocols = (CustomRoutingDestinationDescription -> Maybe [Protocol])
-> (CustomRoutingDestinationDescription
    -> Maybe [Protocol] -> CustomRoutingDestinationDescription)
-> Lens
     CustomRoutingDestinationDescription
     CustomRoutingDestinationDescription
     (Maybe [Protocol])
     (Maybe [Protocol])
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) ((Maybe [Protocol] -> f (Maybe [Protocol]))
 -> CustomRoutingDestinationDescription
 -> f CustomRoutingDestinationDescription)
-> ((Maybe [Protocol] -> f (Maybe [Protocol]))
    -> Maybe [Protocol] -> f (Maybe [Protocol]))
-> (Maybe [Protocol] -> f (Maybe [Protocol]))
-> CustomRoutingDestinationDescription
-> f CustomRoutingDestinationDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Protocol] [Protocol] [Protocol] [Protocol]
-> Iso
     (Maybe [Protocol])
     (Maybe [Protocol])
     (Maybe [Protocol])
     (Maybe [Protocol])
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 AnIso [Protocol] [Protocol] [Protocol] [Protocol]
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 :: (Maybe Natural -> f (Maybe Natural))
-> CustomRoutingDestinationDescription
-> f CustomRoutingDestinationDescription
customRoutingDestinationDescription_toPort = (CustomRoutingDestinationDescription -> Maybe Natural)
-> (CustomRoutingDestinationDescription
    -> Maybe Natural -> CustomRoutingDestinationDescription)
-> Lens
     CustomRoutingDestinationDescription
     CustomRoutingDestinationDescription
     (Maybe Natural)
     (Maybe Natural)
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
  Core.FromJSON
    CustomRoutingDestinationDescription
  where
  parseJSON :: Value -> Parser CustomRoutingDestinationDescription
parseJSON =
    String
-> (Object -> Parser CustomRoutingDestinationDescription)
-> Value
-> Parser CustomRoutingDestinationDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomRoutingDestinationDescription"
      ( \Object
x ->
          Maybe Natural
-> Maybe [Protocol]
-> Maybe Natural
-> CustomRoutingDestinationDescription
CustomRoutingDestinationDescription'
            (Maybe Natural
 -> Maybe [Protocol]
 -> Maybe Natural
 -> CustomRoutingDestinationDescription)
-> Parser (Maybe Natural)
-> Parser
     (Maybe [Protocol]
      -> Maybe Natural -> CustomRoutingDestinationDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FromPort")
            Parser
  (Maybe [Protocol]
   -> Maybe Natural -> CustomRoutingDestinationDescription)
-> Parser (Maybe [Protocol])
-> Parser (Maybe Natural -> CustomRoutingDestinationDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Protocol]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Protocols" Parser (Maybe (Maybe [Protocol]))
-> Maybe [Protocol] -> Parser (Maybe [Protocol])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Protocol]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Natural -> CustomRoutingDestinationDescription)
-> Parser (Maybe Natural)
-> Parser CustomRoutingDestinationDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ToPort")
      )

instance
  Prelude.Hashable
    CustomRoutingDestinationDescription

instance
  Prelude.NFData
    CustomRoutingDestinationDescription