{-# 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.PredictionTimeRange
-- 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.PredictionTimeRange where

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

-- | The time range during which anomalous behavior in a proactive anomaly or
-- an insight is expected to occur.
--
-- /See:/ 'newPredictionTimeRange' smart constructor.
data PredictionTimeRange = PredictionTimeRange'
  { -- | The time when the behavior in a proactive insight is expected to end.
    PredictionTimeRange -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX,
    -- | The time range during which a metric limit is expected to be exceeded.
    -- This applies to proactive insights only.
    PredictionTimeRange -> POSIX
startTime :: Core.POSIX
  }
  deriving (PredictionTimeRange -> PredictionTimeRange -> Bool
(PredictionTimeRange -> PredictionTimeRange -> Bool)
-> (PredictionTimeRange -> PredictionTimeRange -> Bool)
-> Eq PredictionTimeRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredictionTimeRange -> PredictionTimeRange -> Bool
$c/= :: PredictionTimeRange -> PredictionTimeRange -> Bool
== :: PredictionTimeRange -> PredictionTimeRange -> Bool
$c== :: PredictionTimeRange -> PredictionTimeRange -> Bool
Prelude.Eq, ReadPrec [PredictionTimeRange]
ReadPrec PredictionTimeRange
Int -> ReadS PredictionTimeRange
ReadS [PredictionTimeRange]
(Int -> ReadS PredictionTimeRange)
-> ReadS [PredictionTimeRange]
-> ReadPrec PredictionTimeRange
-> ReadPrec [PredictionTimeRange]
-> Read PredictionTimeRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredictionTimeRange]
$creadListPrec :: ReadPrec [PredictionTimeRange]
readPrec :: ReadPrec PredictionTimeRange
$creadPrec :: ReadPrec PredictionTimeRange
readList :: ReadS [PredictionTimeRange]
$creadList :: ReadS [PredictionTimeRange]
readsPrec :: Int -> ReadS PredictionTimeRange
$creadsPrec :: Int -> ReadS PredictionTimeRange
Prelude.Read, Int -> PredictionTimeRange -> ShowS
[PredictionTimeRange] -> ShowS
PredictionTimeRange -> String
(Int -> PredictionTimeRange -> ShowS)
-> (PredictionTimeRange -> String)
-> ([PredictionTimeRange] -> ShowS)
-> Show PredictionTimeRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredictionTimeRange] -> ShowS
$cshowList :: [PredictionTimeRange] -> ShowS
show :: PredictionTimeRange -> String
$cshow :: PredictionTimeRange -> String
showsPrec :: Int -> PredictionTimeRange -> ShowS
$cshowsPrec :: Int -> PredictionTimeRange -> ShowS
Prelude.Show, (forall x. PredictionTimeRange -> Rep PredictionTimeRange x)
-> (forall x. Rep PredictionTimeRange x -> PredictionTimeRange)
-> Generic PredictionTimeRange
forall x. Rep PredictionTimeRange x -> PredictionTimeRange
forall x. PredictionTimeRange -> Rep PredictionTimeRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PredictionTimeRange x -> PredictionTimeRange
$cfrom :: forall x. PredictionTimeRange -> Rep PredictionTimeRange x
Prelude.Generic)

-- |
-- Create a value of 'PredictionTimeRange' 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:
--
-- 'endTime', 'predictionTimeRange_endTime' - The time when the behavior in a proactive insight is expected to end.
--
-- 'startTime', 'predictionTimeRange_startTime' - The time range during which a metric limit is expected to be exceeded.
-- This applies to proactive insights only.
newPredictionTimeRange ::
  -- | 'startTime'
  Prelude.UTCTime ->
  PredictionTimeRange
newPredictionTimeRange :: UTCTime -> PredictionTimeRange
newPredictionTimeRange UTCTime
pStartTime_ =
  PredictionTimeRange' :: Maybe POSIX -> POSIX -> PredictionTimeRange
PredictionTimeRange'
    { $sel:endTime:PredictionTimeRange' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:PredictionTimeRange' :: 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_
    }

-- | The time when the behavior in a proactive insight is expected to end.
predictionTimeRange_endTime :: Lens.Lens' PredictionTimeRange (Prelude.Maybe Prelude.UTCTime)
predictionTimeRange_endTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PredictionTimeRange -> f PredictionTimeRange
predictionTimeRange_endTime = (PredictionTimeRange -> Maybe POSIX)
-> (PredictionTimeRange -> Maybe POSIX -> PredictionTimeRange)
-> Lens
     PredictionTimeRange PredictionTimeRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictionTimeRange' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:PredictionTimeRange' :: PredictionTimeRange -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: PredictionTimeRange
s@PredictionTimeRange' {} Maybe POSIX
a -> PredictionTimeRange
s {$sel:endTime:PredictionTimeRange' :: Maybe POSIX
endTime = Maybe POSIX
a} :: PredictionTimeRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> PredictionTimeRange -> f PredictionTimeRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PredictionTimeRange
-> f PredictionTimeRange
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 time range during which a metric limit is expected to be exceeded.
-- This applies to proactive insights only.
predictionTimeRange_startTime :: Lens.Lens' PredictionTimeRange Prelude.UTCTime
predictionTimeRange_startTime :: (UTCTime -> f UTCTime)
-> PredictionTimeRange -> f PredictionTimeRange
predictionTimeRange_startTime = (PredictionTimeRange -> POSIX)
-> (PredictionTimeRange -> POSIX -> PredictionTimeRange)
-> Lens PredictionTimeRange PredictionTimeRange POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictionTimeRange' {POSIX
startTime :: POSIX
$sel:startTime:PredictionTimeRange' :: PredictionTimeRange -> POSIX
startTime} -> POSIX
startTime) (\s :: PredictionTimeRange
s@PredictionTimeRange' {} POSIX
a -> PredictionTimeRange
s {$sel:startTime:PredictionTimeRange' :: POSIX
startTime = POSIX
a} :: PredictionTimeRange) ((POSIX -> f POSIX)
 -> PredictionTimeRange -> f PredictionTimeRange)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> PredictionTimeRange
-> f PredictionTimeRange
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 PredictionTimeRange where
  parseJSON :: Value -> Parser PredictionTimeRange
parseJSON =
    String
-> (Object -> Parser PredictionTimeRange)
-> Value
-> Parser PredictionTimeRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PredictionTimeRange"
      ( \Object
x ->
          Maybe POSIX -> POSIX -> PredictionTimeRange
PredictionTimeRange'
            (Maybe POSIX -> POSIX -> PredictionTimeRange)
-> Parser (Maybe POSIX) -> Parser (POSIX -> PredictionTimeRange)
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
"EndTime")
            Parser (POSIX -> PredictionTimeRange)
-> Parser POSIX -> Parser PredictionTimeRange
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
"StartTime")
      )

instance Prelude.Hashable PredictionTimeRange

instance Prelude.NFData PredictionTimeRange