{-# 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.Inspector.Types.DurationRange
-- 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.Inspector.Types.DurationRange 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

-- | This data type is used in the AssessmentTemplateFilter data type.
--
-- /See:/ 'newDurationRange' smart constructor.
data DurationRange = DurationRange'
  { -- | The maximum value of the duration range. Must be less than or equal to
    -- 604800 seconds (1 week).
    DurationRange -> Maybe Natural
maxSeconds :: Prelude.Maybe Prelude.Natural,
    -- | The minimum value of the duration range. Must be greater than zero.
    DurationRange -> Maybe Natural
minSeconds :: Prelude.Maybe Prelude.Natural
  }
  deriving (DurationRange -> DurationRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DurationRange -> DurationRange -> Bool
$c/= :: DurationRange -> DurationRange -> Bool
== :: DurationRange -> DurationRange -> Bool
$c== :: DurationRange -> DurationRange -> Bool
Prelude.Eq, ReadPrec [DurationRange]
ReadPrec DurationRange
Int -> ReadS DurationRange
ReadS [DurationRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DurationRange]
$creadListPrec :: ReadPrec [DurationRange]
readPrec :: ReadPrec DurationRange
$creadPrec :: ReadPrec DurationRange
readList :: ReadS [DurationRange]
$creadList :: ReadS [DurationRange]
readsPrec :: Int -> ReadS DurationRange
$creadsPrec :: Int -> ReadS DurationRange
Prelude.Read, Int -> DurationRange -> ShowS
[DurationRange] -> ShowS
DurationRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DurationRange] -> ShowS
$cshowList :: [DurationRange] -> ShowS
show :: DurationRange -> String
$cshow :: DurationRange -> String
showsPrec :: Int -> DurationRange -> ShowS
$cshowsPrec :: Int -> DurationRange -> ShowS
Prelude.Show, forall x. Rep DurationRange x -> DurationRange
forall x. DurationRange -> Rep DurationRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DurationRange x -> DurationRange
$cfrom :: forall x. DurationRange -> Rep DurationRange x
Prelude.Generic)

-- |
-- Create a value of 'DurationRange' 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:
--
-- 'maxSeconds', 'durationRange_maxSeconds' - The maximum value of the duration range. Must be less than or equal to
-- 604800 seconds (1 week).
--
-- 'minSeconds', 'durationRange_minSeconds' - The minimum value of the duration range. Must be greater than zero.
newDurationRange ::
  DurationRange
newDurationRange :: DurationRange
newDurationRange =
  DurationRange'
    { $sel:maxSeconds:DurationRange' :: Maybe Natural
maxSeconds = forall a. Maybe a
Prelude.Nothing,
      $sel:minSeconds:DurationRange' :: Maybe Natural
minSeconds = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum value of the duration range. Must be less than or equal to
-- 604800 seconds (1 week).
durationRange_maxSeconds :: Lens.Lens' DurationRange (Prelude.Maybe Prelude.Natural)
durationRange_maxSeconds :: Lens' DurationRange (Maybe Natural)
durationRange_maxSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DurationRange' {Maybe Natural
maxSeconds :: Maybe Natural
$sel:maxSeconds:DurationRange' :: DurationRange -> Maybe Natural
maxSeconds} -> Maybe Natural
maxSeconds) (\s :: DurationRange
s@DurationRange' {} Maybe Natural
a -> DurationRange
s {$sel:maxSeconds:DurationRange' :: Maybe Natural
maxSeconds = Maybe Natural
a} :: DurationRange)

-- | The minimum value of the duration range. Must be greater than zero.
durationRange_minSeconds :: Lens.Lens' DurationRange (Prelude.Maybe Prelude.Natural)
durationRange_minSeconds :: Lens' DurationRange (Maybe Natural)
durationRange_minSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DurationRange' {Maybe Natural
minSeconds :: Maybe Natural
$sel:minSeconds:DurationRange' :: DurationRange -> Maybe Natural
minSeconds} -> Maybe Natural
minSeconds) (\s :: DurationRange
s@DurationRange' {} Maybe Natural
a -> DurationRange
s {$sel:minSeconds:DurationRange' :: Maybe Natural
minSeconds = Maybe Natural
a} :: DurationRange)

instance Prelude.Hashable DurationRange where
  hashWithSalt :: Int -> DurationRange -> Int
hashWithSalt Int
_salt DurationRange' {Maybe Natural
minSeconds :: Maybe Natural
maxSeconds :: Maybe Natural
$sel:minSeconds:DurationRange' :: DurationRange -> Maybe Natural
$sel:maxSeconds:DurationRange' :: DurationRange -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
minSeconds

instance Prelude.NFData DurationRange where
  rnf :: DurationRange -> ()
rnf DurationRange' {Maybe Natural
minSeconds :: Maybe Natural
maxSeconds :: Maybe Natural
$sel:minSeconds:DurationRange' :: DurationRange -> Maybe Natural
$sel:maxSeconds:DurationRange' :: DurationRange -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
minSeconds

instance Data.ToJSON DurationRange where
  toJSON :: DurationRange -> Value
toJSON DurationRange' {Maybe Natural
minSeconds :: Maybe Natural
maxSeconds :: Maybe Natural
$sel:minSeconds:DurationRange' :: DurationRange -> Maybe Natural
$sel:maxSeconds:DurationRange' :: DurationRange -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxSeconds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxSeconds,
            (Key
"minSeconds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
minSeconds
          ]
      )