{-# 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.IoTSiteWise.Types.MetricProcessingConfig
-- 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.IoTSiteWise.Types.MetricProcessingConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTSiteWise.Types.ComputeLocation
import qualified Amazonka.Prelude as Prelude

-- | The processing configuration for the given metric property. You can
-- configure metrics to be computed at the edge or in the Amazon Web
-- Services Cloud. By default, metrics are forwarded to the cloud.
--
-- /See:/ 'newMetricProcessingConfig' smart constructor.
data MetricProcessingConfig = MetricProcessingConfig'
  { -- | The compute location for the given metric property.
    MetricProcessingConfig -> ComputeLocation
computeLocation :: ComputeLocation
  }
  deriving (MetricProcessingConfig -> MetricProcessingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricProcessingConfig -> MetricProcessingConfig -> Bool
$c/= :: MetricProcessingConfig -> MetricProcessingConfig -> Bool
== :: MetricProcessingConfig -> MetricProcessingConfig -> Bool
$c== :: MetricProcessingConfig -> MetricProcessingConfig -> Bool
Prelude.Eq, ReadPrec [MetricProcessingConfig]
ReadPrec MetricProcessingConfig
Int -> ReadS MetricProcessingConfig
ReadS [MetricProcessingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricProcessingConfig]
$creadListPrec :: ReadPrec [MetricProcessingConfig]
readPrec :: ReadPrec MetricProcessingConfig
$creadPrec :: ReadPrec MetricProcessingConfig
readList :: ReadS [MetricProcessingConfig]
$creadList :: ReadS [MetricProcessingConfig]
readsPrec :: Int -> ReadS MetricProcessingConfig
$creadsPrec :: Int -> ReadS MetricProcessingConfig
Prelude.Read, Int -> MetricProcessingConfig -> ShowS
[MetricProcessingConfig] -> ShowS
MetricProcessingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricProcessingConfig] -> ShowS
$cshowList :: [MetricProcessingConfig] -> ShowS
show :: MetricProcessingConfig -> String
$cshow :: MetricProcessingConfig -> String
showsPrec :: Int -> MetricProcessingConfig -> ShowS
$cshowsPrec :: Int -> MetricProcessingConfig -> ShowS
Prelude.Show, forall x. Rep MetricProcessingConfig x -> MetricProcessingConfig
forall x. MetricProcessingConfig -> Rep MetricProcessingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricProcessingConfig x -> MetricProcessingConfig
$cfrom :: forall x. MetricProcessingConfig -> Rep MetricProcessingConfig x
Prelude.Generic)

-- |
-- Create a value of 'MetricProcessingConfig' 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:
--
-- 'computeLocation', 'metricProcessingConfig_computeLocation' - The compute location for the given metric property.
newMetricProcessingConfig ::
  -- | 'computeLocation'
  ComputeLocation ->
  MetricProcessingConfig
newMetricProcessingConfig :: ComputeLocation -> MetricProcessingConfig
newMetricProcessingConfig ComputeLocation
pComputeLocation_ =
  MetricProcessingConfig'
    { $sel:computeLocation:MetricProcessingConfig' :: ComputeLocation
computeLocation =
        ComputeLocation
pComputeLocation_
    }

-- | The compute location for the given metric property.
metricProcessingConfig_computeLocation :: Lens.Lens' MetricProcessingConfig ComputeLocation
metricProcessingConfig_computeLocation :: Lens' MetricProcessingConfig ComputeLocation
metricProcessingConfig_computeLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricProcessingConfig' {ComputeLocation
computeLocation :: ComputeLocation
$sel:computeLocation:MetricProcessingConfig' :: MetricProcessingConfig -> ComputeLocation
computeLocation} -> ComputeLocation
computeLocation) (\s :: MetricProcessingConfig
s@MetricProcessingConfig' {} ComputeLocation
a -> MetricProcessingConfig
s {$sel:computeLocation:MetricProcessingConfig' :: ComputeLocation
computeLocation = ComputeLocation
a} :: MetricProcessingConfig)

instance Data.FromJSON MetricProcessingConfig where
  parseJSON :: Value -> Parser MetricProcessingConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MetricProcessingConfig"
      ( \Object
x ->
          ComputeLocation -> MetricProcessingConfig
MetricProcessingConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"computeLocation")
      )

instance Prelude.Hashable MetricProcessingConfig where
  hashWithSalt :: Int -> MetricProcessingConfig -> Int
hashWithSalt Int
_salt MetricProcessingConfig' {ComputeLocation
computeLocation :: ComputeLocation
$sel:computeLocation:MetricProcessingConfig' :: MetricProcessingConfig -> ComputeLocation
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ComputeLocation
computeLocation

instance Prelude.NFData MetricProcessingConfig where
  rnf :: MetricProcessingConfig -> ()
rnf MetricProcessingConfig' {ComputeLocation
computeLocation :: ComputeLocation
$sel:computeLocation:MetricProcessingConfig' :: MetricProcessingConfig -> ComputeLocation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ComputeLocation
computeLocation

instance Data.ToJSON MetricProcessingConfig where
  toJSON :: MetricProcessingConfig -> Value
toJSON MetricProcessingConfig' {ComputeLocation
computeLocation :: ComputeLocation
$sel:computeLocation:MetricProcessingConfig' :: MetricProcessingConfig -> ComputeLocation
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"computeLocation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ComputeLocation
computeLocation)
          ]
      )