{-# 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.Greengrass.Types.TelemetryConfiguration
-- 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.Greengrass.Types.TelemetryConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.Types.ConfigurationSyncStatus
import Amazonka.Greengrass.Types.Telemetry
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration settings for running telemetry.
--
-- /See:/ 'newTelemetryConfiguration' smart constructor.
data TelemetryConfiguration = TelemetryConfiguration'
  { -- | Synchronization status of the device reported configuration with the
    -- desired configuration.
    TelemetryConfiguration -> Maybe ConfigurationSyncStatus
configurationSyncStatus :: Prelude.Maybe ConfigurationSyncStatus,
    -- | Configure telemetry to be on or off.
    TelemetryConfiguration -> Telemetry
telemetry :: Telemetry
  }
  deriving (TelemetryConfiguration -> TelemetryConfiguration -> Bool
(TelemetryConfiguration -> TelemetryConfiguration -> Bool)
-> (TelemetryConfiguration -> TelemetryConfiguration -> Bool)
-> Eq TelemetryConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TelemetryConfiguration -> TelemetryConfiguration -> Bool
$c/= :: TelemetryConfiguration -> TelemetryConfiguration -> Bool
== :: TelemetryConfiguration -> TelemetryConfiguration -> Bool
$c== :: TelemetryConfiguration -> TelemetryConfiguration -> Bool
Prelude.Eq, ReadPrec [TelemetryConfiguration]
ReadPrec TelemetryConfiguration
Int -> ReadS TelemetryConfiguration
ReadS [TelemetryConfiguration]
(Int -> ReadS TelemetryConfiguration)
-> ReadS [TelemetryConfiguration]
-> ReadPrec TelemetryConfiguration
-> ReadPrec [TelemetryConfiguration]
-> Read TelemetryConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TelemetryConfiguration]
$creadListPrec :: ReadPrec [TelemetryConfiguration]
readPrec :: ReadPrec TelemetryConfiguration
$creadPrec :: ReadPrec TelemetryConfiguration
readList :: ReadS [TelemetryConfiguration]
$creadList :: ReadS [TelemetryConfiguration]
readsPrec :: Int -> ReadS TelemetryConfiguration
$creadsPrec :: Int -> ReadS TelemetryConfiguration
Prelude.Read, Int -> TelemetryConfiguration -> ShowS
[TelemetryConfiguration] -> ShowS
TelemetryConfiguration -> String
(Int -> TelemetryConfiguration -> ShowS)
-> (TelemetryConfiguration -> String)
-> ([TelemetryConfiguration] -> ShowS)
-> Show TelemetryConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TelemetryConfiguration] -> ShowS
$cshowList :: [TelemetryConfiguration] -> ShowS
show :: TelemetryConfiguration -> String
$cshow :: TelemetryConfiguration -> String
showsPrec :: Int -> TelemetryConfiguration -> ShowS
$cshowsPrec :: Int -> TelemetryConfiguration -> ShowS
Prelude.Show, (forall x. TelemetryConfiguration -> Rep TelemetryConfiguration x)
-> (forall x.
    Rep TelemetryConfiguration x -> TelemetryConfiguration)
-> Generic TelemetryConfiguration
forall x. Rep TelemetryConfiguration x -> TelemetryConfiguration
forall x. TelemetryConfiguration -> Rep TelemetryConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TelemetryConfiguration x -> TelemetryConfiguration
$cfrom :: forall x. TelemetryConfiguration -> Rep TelemetryConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'TelemetryConfiguration' 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:
--
-- 'configurationSyncStatus', 'telemetryConfiguration_configurationSyncStatus' - Synchronization status of the device reported configuration with the
-- desired configuration.
--
-- 'telemetry', 'telemetryConfiguration_telemetry' - Configure telemetry to be on or off.
newTelemetryConfiguration ::
  -- | 'telemetry'
  Telemetry ->
  TelemetryConfiguration
newTelemetryConfiguration :: Telemetry -> TelemetryConfiguration
newTelemetryConfiguration Telemetry
pTelemetry_ =
  TelemetryConfiguration' :: Maybe ConfigurationSyncStatus
-> Telemetry -> TelemetryConfiguration
TelemetryConfiguration'
    { $sel:configurationSyncStatus:TelemetryConfiguration' :: Maybe ConfigurationSyncStatus
configurationSyncStatus =
        Maybe ConfigurationSyncStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:telemetry:TelemetryConfiguration' :: Telemetry
telemetry = Telemetry
pTelemetry_
    }

-- | Synchronization status of the device reported configuration with the
-- desired configuration.
telemetryConfiguration_configurationSyncStatus :: Lens.Lens' TelemetryConfiguration (Prelude.Maybe ConfigurationSyncStatus)
telemetryConfiguration_configurationSyncStatus :: (Maybe ConfigurationSyncStatus
 -> f (Maybe ConfigurationSyncStatus))
-> TelemetryConfiguration -> f TelemetryConfiguration
telemetryConfiguration_configurationSyncStatus = (TelemetryConfiguration -> Maybe ConfigurationSyncStatus)
-> (TelemetryConfiguration
    -> Maybe ConfigurationSyncStatus -> TelemetryConfiguration)
-> Lens
     TelemetryConfiguration
     TelemetryConfiguration
     (Maybe ConfigurationSyncStatus)
     (Maybe ConfigurationSyncStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelemetryConfiguration' {Maybe ConfigurationSyncStatus
configurationSyncStatus :: Maybe ConfigurationSyncStatus
$sel:configurationSyncStatus:TelemetryConfiguration' :: TelemetryConfiguration -> Maybe ConfigurationSyncStatus
configurationSyncStatus} -> Maybe ConfigurationSyncStatus
configurationSyncStatus) (\s :: TelemetryConfiguration
s@TelemetryConfiguration' {} Maybe ConfigurationSyncStatus
a -> TelemetryConfiguration
s {$sel:configurationSyncStatus:TelemetryConfiguration' :: Maybe ConfigurationSyncStatus
configurationSyncStatus = Maybe ConfigurationSyncStatus
a} :: TelemetryConfiguration)

-- | Configure telemetry to be on or off.
telemetryConfiguration_telemetry :: Lens.Lens' TelemetryConfiguration Telemetry
telemetryConfiguration_telemetry :: (Telemetry -> f Telemetry)
-> TelemetryConfiguration -> f TelemetryConfiguration
telemetryConfiguration_telemetry = (TelemetryConfiguration -> Telemetry)
-> (TelemetryConfiguration -> Telemetry -> TelemetryConfiguration)
-> Lens
     TelemetryConfiguration TelemetryConfiguration Telemetry Telemetry
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TelemetryConfiguration' {Telemetry
telemetry :: Telemetry
$sel:telemetry:TelemetryConfiguration' :: TelemetryConfiguration -> Telemetry
telemetry} -> Telemetry
telemetry) (\s :: TelemetryConfiguration
s@TelemetryConfiguration' {} Telemetry
a -> TelemetryConfiguration
s {$sel:telemetry:TelemetryConfiguration' :: Telemetry
telemetry = Telemetry
a} :: TelemetryConfiguration)

instance Core.FromJSON TelemetryConfiguration where
  parseJSON :: Value -> Parser TelemetryConfiguration
parseJSON =
    String
-> (Object -> Parser TelemetryConfiguration)
-> Value
-> Parser TelemetryConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TelemetryConfiguration"
      ( \Object
x ->
          Maybe ConfigurationSyncStatus
-> Telemetry -> TelemetryConfiguration
TelemetryConfiguration'
            (Maybe ConfigurationSyncStatus
 -> Telemetry -> TelemetryConfiguration)
-> Parser (Maybe ConfigurationSyncStatus)
-> Parser (Telemetry -> TelemetryConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ConfigurationSyncStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConfigurationSyncStatus")
            Parser (Telemetry -> TelemetryConfiguration)
-> Parser Telemetry -> Parser TelemetryConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Telemetry
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Telemetry")
      )

instance Prelude.Hashable TelemetryConfiguration

instance Prelude.NFData TelemetryConfiguration