{-# 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 #-}
module Amazonka.WAFRegional.Types.TimeWindow where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data TimeWindow = TimeWindow'
{
TimeWindow -> POSIX
startTime :: Core.POSIX,
TimeWindow -> POSIX
endTime :: Core.POSIX
}
deriving (TimeWindow -> TimeWindow -> Bool
(TimeWindow -> TimeWindow -> Bool)
-> (TimeWindow -> TimeWindow -> Bool) -> Eq TimeWindow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeWindow -> TimeWindow -> Bool
$c/= :: TimeWindow -> TimeWindow -> Bool
== :: TimeWindow -> TimeWindow -> Bool
$c== :: TimeWindow -> TimeWindow -> Bool
Prelude.Eq, ReadPrec [TimeWindow]
ReadPrec TimeWindow
Int -> ReadS TimeWindow
ReadS [TimeWindow]
(Int -> ReadS TimeWindow)
-> ReadS [TimeWindow]
-> ReadPrec TimeWindow
-> ReadPrec [TimeWindow]
-> Read TimeWindow
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimeWindow]
$creadListPrec :: ReadPrec [TimeWindow]
readPrec :: ReadPrec TimeWindow
$creadPrec :: ReadPrec TimeWindow
readList :: ReadS [TimeWindow]
$creadList :: ReadS [TimeWindow]
readsPrec :: Int -> ReadS TimeWindow
$creadsPrec :: Int -> ReadS TimeWindow
Prelude.Read, Int -> TimeWindow -> ShowS
[TimeWindow] -> ShowS
TimeWindow -> String
(Int -> TimeWindow -> ShowS)
-> (TimeWindow -> String)
-> ([TimeWindow] -> ShowS)
-> Show TimeWindow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeWindow] -> ShowS
$cshowList :: [TimeWindow] -> ShowS
show :: TimeWindow -> String
$cshow :: TimeWindow -> String
showsPrec :: Int -> TimeWindow -> ShowS
$cshowsPrec :: Int -> TimeWindow -> ShowS
Prelude.Show, (forall x. TimeWindow -> Rep TimeWindow x)
-> (forall x. Rep TimeWindow x -> TimeWindow) -> Generic TimeWindow
forall x. Rep TimeWindow x -> TimeWindow
forall x. TimeWindow -> Rep TimeWindow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeWindow x -> TimeWindow
$cfrom :: forall x. TimeWindow -> Rep TimeWindow x
Prelude.Generic)
newTimeWindow ::
Prelude.UTCTime ->
Prelude.UTCTime ->
TimeWindow
newTimeWindow :: UTCTime -> UTCTime -> TimeWindow
newTimeWindow UTCTime
pStartTime_ UTCTime
pEndTime_ =
TimeWindow' :: POSIX -> POSIX -> TimeWindow
TimeWindow'
{ $sel:startTime:TimeWindow' :: POSIX
startTime =
Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
-> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
$sel:endTime:TimeWindow' :: POSIX
endTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
-> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_
}
timeWindow_startTime :: Lens.Lens' TimeWindow Prelude.UTCTime
timeWindow_startTime :: (UTCTime -> f UTCTime) -> TimeWindow -> f TimeWindow
timeWindow_startTime = (TimeWindow -> POSIX)
-> (TimeWindow -> POSIX -> TimeWindow)
-> Lens TimeWindow TimeWindow POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeWindow' {POSIX
startTime :: POSIX
$sel:startTime:TimeWindow' :: TimeWindow -> POSIX
startTime} -> POSIX
startTime) (\s :: TimeWindow
s@TimeWindow' {} POSIX
a -> TimeWindow
s {$sel:startTime:TimeWindow' :: POSIX
startTime = POSIX
a} :: TimeWindow) ((POSIX -> f POSIX) -> TimeWindow -> f TimeWindow)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> TimeWindow
-> f TimeWindow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time
timeWindow_endTime :: Lens.Lens' TimeWindow Prelude.UTCTime
timeWindow_endTime :: (UTCTime -> f UTCTime) -> TimeWindow -> f TimeWindow
timeWindow_endTime = (TimeWindow -> POSIX)
-> (TimeWindow -> POSIX -> TimeWindow)
-> Lens TimeWindow TimeWindow POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeWindow' {POSIX
endTime :: POSIX
$sel:endTime:TimeWindow' :: TimeWindow -> POSIX
endTime} -> POSIX
endTime) (\s :: TimeWindow
s@TimeWindow' {} POSIX
a -> TimeWindow
s {$sel:endTime:TimeWindow' :: POSIX
endTime = POSIX
a} :: TimeWindow) ((POSIX -> f POSIX) -> TimeWindow -> f TimeWindow)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> TimeWindow
-> f TimeWindow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time
instance Core.FromJSON TimeWindow where
parseJSON :: Value -> Parser TimeWindow
parseJSON =
String
-> (Object -> Parser TimeWindow) -> Value -> Parser TimeWindow
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"TimeWindow"
( \Object
x ->
POSIX -> POSIX -> TimeWindow
TimeWindow'
(POSIX -> POSIX -> TimeWindow)
-> Parser POSIX -> Parser (POSIX -> TimeWindow)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"StartTime")
Parser (POSIX -> TimeWindow) -> Parser POSIX -> Parser TimeWindow
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EndTime")
)
instance Prelude.Hashable TimeWindow
instance Prelude.NFData TimeWindow
instance Core.ToJSON TimeWindow where
toJSON :: TimeWindow -> Value
toJSON TimeWindow' {POSIX
endTime :: POSIX
startTime :: POSIX
$sel:endTime:TimeWindow' :: TimeWindow -> POSIX
$sel:startTime:TimeWindow' :: TimeWindow -> POSIX
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StartTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
startTime),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EndTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
endTime)
]
)