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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(AnomalyGroupTimeSeries -> AnomalyGroupTimeSeries -> Bool)
-> (AnomalyGroupTimeSeries -> AnomalyGroupTimeSeries -> Bool)
-> Eq AnomalyGroupTimeSeries
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]
(Int -> ReadS AnomalyGroupTimeSeries)
-> ReadS [AnomalyGroupTimeSeries]
-> ReadPrec AnomalyGroupTimeSeries
-> ReadPrec [AnomalyGroupTimeSeries]
-> Read 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
(Int -> AnomalyGroupTimeSeries -> ShowS)
-> (AnomalyGroupTimeSeries -> String)
-> ([AnomalyGroupTimeSeries] -> ShowS)
-> Show AnomalyGroupTimeSeries
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. AnomalyGroupTimeSeries -> Rep AnomalyGroupTimeSeries x)
-> (forall x.
    Rep AnomalyGroupTimeSeries x -> AnomalyGroupTimeSeries)
-> Generic AnomalyGroupTimeSeries
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' :: Maybe Text -> Text -> AnomalyGroupTimeSeries
AnomalyGroupTimeSeries'
    { $sel:timeSeriesId:AnomalyGroupTimeSeries' :: Maybe Text
timeSeriesId =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> AnomalyGroupTimeSeries -> f AnomalyGroupTimeSeries
anomalyGroupTimeSeries_timeSeriesId = (AnomalyGroupTimeSeries -> Maybe Text)
-> (AnomalyGroupTimeSeries -> Maybe Text -> AnomalyGroupTimeSeries)
-> Lens
     AnomalyGroupTimeSeries
     AnomalyGroupTimeSeries
     (Maybe Text)
     (Maybe Text)
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 :: (Text -> f Text)
-> AnomalyGroupTimeSeries -> f AnomalyGroupTimeSeries
anomalyGroupTimeSeries_anomalyGroupId = (AnomalyGroupTimeSeries -> Text)
-> (AnomalyGroupTimeSeries -> Text -> AnomalyGroupTimeSeries)
-> Lens AnomalyGroupTimeSeries AnomalyGroupTimeSeries Text Text
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

instance Prelude.NFData AnomalyGroupTimeSeries

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TimeSeriesId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
timeSeriesId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AnomalyGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
anomalyGroupId)
          ]
      )