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

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

-- | This data type is used in the AssessmentTemplateFilter data type.
--
-- /See:/ 'newDurationRange' smart constructor.
data DurationRange = DurationRange'
  { -- | The minimum value of the duration range. Must be greater than zero.
    DurationRange -> Maybe Natural
minSeconds :: Prelude.Maybe Prelude.Natural,
    -- | 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
  }
  deriving (DurationRange -> DurationRange -> Bool
(DurationRange -> DurationRange -> Bool)
-> (DurationRange -> DurationRange -> Bool) -> Eq DurationRange
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]
(Int -> ReadS DurationRange)
-> ReadS [DurationRange]
-> ReadPrec DurationRange
-> ReadPrec [DurationRange]
-> Read 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
(Int -> DurationRange -> ShowS)
-> (DurationRange -> String)
-> ([DurationRange] -> ShowS)
-> Show DurationRange
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. DurationRange -> Rep DurationRange x)
-> (forall x. Rep DurationRange x -> DurationRange)
-> Generic DurationRange
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:
--
-- 'minSeconds', 'durationRange_minSeconds' - The minimum value of the duration range. Must be greater than zero.
--
-- 'maxSeconds', 'durationRange_maxSeconds' - The maximum value of the duration range. Must be less than or equal to
-- 604800 seconds (1 week).
newDurationRange ::
  DurationRange
newDurationRange :: DurationRange
newDurationRange =
  DurationRange' :: Maybe Natural -> Maybe Natural -> DurationRange
DurationRange'
    { $sel:minSeconds:DurationRange' :: Maybe Natural
minSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maxSeconds:DurationRange' :: Maybe Natural
maxSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The minimum value of the duration range. Must be greater than zero.
durationRange_minSeconds :: Lens.Lens' DurationRange (Prelude.Maybe Prelude.Natural)
durationRange_minSeconds :: (Maybe Natural -> f (Maybe Natural))
-> DurationRange -> f DurationRange
durationRange_minSeconds = (DurationRange -> Maybe Natural)
-> (DurationRange -> Maybe Natural -> DurationRange)
-> Lens DurationRange DurationRange (Maybe Natural) (Maybe Natural)
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)

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> DurationRange -> f DurationRange
durationRange_maxSeconds = (DurationRange -> Maybe Natural)
-> (DurationRange -> Maybe Natural -> DurationRange)
-> Lens DurationRange DurationRange (Maybe Natural) (Maybe Natural)
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)

instance Prelude.Hashable DurationRange

instance Prelude.NFData DurationRange

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