{-# 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.LookoutMetrics.Types.AnomalyGroupTimeSeries
-- 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.LookoutMetrics.Types.AnomalyGroupTimeSeries where

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

-- | An anomalous metric in an anomaly group.
--
-- /See:/ 'newAnomalyGroupTimeSeries' smart constructor.
data AnomalyGroupTimeSeries = AnomalyGroupTimeSeries'
  { -- | The ID of the metric.
    AnomalyGroupTimeSeries -> Maybe Text
timeSeriesId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the anomaly group.
    AnomalyGroupTimeSeries -> Text
anomalyGroupId :: Prelude.Text
  }
  deriving (AnomalyGroupTimeSeries -> AnomalyGroupTimeSeries -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnomalyGroupTimeSeries -> AnomalyGroupTimeSeries -> Bool
$c/= :: AnomalyGroupTimeSeries -> AnomalyGroupTimeSeries -> Bool
== :: AnomalyGroupTimeSeries -> AnomalyGroupTimeSeries -> Bool
$c== :: AnomalyGroupTimeSeries -> AnomalyGroupTimeSeries -> Bool
Prelude.Eq, ReadPrec [AnomalyGroupTimeSeries]
ReadPrec AnomalyGroupTimeSeries
Int -> ReadS AnomalyGroupTimeSeries
ReadS [AnomalyGroupTimeSeries]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnomalyGroupTimeSeries]
$creadListPrec :: ReadPrec [AnomalyGroupTimeSeries]
readPrec :: ReadPrec AnomalyGroupTimeSeries
$creadPrec :: ReadPrec AnomalyGroupTimeSeries
readList :: ReadS [AnomalyGroupTimeSeries]
$creadList :: ReadS [AnomalyGroupTimeSeries]
readsPrec :: Int -> ReadS AnomalyGroupTimeSeries
$creadsPrec :: Int -> ReadS AnomalyGroupTimeSeries
Prelude.Read, Int -> AnomalyGroupTimeSeries -> ShowS
[AnomalyGroupTimeSeries] -> ShowS
AnomalyGroupTimeSeries -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnomalyGroupTimeSeries] -> ShowS
$cshowList :: [AnomalyGroupTimeSeries] -> ShowS
show :: AnomalyGroupTimeSeries -> String
$cshow :: AnomalyGroupTimeSeries -> String
showsPrec :: Int -> AnomalyGroupTimeSeries -> ShowS
$cshowsPrec :: Int -> AnomalyGroupTimeSeries -> ShowS
Prelude.Show, forall x. Rep AnomalyGroupTimeSeries x -> AnomalyGroupTimeSeries
forall x. AnomalyGroupTimeSeries -> Rep AnomalyGroupTimeSeries x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnomalyGroupTimeSeries x -> AnomalyGroupTimeSeries
$cfrom :: forall x. AnomalyGroupTimeSeries -> Rep AnomalyGroupTimeSeries x
Prelude.Generic)

-- |
-- Create a value of 'AnomalyGroupTimeSeries' 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:
--
-- 'timeSeriesId', 'anomalyGroupTimeSeries_timeSeriesId' - The ID of the metric.
--
-- 'anomalyGroupId', 'anomalyGroupTimeSeries_anomalyGroupId' - The ID of the anomaly group.
newAnomalyGroupTimeSeries ::
  -- | 'anomalyGroupId'
  Prelude.Text ->
  AnomalyGroupTimeSeries
newAnomalyGroupTimeSeries :: Text -> AnomalyGroupTimeSeries
newAnomalyGroupTimeSeries Text
pAnomalyGroupId_ =
  AnomalyGroupTimeSeries'
    { $sel:timeSeriesId:AnomalyGroupTimeSeries' :: Maybe Text
timeSeriesId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:anomalyGroupId:AnomalyGroupTimeSeries' :: Text
anomalyGroupId = Text
pAnomalyGroupId_
    }

-- | The ID of the metric.
anomalyGroupTimeSeries_timeSeriesId :: Lens.Lens' AnomalyGroupTimeSeries (Prelude.Maybe Prelude.Text)
anomalyGroupTimeSeries_timeSeriesId :: Lens' AnomalyGroupTimeSeries (Maybe Text)
anomalyGroupTimeSeries_timeSeriesId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroupTimeSeries' {Maybe Text
timeSeriesId :: Maybe Text
$sel:timeSeriesId:AnomalyGroupTimeSeries' :: AnomalyGroupTimeSeries -> Maybe Text
timeSeriesId} -> Maybe Text
timeSeriesId) (\s :: AnomalyGroupTimeSeries
s@AnomalyGroupTimeSeries' {} Maybe Text
a -> AnomalyGroupTimeSeries
s {$sel:timeSeriesId:AnomalyGroupTimeSeries' :: Maybe Text
timeSeriesId = Maybe Text
a} :: AnomalyGroupTimeSeries)

-- | The ID of the anomaly group.
anomalyGroupTimeSeries_anomalyGroupId :: Lens.Lens' AnomalyGroupTimeSeries Prelude.Text
anomalyGroupTimeSeries_anomalyGroupId :: Lens' AnomalyGroupTimeSeries Text
anomalyGroupTimeSeries_anomalyGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyGroupTimeSeries' {Text
anomalyGroupId :: Text
$sel:anomalyGroupId:AnomalyGroupTimeSeries' :: AnomalyGroupTimeSeries -> Text
anomalyGroupId} -> Text
anomalyGroupId) (\s :: AnomalyGroupTimeSeries
s@AnomalyGroupTimeSeries' {} Text
a -> AnomalyGroupTimeSeries
s {$sel:anomalyGroupId:AnomalyGroupTimeSeries' :: Text
anomalyGroupId = Text
a} :: AnomalyGroupTimeSeries)

instance Prelude.Hashable AnomalyGroupTimeSeries where
  hashWithSalt :: Int -> AnomalyGroupTimeSeries -> Int
hashWithSalt Int
_salt AnomalyGroupTimeSeries' {Maybe Text
Text
anomalyGroupId :: Text
timeSeriesId :: Maybe Text
$sel:anomalyGroupId:AnomalyGroupTimeSeries' :: AnomalyGroupTimeSeries -> Text
$sel:timeSeriesId:AnomalyGroupTimeSeries' :: AnomalyGroupTimeSeries -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
timeSeriesId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
anomalyGroupId

instance Prelude.NFData AnomalyGroupTimeSeries where
  rnf :: AnomalyGroupTimeSeries -> ()
rnf AnomalyGroupTimeSeries' {Maybe Text
Text
anomalyGroupId :: Text
timeSeriesId :: Maybe Text
$sel:anomalyGroupId:AnomalyGroupTimeSeries' :: AnomalyGroupTimeSeries -> Text
$sel:timeSeriesId:AnomalyGroupTimeSeries' :: AnomalyGroupTimeSeries -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
timeSeriesId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
anomalyGroupId

instance Data.ToJSON AnomalyGroupTimeSeries where
  toJSON :: AnomalyGroupTimeSeries -> Value
toJSON AnomalyGroupTimeSeries' {Maybe Text
Text
anomalyGroupId :: Text
timeSeriesId :: Maybe Text
$sel:anomalyGroupId:AnomalyGroupTimeSeries' :: AnomalyGroupTimeSeries -> Text
$sel:timeSeriesId:AnomalyGroupTimeSeries' :: AnomalyGroupTimeSeries -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TimeSeriesId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
timeSeriesId,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AnomalyGroupId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
anomalyGroupId)
          ]
      )