{-# 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.TimestampRange
-- 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.TimestampRange 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 AssessmentRunFilter data type.
--
-- /See:/ 'newTimestampRange' smart constructor.
data TimestampRange = TimestampRange'
  { -- | The maximum value of the timestamp range.
    TimestampRange -> Maybe POSIX
endDate :: Prelude.Maybe Core.POSIX,
    -- | The minimum value of the timestamp range.
    TimestampRange -> Maybe POSIX
beginDate :: Prelude.Maybe Core.POSIX
  }
  deriving (TimestampRange -> TimestampRange -> Bool
(TimestampRange -> TimestampRange -> Bool)
-> (TimestampRange -> TimestampRange -> Bool) -> Eq TimestampRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimestampRange -> TimestampRange -> Bool
$c/= :: TimestampRange -> TimestampRange -> Bool
== :: TimestampRange -> TimestampRange -> Bool
$c== :: TimestampRange -> TimestampRange -> Bool
Prelude.Eq, ReadPrec [TimestampRange]
ReadPrec TimestampRange
Int -> ReadS TimestampRange
ReadS [TimestampRange]
(Int -> ReadS TimestampRange)
-> ReadS [TimestampRange]
-> ReadPrec TimestampRange
-> ReadPrec [TimestampRange]
-> Read TimestampRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimestampRange]
$creadListPrec :: ReadPrec [TimestampRange]
readPrec :: ReadPrec TimestampRange
$creadPrec :: ReadPrec TimestampRange
readList :: ReadS [TimestampRange]
$creadList :: ReadS [TimestampRange]
readsPrec :: Int -> ReadS TimestampRange
$creadsPrec :: Int -> ReadS TimestampRange
Prelude.Read, Int -> TimestampRange -> ShowS
[TimestampRange] -> ShowS
TimestampRange -> String
(Int -> TimestampRange -> ShowS)
-> (TimestampRange -> String)
-> ([TimestampRange] -> ShowS)
-> Show TimestampRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimestampRange] -> ShowS
$cshowList :: [TimestampRange] -> ShowS
show :: TimestampRange -> String
$cshow :: TimestampRange -> String
showsPrec :: Int -> TimestampRange -> ShowS
$cshowsPrec :: Int -> TimestampRange -> ShowS
Prelude.Show, (forall x. TimestampRange -> Rep TimestampRange x)
-> (forall x. Rep TimestampRange x -> TimestampRange)
-> Generic TimestampRange
forall x. Rep TimestampRange x -> TimestampRange
forall x. TimestampRange -> Rep TimestampRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimestampRange x -> TimestampRange
$cfrom :: forall x. TimestampRange -> Rep TimestampRange x
Prelude.Generic)

-- |
-- Create a value of 'TimestampRange' 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:
--
-- 'endDate', 'timestampRange_endDate' - The maximum value of the timestamp range.
--
-- 'beginDate', 'timestampRange_beginDate' - The minimum value of the timestamp range.
newTimestampRange ::
  TimestampRange
newTimestampRange :: TimestampRange
newTimestampRange =
  TimestampRange' :: Maybe POSIX -> Maybe POSIX -> TimestampRange
TimestampRange'
    { $sel:endDate:TimestampRange' :: Maybe POSIX
endDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:beginDate:TimestampRange' :: Maybe POSIX
beginDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum value of the timestamp range.
timestampRange_endDate :: Lens.Lens' TimestampRange (Prelude.Maybe Prelude.UTCTime)
timestampRange_endDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TimestampRange -> f TimestampRange
timestampRange_endDate = (TimestampRange -> Maybe POSIX)
-> (TimestampRange -> Maybe POSIX -> TimestampRange)
-> Lens TimestampRange TimestampRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestampRange' {Maybe POSIX
endDate :: Maybe POSIX
$sel:endDate:TimestampRange' :: TimestampRange -> Maybe POSIX
endDate} -> Maybe POSIX
endDate) (\s :: TimestampRange
s@TimestampRange' {} Maybe POSIX
a -> TimestampRange
s {$sel:endDate:TimestampRange' :: Maybe POSIX
endDate = Maybe POSIX
a} :: TimestampRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> TimestampRange -> f TimestampRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TimestampRange
-> f TimestampRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The minimum value of the timestamp range.
timestampRange_beginDate :: Lens.Lens' TimestampRange (Prelude.Maybe Prelude.UTCTime)
timestampRange_beginDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TimestampRange -> f TimestampRange
timestampRange_beginDate = (TimestampRange -> Maybe POSIX)
-> (TimestampRange -> Maybe POSIX -> TimestampRange)
-> Lens TimestampRange TimestampRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestampRange' {Maybe POSIX
beginDate :: Maybe POSIX
$sel:beginDate:TimestampRange' :: TimestampRange -> Maybe POSIX
beginDate} -> Maybe POSIX
beginDate) (\s :: TimestampRange
s@TimestampRange' {} Maybe POSIX
a -> TimestampRange
s {$sel:beginDate:TimestampRange' :: Maybe POSIX
beginDate = Maybe POSIX
a} :: TimestampRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> TimestampRange -> f TimestampRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TimestampRange
-> f TimestampRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Prelude.Hashable TimestampRange

instance Prelude.NFData TimestampRange

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