{-# 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.EC2.Types.TrafficMirrorPortRange
-- 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.EC2.Types.TrafficMirrorPortRange where

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

-- | Describes the Traffic Mirror port range.
--
-- /See:/ 'newTrafficMirrorPortRange' smart constructor.
data TrafficMirrorPortRange = TrafficMirrorPortRange'
  { -- | The start of the Traffic Mirror port range. This applies to the TCP and
    -- UDP protocols.
    TrafficMirrorPortRange -> Maybe Int
fromPort :: Prelude.Maybe Prelude.Int,
    -- | The end of the Traffic Mirror port range. This applies to the TCP and
    -- UDP protocols.
    TrafficMirrorPortRange -> Maybe Int
toPort :: Prelude.Maybe Prelude.Int
  }
  deriving (TrafficMirrorPortRange -> TrafficMirrorPortRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrafficMirrorPortRange -> TrafficMirrorPortRange -> Bool
$c/= :: TrafficMirrorPortRange -> TrafficMirrorPortRange -> Bool
== :: TrafficMirrorPortRange -> TrafficMirrorPortRange -> Bool
$c== :: TrafficMirrorPortRange -> TrafficMirrorPortRange -> Bool
Prelude.Eq, ReadPrec [TrafficMirrorPortRange]
ReadPrec TrafficMirrorPortRange
Int -> ReadS TrafficMirrorPortRange
ReadS [TrafficMirrorPortRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrafficMirrorPortRange]
$creadListPrec :: ReadPrec [TrafficMirrorPortRange]
readPrec :: ReadPrec TrafficMirrorPortRange
$creadPrec :: ReadPrec TrafficMirrorPortRange
readList :: ReadS [TrafficMirrorPortRange]
$creadList :: ReadS [TrafficMirrorPortRange]
readsPrec :: Int -> ReadS TrafficMirrorPortRange
$creadsPrec :: Int -> ReadS TrafficMirrorPortRange
Prelude.Read, Int -> TrafficMirrorPortRange -> ShowS
[TrafficMirrorPortRange] -> ShowS
TrafficMirrorPortRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrafficMirrorPortRange] -> ShowS
$cshowList :: [TrafficMirrorPortRange] -> ShowS
show :: TrafficMirrorPortRange -> String
$cshow :: TrafficMirrorPortRange -> String
showsPrec :: Int -> TrafficMirrorPortRange -> ShowS
$cshowsPrec :: Int -> TrafficMirrorPortRange -> ShowS
Prelude.Show, forall x. Rep TrafficMirrorPortRange x -> TrafficMirrorPortRange
forall x. TrafficMirrorPortRange -> Rep TrafficMirrorPortRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrafficMirrorPortRange x -> TrafficMirrorPortRange
$cfrom :: forall x. TrafficMirrorPortRange -> Rep TrafficMirrorPortRange x
Prelude.Generic)

-- |
-- Create a value of 'TrafficMirrorPortRange' 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', 'trafficMirrorPortRange_fromPort' - The start of the Traffic Mirror port range. This applies to the TCP and
-- UDP protocols.
--
-- 'toPort', 'trafficMirrorPortRange_toPort' - The end of the Traffic Mirror port range. This applies to the TCP and
-- UDP protocols.
newTrafficMirrorPortRange ::
  TrafficMirrorPortRange
newTrafficMirrorPortRange :: TrafficMirrorPortRange
newTrafficMirrorPortRange =
  TrafficMirrorPortRange'
    { $sel:fromPort:TrafficMirrorPortRange' :: Maybe Int
fromPort = forall a. Maybe a
Prelude.Nothing,
      $sel:toPort:TrafficMirrorPortRange' :: Maybe Int
toPort = forall a. Maybe a
Prelude.Nothing
    }

-- | The start of the Traffic Mirror port range. This applies to the TCP and
-- UDP protocols.
trafficMirrorPortRange_fromPort :: Lens.Lens' TrafficMirrorPortRange (Prelude.Maybe Prelude.Int)
trafficMirrorPortRange_fromPort :: Lens' TrafficMirrorPortRange (Maybe Int)
trafficMirrorPortRange_fromPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficMirrorPortRange' {Maybe Int
fromPort :: Maybe Int
$sel:fromPort:TrafficMirrorPortRange' :: TrafficMirrorPortRange -> Maybe Int
fromPort} -> Maybe Int
fromPort) (\s :: TrafficMirrorPortRange
s@TrafficMirrorPortRange' {} Maybe Int
a -> TrafficMirrorPortRange
s {$sel:fromPort:TrafficMirrorPortRange' :: Maybe Int
fromPort = Maybe Int
a} :: TrafficMirrorPortRange)

-- | The end of the Traffic Mirror port range. This applies to the TCP and
-- UDP protocols.
trafficMirrorPortRange_toPort :: Lens.Lens' TrafficMirrorPortRange (Prelude.Maybe Prelude.Int)
trafficMirrorPortRange_toPort :: Lens' TrafficMirrorPortRange (Maybe Int)
trafficMirrorPortRange_toPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrafficMirrorPortRange' {Maybe Int
toPort :: Maybe Int
$sel:toPort:TrafficMirrorPortRange' :: TrafficMirrorPortRange -> Maybe Int
toPort} -> Maybe Int
toPort) (\s :: TrafficMirrorPortRange
s@TrafficMirrorPortRange' {} Maybe Int
a -> TrafficMirrorPortRange
s {$sel:toPort:TrafficMirrorPortRange' :: Maybe Int
toPort = Maybe Int
a} :: TrafficMirrorPortRange)

instance Data.FromXML TrafficMirrorPortRange where
  parseXML :: [Node] -> Either String TrafficMirrorPortRange
parseXML [Node]
x =
    Maybe Int -> Maybe Int -> TrafficMirrorPortRange
TrafficMirrorPortRange'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"fromPort")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"toPort")

instance Prelude.Hashable TrafficMirrorPortRange where
  hashWithSalt :: Int -> TrafficMirrorPortRange -> Int
hashWithSalt Int
_salt TrafficMirrorPortRange' {Maybe Int
toPort :: Maybe Int
fromPort :: Maybe Int
$sel:toPort:TrafficMirrorPortRange' :: TrafficMirrorPortRange -> Maybe Int
$sel:fromPort:TrafficMirrorPortRange' :: TrafficMirrorPortRange -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
fromPort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
toPort

instance Prelude.NFData TrafficMirrorPortRange where
  rnf :: TrafficMirrorPortRange -> ()
rnf TrafficMirrorPortRange' {Maybe Int
toPort :: Maybe Int
fromPort :: Maybe Int
$sel:toPort:TrafficMirrorPortRange' :: TrafficMirrorPortRange -> Maybe Int
$sel:fromPort:TrafficMirrorPortRange' :: TrafficMirrorPortRange -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
fromPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
toPort