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

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

-- | A time range that specifies when DevOps Guru opens and then closes an
-- anomaly. This is different from @AnomalyTimeRange@, which specifies the
-- time range when DevOps Guru actually observes the anomalous behavior.
--
-- /See:/ 'newAnomalyReportedTimeRange' smart constructor.
data AnomalyReportedTimeRange = AnomalyReportedTimeRange'
  { -- | The time when an anomaly is closed.
    AnomalyReportedTimeRange -> Maybe POSIX
closeTime :: Prelude.Maybe Core.POSIX,
    -- | The time when an anomaly is opened.
    AnomalyReportedTimeRange -> POSIX
openTime :: Core.POSIX
  }
  deriving (AnomalyReportedTimeRange -> AnomalyReportedTimeRange -> Bool
(AnomalyReportedTimeRange -> AnomalyReportedTimeRange -> Bool)
-> (AnomalyReportedTimeRange -> AnomalyReportedTimeRange -> Bool)
-> Eq AnomalyReportedTimeRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnomalyReportedTimeRange -> AnomalyReportedTimeRange -> Bool
$c/= :: AnomalyReportedTimeRange -> AnomalyReportedTimeRange -> Bool
== :: AnomalyReportedTimeRange -> AnomalyReportedTimeRange -> Bool
$c== :: AnomalyReportedTimeRange -> AnomalyReportedTimeRange -> Bool
Prelude.Eq, ReadPrec [AnomalyReportedTimeRange]
ReadPrec AnomalyReportedTimeRange
Int -> ReadS AnomalyReportedTimeRange
ReadS [AnomalyReportedTimeRange]
(Int -> ReadS AnomalyReportedTimeRange)
-> ReadS [AnomalyReportedTimeRange]
-> ReadPrec AnomalyReportedTimeRange
-> ReadPrec [AnomalyReportedTimeRange]
-> Read AnomalyReportedTimeRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnomalyReportedTimeRange]
$creadListPrec :: ReadPrec [AnomalyReportedTimeRange]
readPrec :: ReadPrec AnomalyReportedTimeRange
$creadPrec :: ReadPrec AnomalyReportedTimeRange
readList :: ReadS [AnomalyReportedTimeRange]
$creadList :: ReadS [AnomalyReportedTimeRange]
readsPrec :: Int -> ReadS AnomalyReportedTimeRange
$creadsPrec :: Int -> ReadS AnomalyReportedTimeRange
Prelude.Read, Int -> AnomalyReportedTimeRange -> ShowS
[AnomalyReportedTimeRange] -> ShowS
AnomalyReportedTimeRange -> String
(Int -> AnomalyReportedTimeRange -> ShowS)
-> (AnomalyReportedTimeRange -> String)
-> ([AnomalyReportedTimeRange] -> ShowS)
-> Show AnomalyReportedTimeRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnomalyReportedTimeRange] -> ShowS
$cshowList :: [AnomalyReportedTimeRange] -> ShowS
show :: AnomalyReportedTimeRange -> String
$cshow :: AnomalyReportedTimeRange -> String
showsPrec :: Int -> AnomalyReportedTimeRange -> ShowS
$cshowsPrec :: Int -> AnomalyReportedTimeRange -> ShowS
Prelude.Show, (forall x.
 AnomalyReportedTimeRange -> Rep AnomalyReportedTimeRange x)
-> (forall x.
    Rep AnomalyReportedTimeRange x -> AnomalyReportedTimeRange)
-> Generic AnomalyReportedTimeRange
forall x.
Rep AnomalyReportedTimeRange x -> AnomalyReportedTimeRange
forall x.
AnomalyReportedTimeRange -> Rep AnomalyReportedTimeRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AnomalyReportedTimeRange x -> AnomalyReportedTimeRange
$cfrom :: forall x.
AnomalyReportedTimeRange -> Rep AnomalyReportedTimeRange x
Prelude.Generic)

-- |
-- Create a value of 'AnomalyReportedTimeRange' 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:
--
-- 'closeTime', 'anomalyReportedTimeRange_closeTime' - The time when an anomaly is closed.
--
-- 'openTime', 'anomalyReportedTimeRange_openTime' - The time when an anomaly is opened.
newAnomalyReportedTimeRange ::
  -- | 'openTime'
  Prelude.UTCTime ->
  AnomalyReportedTimeRange
newAnomalyReportedTimeRange :: UTCTime -> AnomalyReportedTimeRange
newAnomalyReportedTimeRange UTCTime
pOpenTime_ =
  AnomalyReportedTimeRange' :: Maybe POSIX -> POSIX -> AnomalyReportedTimeRange
AnomalyReportedTimeRange'
    { $sel:closeTime:AnomalyReportedTimeRange' :: Maybe POSIX
closeTime =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:openTime:AnomalyReportedTimeRange' :: POSIX
openTime = 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
pOpenTime_
    }

-- | The time when an anomaly is closed.
anomalyReportedTimeRange_closeTime :: Lens.Lens' AnomalyReportedTimeRange (Prelude.Maybe Prelude.UTCTime)
anomalyReportedTimeRange_closeTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AnomalyReportedTimeRange -> f AnomalyReportedTimeRange
anomalyReportedTimeRange_closeTime = (AnomalyReportedTimeRange -> Maybe POSIX)
-> (AnomalyReportedTimeRange
    -> Maybe POSIX -> AnomalyReportedTimeRange)
-> Lens
     AnomalyReportedTimeRange
     AnomalyReportedTimeRange
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyReportedTimeRange' {Maybe POSIX
closeTime :: Maybe POSIX
$sel:closeTime:AnomalyReportedTimeRange' :: AnomalyReportedTimeRange -> Maybe POSIX
closeTime} -> Maybe POSIX
closeTime) (\s :: AnomalyReportedTimeRange
s@AnomalyReportedTimeRange' {} Maybe POSIX
a -> AnomalyReportedTimeRange
s {$sel:closeTime:AnomalyReportedTimeRange' :: Maybe POSIX
closeTime = Maybe POSIX
a} :: AnomalyReportedTimeRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> AnomalyReportedTimeRange -> f AnomalyReportedTimeRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AnomalyReportedTimeRange
-> f AnomalyReportedTimeRange
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 when an anomaly is opened.
anomalyReportedTimeRange_openTime :: Lens.Lens' AnomalyReportedTimeRange Prelude.UTCTime
anomalyReportedTimeRange_openTime :: (UTCTime -> f UTCTime)
-> AnomalyReportedTimeRange -> f AnomalyReportedTimeRange
anomalyReportedTimeRange_openTime = (AnomalyReportedTimeRange -> POSIX)
-> (AnomalyReportedTimeRange -> POSIX -> AnomalyReportedTimeRange)
-> Lens
     AnomalyReportedTimeRange AnomalyReportedTimeRange POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyReportedTimeRange' {POSIX
openTime :: POSIX
$sel:openTime:AnomalyReportedTimeRange' :: AnomalyReportedTimeRange -> POSIX
openTime} -> POSIX
openTime) (\s :: AnomalyReportedTimeRange
s@AnomalyReportedTimeRange' {} POSIX
a -> AnomalyReportedTimeRange
s {$sel:openTime:AnomalyReportedTimeRange' :: POSIX
openTime = POSIX
a} :: AnomalyReportedTimeRange) ((POSIX -> f POSIX)
 -> AnomalyReportedTimeRange -> f AnomalyReportedTimeRange)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> AnomalyReportedTimeRange
-> f AnomalyReportedTimeRange
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 AnomalyReportedTimeRange where
  parseJSON :: Value -> Parser AnomalyReportedTimeRange
parseJSON =
    String
-> (Object -> Parser AnomalyReportedTimeRange)
-> Value
-> Parser AnomalyReportedTimeRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AnomalyReportedTimeRange"
      ( \Object
x ->
          Maybe POSIX -> POSIX -> AnomalyReportedTimeRange
AnomalyReportedTimeRange'
            (Maybe POSIX -> POSIX -> AnomalyReportedTimeRange)
-> Parser (Maybe POSIX)
-> Parser (POSIX -> AnomalyReportedTimeRange)
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
"CloseTime")
            Parser (POSIX -> AnomalyReportedTimeRange)
-> Parser POSIX -> Parser AnomalyReportedTimeRange
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
"OpenTime")
      )

instance Prelude.Hashable AnomalyReportedTimeRange

instance Prelude.NFData AnomalyReportedTimeRange