{-# 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.IoTFleetWise.Types.SignalInformation
-- 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.IoTFleetWise.Types.SignalInformation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Information about a signal.
--
-- /See:/ 'newSignalInformation' smart constructor.
data SignalInformation = SignalInformation'
  { -- | The maximum number of samples to collect.
    SignalInformation -> Maybe Natural
maxSampleCount :: Prelude.Maybe Prelude.Natural,
    -- | The minimum duration of time (in milliseconds) between two triggering
    -- events to collect data.
    --
    -- If a signal changes often, you might want to collect data at a slower
    -- rate.
    SignalInformation -> Maybe Natural
minimumSamplingIntervalMs :: Prelude.Maybe Prelude.Natural,
    -- | The name of the signal.
    SignalInformation -> Text
name :: Prelude.Text
  }
  deriving (SignalInformation -> SignalInformation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignalInformation -> SignalInformation -> Bool
$c/= :: SignalInformation -> SignalInformation -> Bool
== :: SignalInformation -> SignalInformation -> Bool
$c== :: SignalInformation -> SignalInformation -> Bool
Prelude.Eq, ReadPrec [SignalInformation]
ReadPrec SignalInformation
Int -> ReadS SignalInformation
ReadS [SignalInformation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignalInformation]
$creadListPrec :: ReadPrec [SignalInformation]
readPrec :: ReadPrec SignalInformation
$creadPrec :: ReadPrec SignalInformation
readList :: ReadS [SignalInformation]
$creadList :: ReadS [SignalInformation]
readsPrec :: Int -> ReadS SignalInformation
$creadsPrec :: Int -> ReadS SignalInformation
Prelude.Read, Int -> SignalInformation -> ShowS
[SignalInformation] -> ShowS
SignalInformation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignalInformation] -> ShowS
$cshowList :: [SignalInformation] -> ShowS
show :: SignalInformation -> String
$cshow :: SignalInformation -> String
showsPrec :: Int -> SignalInformation -> ShowS
$cshowsPrec :: Int -> SignalInformation -> ShowS
Prelude.Show, forall x. Rep SignalInformation x -> SignalInformation
forall x. SignalInformation -> Rep SignalInformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SignalInformation x -> SignalInformation
$cfrom :: forall x. SignalInformation -> Rep SignalInformation x
Prelude.Generic)

-- |
-- Create a value of 'SignalInformation' 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:
--
-- 'maxSampleCount', 'signalInformation_maxSampleCount' - The maximum number of samples to collect.
--
-- 'minimumSamplingIntervalMs', 'signalInformation_minimumSamplingIntervalMs' - The minimum duration of time (in milliseconds) between two triggering
-- events to collect data.
--
-- If a signal changes often, you might want to collect data at a slower
-- rate.
--
-- 'name', 'signalInformation_name' - The name of the signal.
newSignalInformation ::
  -- | 'name'
  Prelude.Text ->
  SignalInformation
newSignalInformation :: Text -> SignalInformation
newSignalInformation Text
pName_ =
  SignalInformation'
    { $sel:maxSampleCount:SignalInformation' :: Maybe Natural
maxSampleCount =
        forall a. Maybe a
Prelude.Nothing,
      $sel:minimumSamplingIntervalMs:SignalInformation' :: Maybe Natural
minimumSamplingIntervalMs = forall a. Maybe a
Prelude.Nothing,
      $sel:name:SignalInformation' :: Text
name = Text
pName_
    }

-- | The maximum number of samples to collect.
signalInformation_maxSampleCount :: Lens.Lens' SignalInformation (Prelude.Maybe Prelude.Natural)
signalInformation_maxSampleCount :: Lens' SignalInformation (Maybe Natural)
signalInformation_maxSampleCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignalInformation' {Maybe Natural
maxSampleCount :: Maybe Natural
$sel:maxSampleCount:SignalInformation' :: SignalInformation -> Maybe Natural
maxSampleCount} -> Maybe Natural
maxSampleCount) (\s :: SignalInformation
s@SignalInformation' {} Maybe Natural
a -> SignalInformation
s {$sel:maxSampleCount:SignalInformation' :: Maybe Natural
maxSampleCount = Maybe Natural
a} :: SignalInformation)

-- | The minimum duration of time (in milliseconds) between two triggering
-- events to collect data.
--
-- If a signal changes often, you might want to collect data at a slower
-- rate.
signalInformation_minimumSamplingIntervalMs :: Lens.Lens' SignalInformation (Prelude.Maybe Prelude.Natural)
signalInformation_minimumSamplingIntervalMs :: Lens' SignalInformation (Maybe Natural)
signalInformation_minimumSamplingIntervalMs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignalInformation' {Maybe Natural
minimumSamplingIntervalMs :: Maybe Natural
$sel:minimumSamplingIntervalMs:SignalInformation' :: SignalInformation -> Maybe Natural
minimumSamplingIntervalMs} -> Maybe Natural
minimumSamplingIntervalMs) (\s :: SignalInformation
s@SignalInformation' {} Maybe Natural
a -> SignalInformation
s {$sel:minimumSamplingIntervalMs:SignalInformation' :: Maybe Natural
minimumSamplingIntervalMs = Maybe Natural
a} :: SignalInformation)

-- | The name of the signal.
signalInformation_name :: Lens.Lens' SignalInformation Prelude.Text
signalInformation_name :: Lens' SignalInformation Text
signalInformation_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignalInformation' {Text
name :: Text
$sel:name:SignalInformation' :: SignalInformation -> Text
name} -> Text
name) (\s :: SignalInformation
s@SignalInformation' {} Text
a -> SignalInformation
s {$sel:name:SignalInformation' :: Text
name = Text
a} :: SignalInformation)

instance Data.FromJSON SignalInformation where
  parseJSON :: Value -> Parser SignalInformation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SignalInformation"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> Text -> SignalInformation
SignalInformation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"maxSampleCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"minimumSamplingIntervalMs")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"name")
      )

instance Prelude.Hashable SignalInformation where
  hashWithSalt :: Int -> SignalInformation -> Int
hashWithSalt Int
_salt SignalInformation' {Maybe Natural
Text
name :: Text
minimumSamplingIntervalMs :: Maybe Natural
maxSampleCount :: Maybe Natural
$sel:name:SignalInformation' :: SignalInformation -> Text
$sel:minimumSamplingIntervalMs:SignalInformation' :: SignalInformation -> Maybe Natural
$sel:maxSampleCount:SignalInformation' :: SignalInformation -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxSampleCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
minimumSamplingIntervalMs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData SignalInformation where
  rnf :: SignalInformation -> ()
rnf SignalInformation' {Maybe Natural
Text
name :: Text
minimumSamplingIntervalMs :: Maybe Natural
maxSampleCount :: Maybe Natural
$sel:name:SignalInformation' :: SignalInformation -> Text
$sel:minimumSamplingIntervalMs:SignalInformation' :: SignalInformation -> Maybe Natural
$sel:maxSampleCount:SignalInformation' :: SignalInformation -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxSampleCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
minimumSamplingIntervalMs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToJSON SignalInformation where
  toJSON :: SignalInformation -> Value
toJSON SignalInformation' {Maybe Natural
Text
name :: Text
minimumSamplingIntervalMs :: Maybe Natural
maxSampleCount :: Maybe Natural
$sel:name:SignalInformation' :: SignalInformation -> Text
$sel:minimumSamplingIntervalMs:SignalInformation' :: SignalInformation -> Maybe Natural
$sel:maxSampleCount:SignalInformation' :: SignalInformation -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxSampleCount" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxSampleCount,
            (Key
"minimumSamplingIntervalMs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
minimumSamplingIntervalMs,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )