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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.ComputeLocation
import qualified Amazonka.Lens as Lens
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
(MetricProcessingConfig -> MetricProcessingConfig -> Bool)
-> (MetricProcessingConfig -> MetricProcessingConfig -> Bool)
-> Eq MetricProcessingConfig
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]
(Int -> ReadS MetricProcessingConfig)
-> ReadS [MetricProcessingConfig]
-> ReadPrec MetricProcessingConfig
-> ReadPrec [MetricProcessingConfig]
-> Read 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
(Int -> MetricProcessingConfig -> ShowS)
-> (MetricProcessingConfig -> String)
-> ([MetricProcessingConfig] -> ShowS)
-> Show MetricProcessingConfig
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. MetricProcessingConfig -> Rep MetricProcessingConfig x)
-> (forall x.
    Rep MetricProcessingConfig x -> MetricProcessingConfig)
-> Generic MetricProcessingConfig
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' :: ComputeLocation -> MetricProcessingConfig
MetricProcessingConfig'
    { $sel:computeLocation:MetricProcessingConfig' :: ComputeLocation
computeLocation =
        ComputeLocation
pComputeLocation_
    }

-- | The compute location for the given metric property.
metricProcessingConfig_computeLocation :: Lens.Lens' MetricProcessingConfig ComputeLocation
metricProcessingConfig_computeLocation :: (ComputeLocation -> f ComputeLocation)
-> MetricProcessingConfig -> f MetricProcessingConfig
metricProcessingConfig_computeLocation = (MetricProcessingConfig -> ComputeLocation)
-> (MetricProcessingConfig
    -> ComputeLocation -> MetricProcessingConfig)
-> Lens
     MetricProcessingConfig
     MetricProcessingConfig
     ComputeLocation
     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 Core.FromJSON MetricProcessingConfig where
  parseJSON :: Value -> Parser MetricProcessingConfig
parseJSON =
    String
-> (Object -> Parser MetricProcessingConfig)
-> Value
-> Parser MetricProcessingConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricProcessingConfig"
      ( \Object
x ->
          ComputeLocation -> MetricProcessingConfig
MetricProcessingConfig'
            (ComputeLocation -> MetricProcessingConfig)
-> Parser ComputeLocation -> Parser MetricProcessingConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ComputeLocation
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"computeLocation")
      )

instance Prelude.Hashable MetricProcessingConfig

instance Prelude.NFData MetricProcessingConfig

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