{-# 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.Inspector2.Types.PortRange
-- 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.Inspector2.Types.PortRange where

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

-- | Details about the port range associated with a finding.
--
-- /See:/ 'newPortRange' smart constructor.
data PortRange = PortRange'
  { -- | The beginning port in a port range.
    PortRange -> Natural
begin :: Prelude.Natural,
    -- | The ending port in a port range.
    PortRange -> Natural
end :: Prelude.Natural
  }
  deriving (PortRange -> PortRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortRange -> PortRange -> Bool
$c/= :: PortRange -> PortRange -> Bool
== :: PortRange -> PortRange -> Bool
$c== :: PortRange -> PortRange -> Bool
Prelude.Eq, ReadPrec [PortRange]
ReadPrec PortRange
Int -> ReadS PortRange
ReadS [PortRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PortRange]
$creadListPrec :: ReadPrec [PortRange]
readPrec :: ReadPrec PortRange
$creadPrec :: ReadPrec PortRange
readList :: ReadS [PortRange]
$creadList :: ReadS [PortRange]
readsPrec :: Int -> ReadS PortRange
$creadsPrec :: Int -> ReadS PortRange
Prelude.Read, Int -> PortRange -> ShowS
[PortRange] -> ShowS
PortRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortRange] -> ShowS
$cshowList :: [PortRange] -> ShowS
show :: PortRange -> String
$cshow :: PortRange -> String
showsPrec :: Int -> PortRange -> ShowS
$cshowsPrec :: Int -> PortRange -> ShowS
Prelude.Show, forall x. Rep PortRange x -> PortRange
forall x. PortRange -> Rep PortRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PortRange x -> PortRange
$cfrom :: forall x. PortRange -> Rep PortRange x
Prelude.Generic)

-- |
-- Create a value of 'PortRange' 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:
--
-- 'begin', 'portRange_begin' - The beginning port in a port range.
--
-- 'end', 'portRange_end' - The ending port in a port range.
newPortRange ::
  -- | 'begin'
  Prelude.Natural ->
  -- | 'end'
  Prelude.Natural ->
  PortRange
newPortRange :: Natural -> Natural -> PortRange
newPortRange Natural
pBegin_ Natural
pEnd_ =
  PortRange' {$sel:begin:PortRange' :: Natural
begin = Natural
pBegin_, $sel:end:PortRange' :: Natural
end = Natural
pEnd_}

-- | The beginning port in a port range.
portRange_begin :: Lens.Lens' PortRange Prelude.Natural
portRange_begin :: Lens' PortRange Natural
portRange_begin = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortRange' {Natural
begin :: Natural
$sel:begin:PortRange' :: PortRange -> Natural
begin} -> Natural
begin) (\s :: PortRange
s@PortRange' {} Natural
a -> PortRange
s {$sel:begin:PortRange' :: Natural
begin = Natural
a} :: PortRange)

-- | The ending port in a port range.
portRange_end :: Lens.Lens' PortRange Prelude.Natural
portRange_end :: Lens' PortRange Natural
portRange_end = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortRange' {Natural
end :: Natural
$sel:end:PortRange' :: PortRange -> Natural
end} -> Natural
end) (\s :: PortRange
s@PortRange' {} Natural
a -> PortRange
s {$sel:end:PortRange' :: Natural
end = Natural
a} :: PortRange)

instance Data.FromJSON PortRange where
  parseJSON :: Value -> Parser PortRange
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PortRange"
      ( \Object
x ->
          Natural -> Natural -> PortRange
PortRange'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"begin")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"end")
      )

instance Prelude.Hashable PortRange where
  hashWithSalt :: Int -> PortRange -> Int
hashWithSalt Int
_salt PortRange' {Natural
end :: Natural
begin :: Natural
$sel:end:PortRange' :: PortRange -> Natural
$sel:begin:PortRange' :: PortRange -> Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
begin
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
end

instance Prelude.NFData PortRange where
  rnf :: PortRange -> ()
rnf PortRange' {Natural
end :: Natural
begin :: Natural
$sel:end:PortRange' :: PortRange -> Natural
$sel:begin:PortRange' :: PortRange -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
begin seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
end