{-# 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.ForwardingConfig
-- 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.ForwardingConfig 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.ForwardingConfigState
import qualified Amazonka.Prelude as Prelude

-- | The forwarding configuration for a given property.
--
-- /See:/ 'newForwardingConfig' smart constructor.
data ForwardingConfig = ForwardingConfig'
  { -- | The forwarding state for the given property.
    ForwardingConfig -> ForwardingConfigState
state :: ForwardingConfigState
  }
  deriving (ForwardingConfig -> ForwardingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ForwardingConfig -> ForwardingConfig -> Bool
$c/= :: ForwardingConfig -> ForwardingConfig -> Bool
== :: ForwardingConfig -> ForwardingConfig -> Bool
$c== :: ForwardingConfig -> ForwardingConfig -> Bool
Prelude.Eq, ReadPrec [ForwardingConfig]
ReadPrec ForwardingConfig
Int -> ReadS ForwardingConfig
ReadS [ForwardingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ForwardingConfig]
$creadListPrec :: ReadPrec [ForwardingConfig]
readPrec :: ReadPrec ForwardingConfig
$creadPrec :: ReadPrec ForwardingConfig
readList :: ReadS [ForwardingConfig]
$creadList :: ReadS [ForwardingConfig]
readsPrec :: Int -> ReadS ForwardingConfig
$creadsPrec :: Int -> ReadS ForwardingConfig
Prelude.Read, Int -> ForwardingConfig -> ShowS
[ForwardingConfig] -> ShowS
ForwardingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ForwardingConfig] -> ShowS
$cshowList :: [ForwardingConfig] -> ShowS
show :: ForwardingConfig -> String
$cshow :: ForwardingConfig -> String
showsPrec :: Int -> ForwardingConfig -> ShowS
$cshowsPrec :: Int -> ForwardingConfig -> ShowS
Prelude.Show, forall x. Rep ForwardingConfig x -> ForwardingConfig
forall x. ForwardingConfig -> Rep ForwardingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ForwardingConfig x -> ForwardingConfig
$cfrom :: forall x. ForwardingConfig -> Rep ForwardingConfig x
Prelude.Generic)

-- |
-- Create a value of 'ForwardingConfig' 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:
--
-- 'state', 'forwardingConfig_state' - The forwarding state for the given property.
newForwardingConfig ::
  -- | 'state'
  ForwardingConfigState ->
  ForwardingConfig
newForwardingConfig :: ForwardingConfigState -> ForwardingConfig
newForwardingConfig ForwardingConfigState
pState_ =
  ForwardingConfig' {$sel:state:ForwardingConfig' :: ForwardingConfigState
state = ForwardingConfigState
pState_}

-- | The forwarding state for the given property.
forwardingConfig_state :: Lens.Lens' ForwardingConfig ForwardingConfigState
forwardingConfig_state :: Lens' ForwardingConfig ForwardingConfigState
forwardingConfig_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ForwardingConfig' {ForwardingConfigState
state :: ForwardingConfigState
$sel:state:ForwardingConfig' :: ForwardingConfig -> ForwardingConfigState
state} -> ForwardingConfigState
state) (\s :: ForwardingConfig
s@ForwardingConfig' {} ForwardingConfigState
a -> ForwardingConfig
s {$sel:state:ForwardingConfig' :: ForwardingConfigState
state = ForwardingConfigState
a} :: ForwardingConfig)

instance Data.FromJSON ForwardingConfig where
  parseJSON :: Value -> Parser ForwardingConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ForwardingConfig"
      ( \Object
x ->
          ForwardingConfigState -> ForwardingConfig
ForwardingConfig' 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
"state")
      )

instance Prelude.Hashable ForwardingConfig where
  hashWithSalt :: Int -> ForwardingConfig -> Int
hashWithSalt Int
_salt ForwardingConfig' {ForwardingConfigState
state :: ForwardingConfigState
$sel:state:ForwardingConfig' :: ForwardingConfig -> ForwardingConfigState
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ForwardingConfigState
state

instance Prelude.NFData ForwardingConfig where
  rnf :: ForwardingConfig -> ()
rnf ForwardingConfig' {ForwardingConfigState
state :: ForwardingConfigState
$sel:state:ForwardingConfig' :: ForwardingConfig -> ForwardingConfigState
..} = forall a. NFData a => a -> ()
Prelude.rnf ForwardingConfigState
state

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