{-# 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.Shield.Types.TimeRange where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data TimeRange = TimeRange'
{
TimeRange -> Maybe POSIX
fromInclusive :: Prelude.Maybe Core.POSIX,
TimeRange -> Maybe POSIX
toExclusive :: Prelude.Maybe Core.POSIX
}
deriving (TimeRange -> TimeRange -> Bool
(TimeRange -> TimeRange -> Bool)
-> (TimeRange -> TimeRange -> Bool) -> Eq TimeRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeRange -> TimeRange -> Bool
$c/= :: TimeRange -> TimeRange -> Bool
== :: TimeRange -> TimeRange -> Bool
$c== :: TimeRange -> TimeRange -> Bool
Prelude.Eq, ReadPrec [TimeRange]
ReadPrec TimeRange
Int -> ReadS TimeRange
ReadS [TimeRange]
(Int -> ReadS TimeRange)
-> ReadS [TimeRange]
-> ReadPrec TimeRange
-> ReadPrec [TimeRange]
-> Read TimeRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimeRange]
$creadListPrec :: ReadPrec [TimeRange]
readPrec :: ReadPrec TimeRange
$creadPrec :: ReadPrec TimeRange
readList :: ReadS [TimeRange]
$creadList :: ReadS [TimeRange]
readsPrec :: Int -> ReadS TimeRange
$creadsPrec :: Int -> ReadS TimeRange
Prelude.Read, Int -> TimeRange -> ShowS
[TimeRange] -> ShowS
TimeRange -> String
(Int -> TimeRange -> ShowS)
-> (TimeRange -> String)
-> ([TimeRange] -> ShowS)
-> Show TimeRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeRange] -> ShowS
$cshowList :: [TimeRange] -> ShowS
show :: TimeRange -> String
$cshow :: TimeRange -> String
showsPrec :: Int -> TimeRange -> ShowS
$cshowsPrec :: Int -> TimeRange -> ShowS
Prelude.Show, (forall x. TimeRange -> Rep TimeRange x)
-> (forall x. Rep TimeRange x -> TimeRange) -> Generic TimeRange
forall x. Rep TimeRange x -> TimeRange
forall x. TimeRange -> Rep TimeRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeRange x -> TimeRange
$cfrom :: forall x. TimeRange -> Rep TimeRange x
Prelude.Generic)
newTimeRange ::
TimeRange
newTimeRange :: TimeRange
newTimeRange =
TimeRange' :: Maybe POSIX -> Maybe POSIX -> TimeRange
TimeRange'
{ $sel:fromInclusive:TimeRange' :: Maybe POSIX
fromInclusive = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
$sel:toExclusive:TimeRange' :: Maybe POSIX
toExclusive = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
}
timeRange_fromInclusive :: Lens.Lens' TimeRange (Prelude.Maybe Prelude.UTCTime)
timeRange_fromInclusive :: (Maybe UTCTime -> f (Maybe UTCTime)) -> TimeRange -> f TimeRange
timeRange_fromInclusive = (TimeRange -> Maybe POSIX)
-> (TimeRange -> Maybe POSIX -> TimeRange)
-> Lens TimeRange TimeRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeRange' {Maybe POSIX
fromInclusive :: Maybe POSIX
$sel:fromInclusive:TimeRange' :: TimeRange -> Maybe POSIX
fromInclusive} -> Maybe POSIX
fromInclusive) (\s :: TimeRange
s@TimeRange' {} Maybe POSIX
a -> TimeRange
s {$sel:fromInclusive:TimeRange' :: Maybe POSIX
fromInclusive = Maybe POSIX
a} :: TimeRange) ((Maybe POSIX -> f (Maybe POSIX)) -> TimeRange -> f TimeRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
-> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TimeRange
-> f TimeRange
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
timeRange_toExclusive :: Lens.Lens' TimeRange (Prelude.Maybe Prelude.UTCTime)
timeRange_toExclusive :: (Maybe UTCTime -> f (Maybe UTCTime)) -> TimeRange -> f TimeRange
timeRange_toExclusive = (TimeRange -> Maybe POSIX)
-> (TimeRange -> Maybe POSIX -> TimeRange)
-> Lens TimeRange TimeRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeRange' {Maybe POSIX
toExclusive :: Maybe POSIX
$sel:toExclusive:TimeRange' :: TimeRange -> Maybe POSIX
toExclusive} -> Maybe POSIX
toExclusive) (\s :: TimeRange
s@TimeRange' {} Maybe POSIX
a -> TimeRange
s {$sel:toExclusive:TimeRange' :: Maybe POSIX
toExclusive = Maybe POSIX
a} :: TimeRange) ((Maybe POSIX -> f (Maybe POSIX)) -> TimeRange -> f TimeRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
-> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TimeRange
-> f TimeRange
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 Core.FromJSON TimeRange where
parseJSON :: Value -> Parser TimeRange
parseJSON =
String -> (Object -> Parser TimeRange) -> Value -> Parser TimeRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"TimeRange"
( \Object
x ->
Maybe POSIX -> Maybe POSIX -> TimeRange
TimeRange'
(Maybe POSIX -> Maybe POSIX -> TimeRange)
-> Parser (Maybe POSIX) -> Parser (Maybe POSIX -> TimeRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FromInclusive")
Parser (Maybe POSIX -> TimeRange)
-> Parser (Maybe POSIX) -> Parser TimeRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ToExclusive")
)
instance Prelude.Hashable TimeRange
instance Prelude.NFData TimeRange
instance Core.ToJSON TimeRange where
toJSON :: TimeRange -> Value
toJSON TimeRange' {Maybe POSIX
toExclusive :: Maybe POSIX
fromInclusive :: Maybe POSIX
$sel:toExclusive:TimeRange' :: TimeRange -> Maybe POSIX
$sel:fromInclusive:TimeRange' :: TimeRange -> Maybe POSIX
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"FromInclusive" 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
fromInclusive,
(Text
"ToExclusive" 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
toExclusive
]
)