{-# 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.DevOpsGuru.Types.StartTimeRange
-- 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.DevOpsGuru.Types.StartTimeRange where

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

-- | A time range used to specify when the behavior of an insight or anomaly
-- started.
--
-- /See:/ 'newStartTimeRange' smart constructor.
data StartTimeRange = StartTimeRange'
  { -- | The start time of the time range.
    StartTimeRange -> Maybe POSIX
fromTime :: Prelude.Maybe Core.POSIX,
    -- | The end time of the time range.
    StartTimeRange -> Maybe POSIX
toTime :: Prelude.Maybe Core.POSIX
  }
  deriving (StartTimeRange -> StartTimeRange -> Bool
(StartTimeRange -> StartTimeRange -> Bool)
-> (StartTimeRange -> StartTimeRange -> Bool) -> Eq StartTimeRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartTimeRange -> StartTimeRange -> Bool
$c/= :: StartTimeRange -> StartTimeRange -> Bool
== :: StartTimeRange -> StartTimeRange -> Bool
$c== :: StartTimeRange -> StartTimeRange -> Bool
Prelude.Eq, ReadPrec [StartTimeRange]
ReadPrec StartTimeRange
Int -> ReadS StartTimeRange
ReadS [StartTimeRange]
(Int -> ReadS StartTimeRange)
-> ReadS [StartTimeRange]
-> ReadPrec StartTimeRange
-> ReadPrec [StartTimeRange]
-> Read StartTimeRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartTimeRange]
$creadListPrec :: ReadPrec [StartTimeRange]
readPrec :: ReadPrec StartTimeRange
$creadPrec :: ReadPrec StartTimeRange
readList :: ReadS [StartTimeRange]
$creadList :: ReadS [StartTimeRange]
readsPrec :: Int -> ReadS StartTimeRange
$creadsPrec :: Int -> ReadS StartTimeRange
Prelude.Read, Int -> StartTimeRange -> ShowS
[StartTimeRange] -> ShowS
StartTimeRange -> String
(Int -> StartTimeRange -> ShowS)
-> (StartTimeRange -> String)
-> ([StartTimeRange] -> ShowS)
-> Show StartTimeRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartTimeRange] -> ShowS
$cshowList :: [StartTimeRange] -> ShowS
show :: StartTimeRange -> String
$cshow :: StartTimeRange -> String
showsPrec :: Int -> StartTimeRange -> ShowS
$cshowsPrec :: Int -> StartTimeRange -> ShowS
Prelude.Show, (forall x. StartTimeRange -> Rep StartTimeRange x)
-> (forall x. Rep StartTimeRange x -> StartTimeRange)
-> Generic StartTimeRange
forall x. Rep StartTimeRange x -> StartTimeRange
forall x. StartTimeRange -> Rep StartTimeRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartTimeRange x -> StartTimeRange
$cfrom :: forall x. StartTimeRange -> Rep StartTimeRange x
Prelude.Generic)

-- |
-- Create a value of 'StartTimeRange' 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:
--
-- 'fromTime', 'startTimeRange_fromTime' - The start time of the time range.
--
-- 'toTime', 'startTimeRange_toTime' - The end time of the time range.
newStartTimeRange ::
  StartTimeRange
newStartTimeRange :: StartTimeRange
newStartTimeRange =
  StartTimeRange' :: Maybe POSIX -> Maybe POSIX -> StartTimeRange
StartTimeRange'
    { $sel:fromTime:StartTimeRange' :: Maybe POSIX
fromTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:toTime:StartTimeRange' :: Maybe POSIX
toTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The start time of the time range.
startTimeRange_fromTime :: Lens.Lens' StartTimeRange (Prelude.Maybe Prelude.UTCTime)
startTimeRange_fromTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> StartTimeRange -> f StartTimeRange
startTimeRange_fromTime = (StartTimeRange -> Maybe POSIX)
-> (StartTimeRange -> Maybe POSIX -> StartTimeRange)
-> Lens StartTimeRange StartTimeRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartTimeRange' {Maybe POSIX
fromTime :: Maybe POSIX
$sel:fromTime:StartTimeRange' :: StartTimeRange -> Maybe POSIX
fromTime} -> Maybe POSIX
fromTime) (\s :: StartTimeRange
s@StartTimeRange' {} Maybe POSIX
a -> StartTimeRange
s {$sel:fromTime:StartTimeRange' :: Maybe POSIX
fromTime = Maybe POSIX
a} :: StartTimeRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> StartTimeRange -> f StartTimeRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> StartTimeRange
-> f StartTimeRange
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 end time of the time range.
startTimeRange_toTime :: Lens.Lens' StartTimeRange (Prelude.Maybe Prelude.UTCTime)
startTimeRange_toTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> StartTimeRange -> f StartTimeRange
startTimeRange_toTime = (StartTimeRange -> Maybe POSIX)
-> (StartTimeRange -> Maybe POSIX -> StartTimeRange)
-> Lens StartTimeRange StartTimeRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartTimeRange' {Maybe POSIX
toTime :: Maybe POSIX
$sel:toTime:StartTimeRange' :: StartTimeRange -> Maybe POSIX
toTime} -> Maybe POSIX
toTime) (\s :: StartTimeRange
s@StartTimeRange' {} Maybe POSIX
a -> StartTimeRange
s {$sel:toTime:StartTimeRange' :: Maybe POSIX
toTime = Maybe POSIX
a} :: StartTimeRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> StartTimeRange -> f StartTimeRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> StartTimeRange
-> f StartTimeRange
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 StartTimeRange

instance Prelude.NFData StartTimeRange

instance Core.ToJSON StartTimeRange where
  toJSON :: StartTimeRange -> Value
toJSON StartTimeRange' {Maybe POSIX
toTime :: Maybe POSIX
fromTime :: Maybe POSIX
$sel:toTime:StartTimeRange' :: StartTimeRange -> Maybe POSIX
$sel:fromTime:StartTimeRange' :: StartTimeRange -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FromTime" 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
fromTime,
            (Text
"ToTime" 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
toTime
          ]
      )