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

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

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

-- |
-- Create a value of 'TransformProcessingConfig' 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', 'transformProcessingConfig_forwardingConfig' - Undocumented member.
--
-- 'computeLocation', 'transformProcessingConfig_computeLocation' - The compute location for the given transform property.
newTransformProcessingConfig ::
  -- | 'computeLocation'
  ComputeLocation ->
  TransformProcessingConfig
newTransformProcessingConfig :: ComputeLocation -> TransformProcessingConfig
newTransformProcessingConfig ComputeLocation
pComputeLocation_ =
  TransformProcessingConfig' :: Maybe ForwardingConfig
-> ComputeLocation -> TransformProcessingConfig
TransformProcessingConfig'
    { $sel:forwardingConfig:TransformProcessingConfig' :: Maybe ForwardingConfig
forwardingConfig =
        Maybe ForwardingConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:computeLocation:TransformProcessingConfig' :: ComputeLocation
computeLocation = ComputeLocation
pComputeLocation_
    }

-- | Undocumented member.
transformProcessingConfig_forwardingConfig :: Lens.Lens' TransformProcessingConfig (Prelude.Maybe ForwardingConfig)
transformProcessingConfig_forwardingConfig :: (Maybe ForwardingConfig -> f (Maybe ForwardingConfig))
-> TransformProcessingConfig -> f TransformProcessingConfig
transformProcessingConfig_forwardingConfig = (TransformProcessingConfig -> Maybe ForwardingConfig)
-> (TransformProcessingConfig
    -> Maybe ForwardingConfig -> TransformProcessingConfig)
-> Lens
     TransformProcessingConfig
     TransformProcessingConfig
     (Maybe ForwardingConfig)
     (Maybe ForwardingConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransformProcessingConfig' {Maybe ForwardingConfig
forwardingConfig :: Maybe ForwardingConfig
$sel:forwardingConfig:TransformProcessingConfig' :: TransformProcessingConfig -> Maybe ForwardingConfig
forwardingConfig} -> Maybe ForwardingConfig
forwardingConfig) (\s :: TransformProcessingConfig
s@TransformProcessingConfig' {} Maybe ForwardingConfig
a -> TransformProcessingConfig
s {$sel:forwardingConfig:TransformProcessingConfig' :: Maybe ForwardingConfig
forwardingConfig = Maybe ForwardingConfig
a} :: TransformProcessingConfig)

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

instance Core.FromJSON TransformProcessingConfig where
  parseJSON :: Value -> Parser TransformProcessingConfig
parseJSON =
    String
-> (Object -> Parser TransformProcessingConfig)
-> Value
-> Parser TransformProcessingConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TransformProcessingConfig"
      ( \Object
x ->
          Maybe ForwardingConfig
-> ComputeLocation -> TransformProcessingConfig
TransformProcessingConfig'
            (Maybe ForwardingConfig
 -> ComputeLocation -> TransformProcessingConfig)
-> Parser (Maybe ForwardingConfig)
-> Parser (ComputeLocation -> TransformProcessingConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ForwardingConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"forwardingConfig")
            Parser (ComputeLocation -> TransformProcessingConfig)
-> Parser ComputeLocation -> Parser TransformProcessingConfig
forall (f :: * -> *) a b. Applicative f => 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 TransformProcessingConfig

instance Prelude.NFData TransformProcessingConfig

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