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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutMetrics.Types.Frequency
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a detector\'s configuration.
--
-- /See:/ 'newAnomalyDetectorConfig' smart constructor.
data AnomalyDetectorConfig = AnomalyDetectorConfig'
  { -- | The frequency at which the detector analyzes its source data.
    AnomalyDetectorConfig -> Maybe Frequency
anomalyDetectorFrequency :: Prelude.Maybe Frequency
  }
  deriving (AnomalyDetectorConfig -> AnomalyDetectorConfig -> Bool
(AnomalyDetectorConfig -> AnomalyDetectorConfig -> Bool)
-> (AnomalyDetectorConfig -> AnomalyDetectorConfig -> Bool)
-> Eq AnomalyDetectorConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnomalyDetectorConfig -> AnomalyDetectorConfig -> Bool
$c/= :: AnomalyDetectorConfig -> AnomalyDetectorConfig -> Bool
== :: AnomalyDetectorConfig -> AnomalyDetectorConfig -> Bool
$c== :: AnomalyDetectorConfig -> AnomalyDetectorConfig -> Bool
Prelude.Eq, ReadPrec [AnomalyDetectorConfig]
ReadPrec AnomalyDetectorConfig
Int -> ReadS AnomalyDetectorConfig
ReadS [AnomalyDetectorConfig]
(Int -> ReadS AnomalyDetectorConfig)
-> ReadS [AnomalyDetectorConfig]
-> ReadPrec AnomalyDetectorConfig
-> ReadPrec [AnomalyDetectorConfig]
-> Read AnomalyDetectorConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnomalyDetectorConfig]
$creadListPrec :: ReadPrec [AnomalyDetectorConfig]
readPrec :: ReadPrec AnomalyDetectorConfig
$creadPrec :: ReadPrec AnomalyDetectorConfig
readList :: ReadS [AnomalyDetectorConfig]
$creadList :: ReadS [AnomalyDetectorConfig]
readsPrec :: Int -> ReadS AnomalyDetectorConfig
$creadsPrec :: Int -> ReadS AnomalyDetectorConfig
Prelude.Read, Int -> AnomalyDetectorConfig -> ShowS
[AnomalyDetectorConfig] -> ShowS
AnomalyDetectorConfig -> String
(Int -> AnomalyDetectorConfig -> ShowS)
-> (AnomalyDetectorConfig -> String)
-> ([AnomalyDetectorConfig] -> ShowS)
-> Show AnomalyDetectorConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnomalyDetectorConfig] -> ShowS
$cshowList :: [AnomalyDetectorConfig] -> ShowS
show :: AnomalyDetectorConfig -> String
$cshow :: AnomalyDetectorConfig -> String
showsPrec :: Int -> AnomalyDetectorConfig -> ShowS
$cshowsPrec :: Int -> AnomalyDetectorConfig -> ShowS
Prelude.Show, (forall x. AnomalyDetectorConfig -> Rep AnomalyDetectorConfig x)
-> (forall x. Rep AnomalyDetectorConfig x -> AnomalyDetectorConfig)
-> Generic AnomalyDetectorConfig
forall x. Rep AnomalyDetectorConfig x -> AnomalyDetectorConfig
forall x. AnomalyDetectorConfig -> Rep AnomalyDetectorConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnomalyDetectorConfig x -> AnomalyDetectorConfig
$cfrom :: forall x. AnomalyDetectorConfig -> Rep AnomalyDetectorConfig x
Prelude.Generic)

-- |
-- Create a value of 'AnomalyDetectorConfig' 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:
--
-- 'anomalyDetectorFrequency', 'anomalyDetectorConfig_anomalyDetectorFrequency' - The frequency at which the detector analyzes its source data.
newAnomalyDetectorConfig ::
  AnomalyDetectorConfig
newAnomalyDetectorConfig :: AnomalyDetectorConfig
newAnomalyDetectorConfig =
  AnomalyDetectorConfig' :: Maybe Frequency -> AnomalyDetectorConfig
AnomalyDetectorConfig'
    { $sel:anomalyDetectorFrequency:AnomalyDetectorConfig' :: Maybe Frequency
anomalyDetectorFrequency =
        Maybe Frequency
forall a. Maybe a
Prelude.Nothing
    }

-- | The frequency at which the detector analyzes its source data.
anomalyDetectorConfig_anomalyDetectorFrequency :: Lens.Lens' AnomalyDetectorConfig (Prelude.Maybe Frequency)
anomalyDetectorConfig_anomalyDetectorFrequency :: (Maybe Frequency -> f (Maybe Frequency))
-> AnomalyDetectorConfig -> f AnomalyDetectorConfig
anomalyDetectorConfig_anomalyDetectorFrequency = (AnomalyDetectorConfig -> Maybe Frequency)
-> (AnomalyDetectorConfig
    -> Maybe Frequency -> AnomalyDetectorConfig)
-> Lens
     AnomalyDetectorConfig
     AnomalyDetectorConfig
     (Maybe Frequency)
     (Maybe Frequency)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyDetectorConfig' {Maybe Frequency
anomalyDetectorFrequency :: Maybe Frequency
$sel:anomalyDetectorFrequency:AnomalyDetectorConfig' :: AnomalyDetectorConfig -> Maybe Frequency
anomalyDetectorFrequency} -> Maybe Frequency
anomalyDetectorFrequency) (\s :: AnomalyDetectorConfig
s@AnomalyDetectorConfig' {} Maybe Frequency
a -> AnomalyDetectorConfig
s {$sel:anomalyDetectorFrequency:AnomalyDetectorConfig' :: Maybe Frequency
anomalyDetectorFrequency = Maybe Frequency
a} :: AnomalyDetectorConfig)

instance Prelude.Hashable AnomalyDetectorConfig

instance Prelude.NFData AnomalyDetectorConfig

instance Core.ToJSON AnomalyDetectorConfig where
  toJSON :: AnomalyDetectorConfig -> Value
toJSON AnomalyDetectorConfig' {Maybe Frequency
anomalyDetectorFrequency :: Maybe Frequency
$sel:anomalyDetectorFrequency:AnomalyDetectorConfig' :: AnomalyDetectorConfig -> Maybe Frequency
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AnomalyDetectorFrequency" Text -> Frequency -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Frequency -> Pair) -> Maybe Frequency -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Frequency
anomalyDetectorFrequency
          ]
      )