{-# 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.TrafficMirrorPortRangeRequest
-- 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.TrafficMirrorPortRangeRequest 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

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

-- |
-- Create a value of 'TrafficMirrorPortRangeRequest' 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', 'trafficMirrorPortRangeRequest_fromPort' - The first port in the Traffic Mirror port range. This applies to the TCP
-- and UDP protocols.
--
-- 'toPort', 'trafficMirrorPortRangeRequest_toPort' - The last port in the Traffic Mirror port range. This applies to the TCP
-- and UDP protocols.
newTrafficMirrorPortRangeRequest ::
  TrafficMirrorPortRangeRequest
newTrafficMirrorPortRangeRequest :: TrafficMirrorPortRangeRequest
newTrafficMirrorPortRangeRequest =
  TrafficMirrorPortRangeRequest'
    { $sel:fromPort:TrafficMirrorPortRangeRequest' :: Maybe Int
fromPort =
        forall a. Maybe a
Prelude.Nothing,
      $sel:toPort:TrafficMirrorPortRangeRequest' :: Maybe Int
toPort = forall a. Maybe a
Prelude.Nothing
    }

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

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

instance
  Prelude.Hashable
    TrafficMirrorPortRangeRequest
  where
  hashWithSalt :: Int -> TrafficMirrorPortRangeRequest -> Int
hashWithSalt Int
_salt TrafficMirrorPortRangeRequest' {Maybe Int
toPort :: Maybe Int
fromPort :: Maybe Int
$sel:toPort:TrafficMirrorPortRangeRequest' :: TrafficMirrorPortRangeRequest -> Maybe Int
$sel:fromPort:TrafficMirrorPortRangeRequest' :: TrafficMirrorPortRangeRequest -> 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 TrafficMirrorPortRangeRequest where
  rnf :: TrafficMirrorPortRangeRequest -> ()
rnf TrafficMirrorPortRangeRequest' {Maybe Int
toPort :: Maybe Int
fromPort :: Maybe Int
$sel:toPort:TrafficMirrorPortRangeRequest' :: TrafficMirrorPortRangeRequest -> Maybe Int
$sel:fromPort:TrafficMirrorPortRangeRequest' :: TrafficMirrorPortRangeRequest -> 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

instance Data.ToQuery TrafficMirrorPortRangeRequest where
  toQuery :: TrafficMirrorPortRangeRequest -> QueryString
toQuery TrafficMirrorPortRangeRequest' {Maybe Int
toPort :: Maybe Int
fromPort :: Maybe Int
$sel:toPort:TrafficMirrorPortRangeRequest' :: TrafficMirrorPortRangeRequest -> Maybe Int
$sel:fromPort:TrafficMirrorPortRangeRequest' :: TrafficMirrorPortRangeRequest -> Maybe Int
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"FromPort" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
fromPort,
        ByteString
"ToPort" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
toPort
      ]