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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.ForwardingConfig
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'MeasurementProcessingConfig' 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:
--
-- 'forwardingConfig', 'measurementProcessingConfig_forwardingConfig' - The forwarding configuration for the given measurement property.
newMeasurementProcessingConfig ::
  -- | 'forwardingConfig'
  ForwardingConfig ->
  MeasurementProcessingConfig
newMeasurementProcessingConfig :: ForwardingConfig -> MeasurementProcessingConfig
newMeasurementProcessingConfig ForwardingConfig
pForwardingConfig_ =
  MeasurementProcessingConfig' :: ForwardingConfig -> MeasurementProcessingConfig
MeasurementProcessingConfig'
    { $sel:forwardingConfig:MeasurementProcessingConfig' :: ForwardingConfig
forwardingConfig =
        ForwardingConfig
pForwardingConfig_
    }

-- | The forwarding configuration for the given measurement property.
measurementProcessingConfig_forwardingConfig :: Lens.Lens' MeasurementProcessingConfig ForwardingConfig
measurementProcessingConfig_forwardingConfig :: (ForwardingConfig -> f ForwardingConfig)
-> MeasurementProcessingConfig -> f MeasurementProcessingConfig
measurementProcessingConfig_forwardingConfig = (MeasurementProcessingConfig -> ForwardingConfig)
-> (MeasurementProcessingConfig
    -> ForwardingConfig -> MeasurementProcessingConfig)
-> Lens
     MeasurementProcessingConfig
     MeasurementProcessingConfig
     ForwardingConfig
     ForwardingConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeasurementProcessingConfig' {ForwardingConfig
forwardingConfig :: ForwardingConfig
$sel:forwardingConfig:MeasurementProcessingConfig' :: MeasurementProcessingConfig -> ForwardingConfig
forwardingConfig} -> ForwardingConfig
forwardingConfig) (\s :: MeasurementProcessingConfig
s@MeasurementProcessingConfig' {} ForwardingConfig
a -> MeasurementProcessingConfig
s {$sel:forwardingConfig:MeasurementProcessingConfig' :: ForwardingConfig
forwardingConfig = ForwardingConfig
a} :: MeasurementProcessingConfig)

instance Core.FromJSON MeasurementProcessingConfig where
  parseJSON :: Value -> Parser MeasurementProcessingConfig
parseJSON =
    String
-> (Object -> Parser MeasurementProcessingConfig)
-> Value
-> Parser MeasurementProcessingConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MeasurementProcessingConfig"
      ( \Object
x ->
          ForwardingConfig -> MeasurementProcessingConfig
MeasurementProcessingConfig'
            (ForwardingConfig -> MeasurementProcessingConfig)
-> Parser ForwardingConfig -> Parser MeasurementProcessingConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ForwardingConfig
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"forwardingConfig")
      )

instance Prelude.Hashable MeasurementProcessingConfig

instance Prelude.NFData MeasurementProcessingConfig

instance Core.ToJSON MeasurementProcessingConfig where
  toJSON :: MeasurementProcessingConfig -> Value
toJSON MeasurementProcessingConfig' {ForwardingConfig
forwardingConfig :: ForwardingConfig
$sel:forwardingConfig:MeasurementProcessingConfig' :: MeasurementProcessingConfig -> ForwardingConfig
..} =
    [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
"forwardingConfig" Text -> ForwardingConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ForwardingConfig
forwardingConfig)
          ]
      )