{-# 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.Budgets.Types.TimePeriod where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data TimePeriod = TimePeriod'
{
TimePeriod -> Maybe POSIX
start :: Prelude.Maybe Core.POSIX,
TimePeriod -> Maybe POSIX
end :: Prelude.Maybe Core.POSIX
}
deriving (TimePeriod -> TimePeriod -> Bool
(TimePeriod -> TimePeriod -> Bool)
-> (TimePeriod -> TimePeriod -> Bool) -> Eq TimePeriod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimePeriod -> TimePeriod -> Bool
$c/= :: TimePeriod -> TimePeriod -> Bool
== :: TimePeriod -> TimePeriod -> Bool
$c== :: TimePeriod -> TimePeriod -> Bool
Prelude.Eq, ReadPrec [TimePeriod]
ReadPrec TimePeriod
Int -> ReadS TimePeriod
ReadS [TimePeriod]
(Int -> ReadS TimePeriod)
-> ReadS [TimePeriod]
-> ReadPrec TimePeriod
-> ReadPrec [TimePeriod]
-> Read TimePeriod
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimePeriod]
$creadListPrec :: ReadPrec [TimePeriod]
readPrec :: ReadPrec TimePeriod
$creadPrec :: ReadPrec TimePeriod
readList :: ReadS [TimePeriod]
$creadList :: ReadS [TimePeriod]
readsPrec :: Int -> ReadS TimePeriod
$creadsPrec :: Int -> ReadS TimePeriod
Prelude.Read, Int -> TimePeriod -> ShowS
[TimePeriod] -> ShowS
TimePeriod -> String
(Int -> TimePeriod -> ShowS)
-> (TimePeriod -> String)
-> ([TimePeriod] -> ShowS)
-> Show TimePeriod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimePeriod] -> ShowS
$cshowList :: [TimePeriod] -> ShowS
show :: TimePeriod -> String
$cshow :: TimePeriod -> String
showsPrec :: Int -> TimePeriod -> ShowS
$cshowsPrec :: Int -> TimePeriod -> ShowS
Prelude.Show, (forall x. TimePeriod -> Rep TimePeriod x)
-> (forall x. Rep TimePeriod x -> TimePeriod) -> Generic TimePeriod
forall x. Rep TimePeriod x -> TimePeriod
forall x. TimePeriod -> Rep TimePeriod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimePeriod x -> TimePeriod
$cfrom :: forall x. TimePeriod -> Rep TimePeriod x
Prelude.Generic)
newTimePeriod ::
TimePeriod
newTimePeriod :: TimePeriod
newTimePeriod =
TimePeriod' :: Maybe POSIX -> Maybe POSIX -> TimePeriod
TimePeriod'
{ $sel:start:TimePeriod' :: Maybe POSIX
start = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
$sel:end:TimePeriod' :: Maybe POSIX
end = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
}
timePeriod_start :: Lens.Lens' TimePeriod (Prelude.Maybe Prelude.UTCTime)
timePeriod_start :: (Maybe UTCTime -> f (Maybe UTCTime)) -> TimePeriod -> f TimePeriod
timePeriod_start = (TimePeriod -> Maybe POSIX)
-> (TimePeriod -> Maybe POSIX -> TimePeriod)
-> Lens TimePeriod TimePeriod (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimePeriod' {Maybe POSIX
start :: Maybe POSIX
$sel:start:TimePeriod' :: TimePeriod -> Maybe POSIX
start} -> Maybe POSIX
start) (\s :: TimePeriod
s@TimePeriod' {} Maybe POSIX
a -> TimePeriod
s {$sel:start:TimePeriod' :: Maybe POSIX
start = Maybe POSIX
a} :: TimePeriod) ((Maybe POSIX -> f (Maybe POSIX)) -> TimePeriod -> f TimePeriod)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
-> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TimePeriod
-> f TimePeriod
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
timePeriod_end :: Lens.Lens' TimePeriod (Prelude.Maybe Prelude.UTCTime)
timePeriod_end :: (Maybe UTCTime -> f (Maybe UTCTime)) -> TimePeriod -> f TimePeriod
timePeriod_end = (TimePeriod -> Maybe POSIX)
-> (TimePeriod -> Maybe POSIX -> TimePeriod)
-> Lens TimePeriod TimePeriod (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimePeriod' {Maybe POSIX
end :: Maybe POSIX
$sel:end:TimePeriod' :: TimePeriod -> Maybe POSIX
end} -> Maybe POSIX
end) (\s :: TimePeriod
s@TimePeriod' {} Maybe POSIX
a -> TimePeriod
s {$sel:end:TimePeriod' :: Maybe POSIX
end = Maybe POSIX
a} :: TimePeriod) ((Maybe POSIX -> f (Maybe POSIX)) -> TimePeriod -> f TimePeriod)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
-> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TimePeriod
-> f TimePeriod
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 TimePeriod where
parseJSON :: Value -> Parser TimePeriod
parseJSON =
String
-> (Object -> Parser TimePeriod) -> Value -> Parser TimePeriod
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"TimePeriod"
( \Object
x ->
Maybe POSIX -> Maybe POSIX -> TimePeriod
TimePeriod'
(Maybe POSIX -> Maybe POSIX -> TimePeriod)
-> Parser (Maybe POSIX) -> Parser (Maybe POSIX -> TimePeriod)
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
"Start") Parser (Maybe POSIX -> TimePeriod)
-> Parser (Maybe POSIX) -> Parser TimePeriod
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
"End")
)
instance Prelude.Hashable TimePeriod
instance Prelude.NFData TimePeriod
instance Core.ToJSON TimePeriod where
toJSON :: TimePeriod -> Value
toJSON TimePeriod' {Maybe POSIX
end :: Maybe POSIX
start :: Maybe POSIX
$sel:end:TimePeriod' :: TimePeriod -> Maybe POSIX
$sel:start:TimePeriod' :: TimePeriod -> Maybe POSIX
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Start" 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
start,
(Text
"End" 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
end
]
)