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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutMetrics.Types.AppFlowConfig
import Amazonka.LookoutMetrics.Types.CloudWatchConfig
import Amazonka.LookoutMetrics.Types.RDSSourceConfig
import Amazonka.LookoutMetrics.Types.RedshiftSourceConfig
import Amazonka.LookoutMetrics.Types.S3SourceConfig
import qualified Amazonka.Prelude as Prelude

-- | Contains information about source data used to generate a metric.
--
-- /See:/ 'newMetricSource' smart constructor.
data MetricSource = MetricSource'
  { -- | An object containing information about the Amazon Redshift database
    -- configuration.
    MetricSource -> Maybe RedshiftSourceConfig
redshiftSourceConfig :: Prelude.Maybe RedshiftSourceConfig,
    MetricSource -> Maybe S3SourceConfig
s3SourceConfig :: Prelude.Maybe S3SourceConfig,
    -- | An object containing information about the Amazon Relational Database
    -- Service (RDS) configuration.
    MetricSource -> Maybe RDSSourceConfig
rDSSourceConfig :: Prelude.Maybe RDSSourceConfig,
    -- | An object containing information about the AppFlow configuration.
    MetricSource -> Maybe AppFlowConfig
appFlowConfig :: Prelude.Maybe AppFlowConfig,
    -- | An object containing information about the Amazon CloudWatch monitoring
    -- configuration.
    MetricSource -> Maybe CloudWatchConfig
cloudWatchConfig :: Prelude.Maybe CloudWatchConfig
  }
  deriving (MetricSource -> MetricSource -> Bool
(MetricSource -> MetricSource -> Bool)
-> (MetricSource -> MetricSource -> Bool) -> Eq MetricSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricSource -> MetricSource -> Bool
$c/= :: MetricSource -> MetricSource -> Bool
== :: MetricSource -> MetricSource -> Bool
$c== :: MetricSource -> MetricSource -> Bool
Prelude.Eq, ReadPrec [MetricSource]
ReadPrec MetricSource
Int -> ReadS MetricSource
ReadS [MetricSource]
(Int -> ReadS MetricSource)
-> ReadS [MetricSource]
-> ReadPrec MetricSource
-> ReadPrec [MetricSource]
-> Read MetricSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricSource]
$creadListPrec :: ReadPrec [MetricSource]
readPrec :: ReadPrec MetricSource
$creadPrec :: ReadPrec MetricSource
readList :: ReadS [MetricSource]
$creadList :: ReadS [MetricSource]
readsPrec :: Int -> ReadS MetricSource
$creadsPrec :: Int -> ReadS MetricSource
Prelude.Read, Int -> MetricSource -> ShowS
[MetricSource] -> ShowS
MetricSource -> String
(Int -> MetricSource -> ShowS)
-> (MetricSource -> String)
-> ([MetricSource] -> ShowS)
-> Show MetricSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricSource] -> ShowS
$cshowList :: [MetricSource] -> ShowS
show :: MetricSource -> String
$cshow :: MetricSource -> String
showsPrec :: Int -> MetricSource -> ShowS
$cshowsPrec :: Int -> MetricSource -> ShowS
Prelude.Show, (forall x. MetricSource -> Rep MetricSource x)
-> (forall x. Rep MetricSource x -> MetricSource)
-> Generic MetricSource
forall x. Rep MetricSource x -> MetricSource
forall x. MetricSource -> Rep MetricSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricSource x -> MetricSource
$cfrom :: forall x. MetricSource -> Rep MetricSource x
Prelude.Generic)

-- |
-- Create a value of 'MetricSource' 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:
--
-- 'redshiftSourceConfig', 'metricSource_redshiftSourceConfig' - An object containing information about the Amazon Redshift database
-- configuration.
--
-- 's3SourceConfig', 'metricSource_s3SourceConfig' - Undocumented member.
--
-- 'rDSSourceConfig', 'metricSource_rDSSourceConfig' - An object containing information about the Amazon Relational Database
-- Service (RDS) configuration.
--
-- 'appFlowConfig', 'metricSource_appFlowConfig' - An object containing information about the AppFlow configuration.
--
-- 'cloudWatchConfig', 'metricSource_cloudWatchConfig' - An object containing information about the Amazon CloudWatch monitoring
-- configuration.
newMetricSource ::
  MetricSource
newMetricSource :: MetricSource
newMetricSource =
  MetricSource' :: Maybe RedshiftSourceConfig
-> Maybe S3SourceConfig
-> Maybe RDSSourceConfig
-> Maybe AppFlowConfig
-> Maybe CloudWatchConfig
-> MetricSource
MetricSource'
    { $sel:redshiftSourceConfig:MetricSource' :: Maybe RedshiftSourceConfig
redshiftSourceConfig =
        Maybe RedshiftSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:s3SourceConfig:MetricSource' :: Maybe S3SourceConfig
s3SourceConfig = Maybe S3SourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:rDSSourceConfig:MetricSource' :: Maybe RDSSourceConfig
rDSSourceConfig = Maybe RDSSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:appFlowConfig:MetricSource' :: Maybe AppFlowConfig
appFlowConfig = Maybe AppFlowConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudWatchConfig:MetricSource' :: Maybe CloudWatchConfig
cloudWatchConfig = Maybe CloudWatchConfig
forall a. Maybe a
Prelude.Nothing
    }

-- | An object containing information about the Amazon Redshift database
-- configuration.
metricSource_redshiftSourceConfig :: Lens.Lens' MetricSource (Prelude.Maybe RedshiftSourceConfig)
metricSource_redshiftSourceConfig :: (Maybe RedshiftSourceConfig -> f (Maybe RedshiftSourceConfig))
-> MetricSource -> f MetricSource
metricSource_redshiftSourceConfig = (MetricSource -> Maybe RedshiftSourceConfig)
-> (MetricSource -> Maybe RedshiftSourceConfig -> MetricSource)
-> Lens
     MetricSource
     MetricSource
     (Maybe RedshiftSourceConfig)
     (Maybe RedshiftSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricSource' {Maybe RedshiftSourceConfig
redshiftSourceConfig :: Maybe RedshiftSourceConfig
$sel:redshiftSourceConfig:MetricSource' :: MetricSource -> Maybe RedshiftSourceConfig
redshiftSourceConfig} -> Maybe RedshiftSourceConfig
redshiftSourceConfig) (\s :: MetricSource
s@MetricSource' {} Maybe RedshiftSourceConfig
a -> MetricSource
s {$sel:redshiftSourceConfig:MetricSource' :: Maybe RedshiftSourceConfig
redshiftSourceConfig = Maybe RedshiftSourceConfig
a} :: MetricSource)

-- | Undocumented member.
metricSource_s3SourceConfig :: Lens.Lens' MetricSource (Prelude.Maybe S3SourceConfig)
metricSource_s3SourceConfig :: (Maybe S3SourceConfig -> f (Maybe S3SourceConfig))
-> MetricSource -> f MetricSource
metricSource_s3SourceConfig = (MetricSource -> Maybe S3SourceConfig)
-> (MetricSource -> Maybe S3SourceConfig -> MetricSource)
-> Lens
     MetricSource
     MetricSource
     (Maybe S3SourceConfig)
     (Maybe S3SourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricSource' {Maybe S3SourceConfig
s3SourceConfig :: Maybe S3SourceConfig
$sel:s3SourceConfig:MetricSource' :: MetricSource -> Maybe S3SourceConfig
s3SourceConfig} -> Maybe S3SourceConfig
s3SourceConfig) (\s :: MetricSource
s@MetricSource' {} Maybe S3SourceConfig
a -> MetricSource
s {$sel:s3SourceConfig:MetricSource' :: Maybe S3SourceConfig
s3SourceConfig = Maybe S3SourceConfig
a} :: MetricSource)

-- | An object containing information about the Amazon Relational Database
-- Service (RDS) configuration.
metricSource_rDSSourceConfig :: Lens.Lens' MetricSource (Prelude.Maybe RDSSourceConfig)
metricSource_rDSSourceConfig :: (Maybe RDSSourceConfig -> f (Maybe RDSSourceConfig))
-> MetricSource -> f MetricSource
metricSource_rDSSourceConfig = (MetricSource -> Maybe RDSSourceConfig)
-> (MetricSource -> Maybe RDSSourceConfig -> MetricSource)
-> Lens
     MetricSource
     MetricSource
     (Maybe RDSSourceConfig)
     (Maybe RDSSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricSource' {Maybe RDSSourceConfig
rDSSourceConfig :: Maybe RDSSourceConfig
$sel:rDSSourceConfig:MetricSource' :: MetricSource -> Maybe RDSSourceConfig
rDSSourceConfig} -> Maybe RDSSourceConfig
rDSSourceConfig) (\s :: MetricSource
s@MetricSource' {} Maybe RDSSourceConfig
a -> MetricSource
s {$sel:rDSSourceConfig:MetricSource' :: Maybe RDSSourceConfig
rDSSourceConfig = Maybe RDSSourceConfig
a} :: MetricSource)

-- | An object containing information about the AppFlow configuration.
metricSource_appFlowConfig :: Lens.Lens' MetricSource (Prelude.Maybe AppFlowConfig)
metricSource_appFlowConfig :: (Maybe AppFlowConfig -> f (Maybe AppFlowConfig))
-> MetricSource -> f MetricSource
metricSource_appFlowConfig = (MetricSource -> Maybe AppFlowConfig)
-> (MetricSource -> Maybe AppFlowConfig -> MetricSource)
-> Lens
     MetricSource
     MetricSource
     (Maybe AppFlowConfig)
     (Maybe AppFlowConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricSource' {Maybe AppFlowConfig
appFlowConfig :: Maybe AppFlowConfig
$sel:appFlowConfig:MetricSource' :: MetricSource -> Maybe AppFlowConfig
appFlowConfig} -> Maybe AppFlowConfig
appFlowConfig) (\s :: MetricSource
s@MetricSource' {} Maybe AppFlowConfig
a -> MetricSource
s {$sel:appFlowConfig:MetricSource' :: Maybe AppFlowConfig
appFlowConfig = Maybe AppFlowConfig
a} :: MetricSource)

-- | An object containing information about the Amazon CloudWatch monitoring
-- configuration.
metricSource_cloudWatchConfig :: Lens.Lens' MetricSource (Prelude.Maybe CloudWatchConfig)
metricSource_cloudWatchConfig :: (Maybe CloudWatchConfig -> f (Maybe CloudWatchConfig))
-> MetricSource -> f MetricSource
metricSource_cloudWatchConfig = (MetricSource -> Maybe CloudWatchConfig)
-> (MetricSource -> Maybe CloudWatchConfig -> MetricSource)
-> Lens
     MetricSource
     MetricSource
     (Maybe CloudWatchConfig)
     (Maybe CloudWatchConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricSource' {Maybe CloudWatchConfig
cloudWatchConfig :: Maybe CloudWatchConfig
$sel:cloudWatchConfig:MetricSource' :: MetricSource -> Maybe CloudWatchConfig
cloudWatchConfig} -> Maybe CloudWatchConfig
cloudWatchConfig) (\s :: MetricSource
s@MetricSource' {} Maybe CloudWatchConfig
a -> MetricSource
s {$sel:cloudWatchConfig:MetricSource' :: Maybe CloudWatchConfig
cloudWatchConfig = Maybe CloudWatchConfig
a} :: MetricSource)

instance Core.FromJSON MetricSource where
  parseJSON :: Value -> Parser MetricSource
parseJSON =
    String
-> (Object -> Parser MetricSource) -> Value -> Parser MetricSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricSource"
      ( \Object
x ->
          Maybe RedshiftSourceConfig
-> Maybe S3SourceConfig
-> Maybe RDSSourceConfig
-> Maybe AppFlowConfig
-> Maybe CloudWatchConfig
-> MetricSource
MetricSource'
            (Maybe RedshiftSourceConfig
 -> Maybe S3SourceConfig
 -> Maybe RDSSourceConfig
 -> Maybe AppFlowConfig
 -> Maybe CloudWatchConfig
 -> MetricSource)
-> Parser (Maybe RedshiftSourceConfig)
-> Parser
     (Maybe S3SourceConfig
      -> Maybe RDSSourceConfig
      -> Maybe AppFlowConfig
      -> Maybe CloudWatchConfig
      -> MetricSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RedshiftSourceConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RedshiftSourceConfig")
            Parser
  (Maybe S3SourceConfig
   -> Maybe RDSSourceConfig
   -> Maybe AppFlowConfig
   -> Maybe CloudWatchConfig
   -> MetricSource)
-> Parser (Maybe S3SourceConfig)
-> Parser
     (Maybe RDSSourceConfig
      -> Maybe AppFlowConfig -> Maybe CloudWatchConfig -> MetricSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe S3SourceConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3SourceConfig")
            Parser
  (Maybe RDSSourceConfig
   -> Maybe AppFlowConfig -> Maybe CloudWatchConfig -> MetricSource)
-> Parser (Maybe RDSSourceConfig)
-> Parser
     (Maybe AppFlowConfig -> Maybe CloudWatchConfig -> MetricSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RDSSourceConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RDSSourceConfig")
            Parser
  (Maybe AppFlowConfig -> Maybe CloudWatchConfig -> MetricSource)
-> Parser (Maybe AppFlowConfig)
-> Parser (Maybe CloudWatchConfig -> MetricSource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AppFlowConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AppFlowConfig")
            Parser (Maybe CloudWatchConfig -> MetricSource)
-> Parser (Maybe CloudWatchConfig) -> Parser MetricSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CloudWatchConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CloudWatchConfig")
      )

instance Prelude.Hashable MetricSource

instance Prelude.NFData MetricSource

instance Core.ToJSON MetricSource where
  toJSON :: MetricSource -> Value
toJSON MetricSource' {Maybe AppFlowConfig
Maybe CloudWatchConfig
Maybe S3SourceConfig
Maybe RedshiftSourceConfig
Maybe RDSSourceConfig
cloudWatchConfig :: Maybe CloudWatchConfig
appFlowConfig :: Maybe AppFlowConfig
rDSSourceConfig :: Maybe RDSSourceConfig
s3SourceConfig :: Maybe S3SourceConfig
redshiftSourceConfig :: Maybe RedshiftSourceConfig
$sel:cloudWatchConfig:MetricSource' :: MetricSource -> Maybe CloudWatchConfig
$sel:appFlowConfig:MetricSource' :: MetricSource -> Maybe AppFlowConfig
$sel:rDSSourceConfig:MetricSource' :: MetricSource -> Maybe RDSSourceConfig
$sel:s3SourceConfig:MetricSource' :: MetricSource -> Maybe S3SourceConfig
$sel:redshiftSourceConfig:MetricSource' :: MetricSource -> Maybe RedshiftSourceConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RedshiftSourceConfig" Text -> RedshiftSourceConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RedshiftSourceConfig -> Pair)
-> Maybe RedshiftSourceConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RedshiftSourceConfig
redshiftSourceConfig,
            (Text
"S3SourceConfig" Text -> S3SourceConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (S3SourceConfig -> Pair) -> Maybe S3SourceConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3SourceConfig
s3SourceConfig,
            (Text
"RDSSourceConfig" Text -> RDSSourceConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RDSSourceConfig -> Pair) -> Maybe RDSSourceConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RDSSourceConfig
rDSSourceConfig,
            (Text
"AppFlowConfig" Text -> AppFlowConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AppFlowConfig -> Pair) -> Maybe AppFlowConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AppFlowConfig
appFlowConfig,
            (Text
"CloudWatchConfig" Text -> CloudWatchConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CloudWatchConfig -> Pair) -> Maybe CloudWatchConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CloudWatchConfig
cloudWatchConfig
          ]
      )