{-# 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.TimeBasedCollectionScheme
-- 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.TimeBasedCollectionScheme 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 collection scheme that uses a time period to decide
-- how often to collect data.
--
-- /See:/ 'newTimeBasedCollectionScheme' smart constructor.
data TimeBasedCollectionScheme = TimeBasedCollectionScheme'
  { -- | The time period (in milliseconds) to decide how often to collect data.
    -- For example, if the time period is @60000@, the Edge Agent software
    -- collects data once every minute.
    TimeBasedCollectionScheme -> Natural
periodMs :: Prelude.Natural
  }
  deriving (TimeBasedCollectionScheme -> TimeBasedCollectionScheme -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeBasedCollectionScheme -> TimeBasedCollectionScheme -> Bool
$c/= :: TimeBasedCollectionScheme -> TimeBasedCollectionScheme -> Bool
== :: TimeBasedCollectionScheme -> TimeBasedCollectionScheme -> Bool
$c== :: TimeBasedCollectionScheme -> TimeBasedCollectionScheme -> Bool
Prelude.Eq, ReadPrec [TimeBasedCollectionScheme]
ReadPrec TimeBasedCollectionScheme
Int -> ReadS TimeBasedCollectionScheme
ReadS [TimeBasedCollectionScheme]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimeBasedCollectionScheme]
$creadListPrec :: ReadPrec [TimeBasedCollectionScheme]
readPrec :: ReadPrec TimeBasedCollectionScheme
$creadPrec :: ReadPrec TimeBasedCollectionScheme
readList :: ReadS [TimeBasedCollectionScheme]
$creadList :: ReadS [TimeBasedCollectionScheme]
readsPrec :: Int -> ReadS TimeBasedCollectionScheme
$creadsPrec :: Int -> ReadS TimeBasedCollectionScheme
Prelude.Read, Int -> TimeBasedCollectionScheme -> ShowS
[TimeBasedCollectionScheme] -> ShowS
TimeBasedCollectionScheme -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeBasedCollectionScheme] -> ShowS
$cshowList :: [TimeBasedCollectionScheme] -> ShowS
show :: TimeBasedCollectionScheme -> String
$cshow :: TimeBasedCollectionScheme -> String
showsPrec :: Int -> TimeBasedCollectionScheme -> ShowS
$cshowsPrec :: Int -> TimeBasedCollectionScheme -> ShowS
Prelude.Show, forall x.
Rep TimeBasedCollectionScheme x -> TimeBasedCollectionScheme
forall x.
TimeBasedCollectionScheme -> Rep TimeBasedCollectionScheme x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TimeBasedCollectionScheme x -> TimeBasedCollectionScheme
$cfrom :: forall x.
TimeBasedCollectionScheme -> Rep TimeBasedCollectionScheme x
Prelude.Generic)

-- |
-- Create a value of 'TimeBasedCollectionScheme' 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:
--
-- 'periodMs', 'timeBasedCollectionScheme_periodMs' - The time period (in milliseconds) to decide how often to collect data.
-- For example, if the time period is @60000@, the Edge Agent software
-- collects data once every minute.
newTimeBasedCollectionScheme ::
  -- | 'periodMs'
  Prelude.Natural ->
  TimeBasedCollectionScheme
newTimeBasedCollectionScheme :: Natural -> TimeBasedCollectionScheme
newTimeBasedCollectionScheme Natural
pPeriodMs_ =
  TimeBasedCollectionScheme' {$sel:periodMs:TimeBasedCollectionScheme' :: Natural
periodMs = Natural
pPeriodMs_}

-- | The time period (in milliseconds) to decide how often to collect data.
-- For example, if the time period is @60000@, the Edge Agent software
-- collects data once every minute.
timeBasedCollectionScheme_periodMs :: Lens.Lens' TimeBasedCollectionScheme Prelude.Natural
timeBasedCollectionScheme_periodMs :: Lens' TimeBasedCollectionScheme Natural
timeBasedCollectionScheme_periodMs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeBasedCollectionScheme' {Natural
periodMs :: Natural
$sel:periodMs:TimeBasedCollectionScheme' :: TimeBasedCollectionScheme -> Natural
periodMs} -> Natural
periodMs) (\s :: TimeBasedCollectionScheme
s@TimeBasedCollectionScheme' {} Natural
a -> TimeBasedCollectionScheme
s {$sel:periodMs:TimeBasedCollectionScheme' :: Natural
periodMs = Natural
a} :: TimeBasedCollectionScheme)

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

instance Prelude.Hashable TimeBasedCollectionScheme where
  hashWithSalt :: Int -> TimeBasedCollectionScheme -> Int
hashWithSalt Int
_salt TimeBasedCollectionScheme' {Natural
periodMs :: Natural
$sel:periodMs:TimeBasedCollectionScheme' :: TimeBasedCollectionScheme -> Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
periodMs

instance Prelude.NFData TimeBasedCollectionScheme where
  rnf :: TimeBasedCollectionScheme -> ()
rnf TimeBasedCollectionScheme' {Natural
periodMs :: Natural
$sel:periodMs:TimeBasedCollectionScheme' :: TimeBasedCollectionScheme -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
periodMs

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