{-# 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.CodeGuruProfiler.Types.AnomalyInstance
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeGuruProfiler.Types.AnomalyInstance where

import Amazonka.CodeGuruProfiler.Types.UserFeedback
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The specific duration in which the metric is flagged as anomalous.
--
-- /See:/ 'newAnomalyInstance' smart constructor.
data AnomalyInstance = AnomalyInstance'
  { -- | The end time of the period during which the metric is flagged as
    -- anomalous. This is specified using the ISO 8601 format. For example,
    -- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
    -- 1:15:02 PM UTC.
    AnomalyInstance -> Maybe ISO8601
endTime :: Prelude.Maybe Data.ISO8601,
    -- | Feedback type on a specific instance of anomaly submitted by the user.
    AnomalyInstance -> Maybe UserFeedback
userFeedback :: Prelude.Maybe UserFeedback,
    -- | The universally unique identifier (UUID) of an instance of an anomaly in
    -- a metric.
    AnomalyInstance -> Text
id :: Prelude.Text,
    -- | The start time of the period during which the metric is flagged as
    -- anomalous. This is specified using the ISO 8601 format. For example,
    -- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
    -- 1:15:02 PM UTC.
    AnomalyInstance -> ISO8601
startTime :: Data.ISO8601
  }
  deriving (AnomalyInstance -> AnomalyInstance -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnomalyInstance -> AnomalyInstance -> Bool
$c/= :: AnomalyInstance -> AnomalyInstance -> Bool
== :: AnomalyInstance -> AnomalyInstance -> Bool
$c== :: AnomalyInstance -> AnomalyInstance -> Bool
Prelude.Eq, ReadPrec [AnomalyInstance]
ReadPrec AnomalyInstance
Int -> ReadS AnomalyInstance
ReadS [AnomalyInstance]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnomalyInstance]
$creadListPrec :: ReadPrec [AnomalyInstance]
readPrec :: ReadPrec AnomalyInstance
$creadPrec :: ReadPrec AnomalyInstance
readList :: ReadS [AnomalyInstance]
$creadList :: ReadS [AnomalyInstance]
readsPrec :: Int -> ReadS AnomalyInstance
$creadsPrec :: Int -> ReadS AnomalyInstance
Prelude.Read, Int -> AnomalyInstance -> ShowS
[AnomalyInstance] -> ShowS
AnomalyInstance -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnomalyInstance] -> ShowS
$cshowList :: [AnomalyInstance] -> ShowS
show :: AnomalyInstance -> String
$cshow :: AnomalyInstance -> String
showsPrec :: Int -> AnomalyInstance -> ShowS
$cshowsPrec :: Int -> AnomalyInstance -> ShowS
Prelude.Show, forall x. Rep AnomalyInstance x -> AnomalyInstance
forall x. AnomalyInstance -> Rep AnomalyInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnomalyInstance x -> AnomalyInstance
$cfrom :: forall x. AnomalyInstance -> Rep AnomalyInstance x
Prelude.Generic)

-- |
-- Create a value of 'AnomalyInstance' 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', 'anomalyInstance_endTime' - The end time of the period during which the metric is flagged as
-- anomalous. This is specified using the ISO 8601 format. For example,
-- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
-- 1:15:02 PM UTC.
--
-- 'userFeedback', 'anomalyInstance_userFeedback' - Feedback type on a specific instance of anomaly submitted by the user.
--
-- 'id', 'anomalyInstance_id' - The universally unique identifier (UUID) of an instance of an anomaly in
-- a metric.
--
-- 'startTime', 'anomalyInstance_startTime' - The start time of the period during which the metric is flagged as
-- anomalous. This is specified using the ISO 8601 format. For example,
-- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
-- 1:15:02 PM UTC.
newAnomalyInstance ::
  -- | 'id'
  Prelude.Text ->
  -- | 'startTime'
  Prelude.UTCTime ->
  AnomalyInstance
newAnomalyInstance :: Text -> UTCTime -> AnomalyInstance
newAnomalyInstance Text
pId_ UTCTime
pStartTime_ =
  AnomalyInstance'
    { $sel:endTime:AnomalyInstance' :: Maybe ISO8601
endTime = forall a. Maybe a
Prelude.Nothing,
      $sel:userFeedback:AnomalyInstance' :: Maybe UserFeedback
userFeedback = forall a. Maybe a
Prelude.Nothing,
      $sel:id:AnomalyInstance' :: Text
id = Text
pId_,
      $sel:startTime:AnomalyInstance' :: ISO8601
startTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_
    }

-- | The end time of the period during which the metric is flagged as
-- anomalous. This is specified using the ISO 8601 format. For example,
-- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
-- 1:15:02 PM UTC.
anomalyInstance_endTime :: Lens.Lens' AnomalyInstance (Prelude.Maybe Prelude.UTCTime)
anomalyInstance_endTime :: Lens' AnomalyInstance (Maybe UTCTime)
anomalyInstance_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyInstance' {Maybe ISO8601
endTime :: Maybe ISO8601
$sel:endTime:AnomalyInstance' :: AnomalyInstance -> Maybe ISO8601
endTime} -> Maybe ISO8601
endTime) (\s :: AnomalyInstance
s@AnomalyInstance' {} Maybe ISO8601
a -> AnomalyInstance
s {$sel:endTime:AnomalyInstance' :: Maybe ISO8601
endTime = Maybe ISO8601
a} :: AnomalyInstance) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Feedback type on a specific instance of anomaly submitted by the user.
anomalyInstance_userFeedback :: Lens.Lens' AnomalyInstance (Prelude.Maybe UserFeedback)
anomalyInstance_userFeedback :: Lens' AnomalyInstance (Maybe UserFeedback)
anomalyInstance_userFeedback = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyInstance' {Maybe UserFeedback
userFeedback :: Maybe UserFeedback
$sel:userFeedback:AnomalyInstance' :: AnomalyInstance -> Maybe UserFeedback
userFeedback} -> Maybe UserFeedback
userFeedback) (\s :: AnomalyInstance
s@AnomalyInstance' {} Maybe UserFeedback
a -> AnomalyInstance
s {$sel:userFeedback:AnomalyInstance' :: Maybe UserFeedback
userFeedback = Maybe UserFeedback
a} :: AnomalyInstance)

-- | The universally unique identifier (UUID) of an instance of an anomaly in
-- a metric.
anomalyInstance_id :: Lens.Lens' AnomalyInstance Prelude.Text
anomalyInstance_id :: Lens' AnomalyInstance Text
anomalyInstance_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyInstance' {Text
id :: Text
$sel:id:AnomalyInstance' :: AnomalyInstance -> Text
id} -> Text
id) (\s :: AnomalyInstance
s@AnomalyInstance' {} Text
a -> AnomalyInstance
s {$sel:id:AnomalyInstance' :: Text
id = Text
a} :: AnomalyInstance)

-- | The start time of the period during which the metric is flagged as
-- anomalous. This is specified using the ISO 8601 format. For example,
-- 2020-06-01T13:15:02.001Z represents 1 millisecond past June 1, 2020
-- 1:15:02 PM UTC.
anomalyInstance_startTime :: Lens.Lens' AnomalyInstance Prelude.UTCTime
anomalyInstance_startTime :: Lens' AnomalyInstance UTCTime
anomalyInstance_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyInstance' {ISO8601
startTime :: ISO8601
$sel:startTime:AnomalyInstance' :: AnomalyInstance -> ISO8601
startTime} -> ISO8601
startTime) (\s :: AnomalyInstance
s@AnomalyInstance' {} ISO8601
a -> AnomalyInstance
s {$sel:startTime:AnomalyInstance' :: ISO8601
startTime = ISO8601
a} :: AnomalyInstance) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON AnomalyInstance where
  parseJSON :: Value -> Parser AnomalyInstance
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AnomalyInstance"
      ( \Object
x ->
          Maybe ISO8601
-> Maybe UserFeedback -> Text -> ISO8601 -> AnomalyInstance
AnomalyInstance'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"endTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"userFeedback")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"startTime")
      )

instance Prelude.Hashable AnomalyInstance where
  hashWithSalt :: Int -> AnomalyInstance -> Int
hashWithSalt Int
_salt AnomalyInstance' {Maybe ISO8601
Maybe UserFeedback
Text
ISO8601
startTime :: ISO8601
id :: Text
userFeedback :: Maybe UserFeedback
endTime :: Maybe ISO8601
$sel:startTime:AnomalyInstance' :: AnomalyInstance -> ISO8601
$sel:id:AnomalyInstance' :: AnomalyInstance -> Text
$sel:userFeedback:AnomalyInstance' :: AnomalyInstance -> Maybe UserFeedback
$sel:endTime:AnomalyInstance' :: AnomalyInstance -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
endTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UserFeedback
userFeedback
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
startTime

instance Prelude.NFData AnomalyInstance where
  rnf :: AnomalyInstance -> ()
rnf AnomalyInstance' {Maybe ISO8601
Maybe UserFeedback
Text
ISO8601
startTime :: ISO8601
id :: Text
userFeedback :: Maybe UserFeedback
endTime :: Maybe ISO8601
$sel:startTime:AnomalyInstance' :: AnomalyInstance -> ISO8601
$sel:id:AnomalyInstance' :: AnomalyInstance -> Text
$sel:userFeedback:AnomalyInstance' :: AnomalyInstance -> Maybe UserFeedback
$sel:endTime:AnomalyInstance' :: AnomalyInstance -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
endTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UserFeedback
userFeedback
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
startTime