{-# 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.IoTThingsGraph.Types.MetricsConfiguration
-- 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.IoTThingsGraph.Types.MetricsConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that specifies whether cloud metrics are collected in a
-- deployment and, if so, what role is used to collect metrics.
--
-- /See:/ 'newMetricsConfiguration' smart constructor.
data MetricsConfiguration = MetricsConfiguration'
  { -- | A Boolean that specifies whether cloud metrics are collected.
    MetricsConfiguration -> Maybe Bool
cloudMetricEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The ARN of the role that is used to collect cloud metrics.
    MetricsConfiguration -> Maybe Text
metricRuleRoleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (MetricsConfiguration -> MetricsConfiguration -> Bool
(MetricsConfiguration -> MetricsConfiguration -> Bool)
-> (MetricsConfiguration -> MetricsConfiguration -> Bool)
-> Eq MetricsConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricsConfiguration -> MetricsConfiguration -> Bool
$c/= :: MetricsConfiguration -> MetricsConfiguration -> Bool
== :: MetricsConfiguration -> MetricsConfiguration -> Bool
$c== :: MetricsConfiguration -> MetricsConfiguration -> Bool
Prelude.Eq, ReadPrec [MetricsConfiguration]
ReadPrec MetricsConfiguration
Int -> ReadS MetricsConfiguration
ReadS [MetricsConfiguration]
(Int -> ReadS MetricsConfiguration)
-> ReadS [MetricsConfiguration]
-> ReadPrec MetricsConfiguration
-> ReadPrec [MetricsConfiguration]
-> Read MetricsConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricsConfiguration]
$creadListPrec :: ReadPrec [MetricsConfiguration]
readPrec :: ReadPrec MetricsConfiguration
$creadPrec :: ReadPrec MetricsConfiguration
readList :: ReadS [MetricsConfiguration]
$creadList :: ReadS [MetricsConfiguration]
readsPrec :: Int -> ReadS MetricsConfiguration
$creadsPrec :: Int -> ReadS MetricsConfiguration
Prelude.Read, Int -> MetricsConfiguration -> ShowS
[MetricsConfiguration] -> ShowS
MetricsConfiguration -> String
(Int -> MetricsConfiguration -> ShowS)
-> (MetricsConfiguration -> String)
-> ([MetricsConfiguration] -> ShowS)
-> Show MetricsConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricsConfiguration] -> ShowS
$cshowList :: [MetricsConfiguration] -> ShowS
show :: MetricsConfiguration -> String
$cshow :: MetricsConfiguration -> String
showsPrec :: Int -> MetricsConfiguration -> ShowS
$cshowsPrec :: Int -> MetricsConfiguration -> ShowS
Prelude.Show, (forall x. MetricsConfiguration -> Rep MetricsConfiguration x)
-> (forall x. Rep MetricsConfiguration x -> MetricsConfiguration)
-> Generic MetricsConfiguration
forall x. Rep MetricsConfiguration x -> MetricsConfiguration
forall x. MetricsConfiguration -> Rep MetricsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricsConfiguration x -> MetricsConfiguration
$cfrom :: forall x. MetricsConfiguration -> Rep MetricsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'MetricsConfiguration' 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:
--
-- 'cloudMetricEnabled', 'metricsConfiguration_cloudMetricEnabled' - A Boolean that specifies whether cloud metrics are collected.
--
-- 'metricRuleRoleArn', 'metricsConfiguration_metricRuleRoleArn' - The ARN of the role that is used to collect cloud metrics.
newMetricsConfiguration ::
  MetricsConfiguration
newMetricsConfiguration :: MetricsConfiguration
newMetricsConfiguration =
  MetricsConfiguration' :: Maybe Bool -> Maybe Text -> MetricsConfiguration
MetricsConfiguration'
    { $sel:cloudMetricEnabled:MetricsConfiguration' :: Maybe Bool
cloudMetricEnabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:metricRuleRoleArn:MetricsConfiguration' :: Maybe Text
metricRuleRoleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A Boolean that specifies whether cloud metrics are collected.
metricsConfiguration_cloudMetricEnabled :: Lens.Lens' MetricsConfiguration (Prelude.Maybe Prelude.Bool)
metricsConfiguration_cloudMetricEnabled :: (Maybe Bool -> f (Maybe Bool))
-> MetricsConfiguration -> f MetricsConfiguration
metricsConfiguration_cloudMetricEnabled = (MetricsConfiguration -> Maybe Bool)
-> (MetricsConfiguration -> Maybe Bool -> MetricsConfiguration)
-> Lens
     MetricsConfiguration MetricsConfiguration (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricsConfiguration' {Maybe Bool
cloudMetricEnabled :: Maybe Bool
$sel:cloudMetricEnabled:MetricsConfiguration' :: MetricsConfiguration -> Maybe Bool
cloudMetricEnabled} -> Maybe Bool
cloudMetricEnabled) (\s :: MetricsConfiguration
s@MetricsConfiguration' {} Maybe Bool
a -> MetricsConfiguration
s {$sel:cloudMetricEnabled:MetricsConfiguration' :: Maybe Bool
cloudMetricEnabled = Maybe Bool
a} :: MetricsConfiguration)

-- | The ARN of the role that is used to collect cloud metrics.
metricsConfiguration_metricRuleRoleArn :: Lens.Lens' MetricsConfiguration (Prelude.Maybe Prelude.Text)
metricsConfiguration_metricRuleRoleArn :: (Maybe Text -> f (Maybe Text))
-> MetricsConfiguration -> f MetricsConfiguration
metricsConfiguration_metricRuleRoleArn = (MetricsConfiguration -> Maybe Text)
-> (MetricsConfiguration -> Maybe Text -> MetricsConfiguration)
-> Lens
     MetricsConfiguration MetricsConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricsConfiguration' {Maybe Text
metricRuleRoleArn :: Maybe Text
$sel:metricRuleRoleArn:MetricsConfiguration' :: MetricsConfiguration -> Maybe Text
metricRuleRoleArn} -> Maybe Text
metricRuleRoleArn) (\s :: MetricsConfiguration
s@MetricsConfiguration' {} Maybe Text
a -> MetricsConfiguration
s {$sel:metricRuleRoleArn:MetricsConfiguration' :: Maybe Text
metricRuleRoleArn = Maybe Text
a} :: MetricsConfiguration)

instance Core.FromJSON MetricsConfiguration where
  parseJSON :: Value -> Parser MetricsConfiguration
parseJSON =
    String
-> (Object -> Parser MetricsConfiguration)
-> Value
-> Parser MetricsConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricsConfiguration"
      ( \Object
x ->
          Maybe Bool -> Maybe Text -> MetricsConfiguration
MetricsConfiguration'
            (Maybe Bool -> Maybe Text -> MetricsConfiguration)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> MetricsConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cloudMetricEnabled")
            Parser (Maybe Text -> MetricsConfiguration)
-> Parser (Maybe Text) -> Parser MetricsConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"metricRuleRoleArn")
      )

instance Prelude.Hashable MetricsConfiguration

instance Prelude.NFData MetricsConfiguration

instance Core.ToJSON MetricsConfiguration where
  toJSON :: MetricsConfiguration -> Value
toJSON MetricsConfiguration' {Maybe Bool
Maybe Text
metricRuleRoleArn :: Maybe Text
cloudMetricEnabled :: Maybe Bool
$sel:metricRuleRoleArn:MetricsConfiguration' :: MetricsConfiguration -> Maybe Text
$sel:cloudMetricEnabled:MetricsConfiguration' :: MetricsConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"cloudMetricEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
cloudMetricEnabled,
            (Text
"metricRuleRoleArn" 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
metricRuleRoleArn
          ]
      )