{-# 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.IoTWireless.Types.SidewalkDeviceMetadata
-- 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.IoTWireless.Types.SidewalkDeviceMetadata where

import qualified Amazonka.Core as Core
import Amazonka.IoTWireless.Types.BatteryLevel
import Amazonka.IoTWireless.Types.DeviceState
import Amazonka.IoTWireless.Types.Event
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | MetaData for Sidewalk device.
--
-- /See:/ 'newSidewalkDeviceMetadata' smart constructor.
data SidewalkDeviceMetadata = SidewalkDeviceMetadata'
  { -- | Sidewalk device status notification.
    SidewalkDeviceMetadata -> Maybe Event
event :: Prelude.Maybe Event,
    -- | Device state defines the device status of sidewalk device.
    SidewalkDeviceMetadata -> Maybe DeviceState
deviceState :: Prelude.Maybe DeviceState,
    -- | Sidewalk device battery level.
    SidewalkDeviceMetadata -> Maybe BatteryLevel
batteryLevel :: Prelude.Maybe BatteryLevel,
    -- | The RSSI value.
    SidewalkDeviceMetadata -> Maybe Int
rssi :: Prelude.Maybe Prelude.Int
  }
  deriving (SidewalkDeviceMetadata -> SidewalkDeviceMetadata -> Bool
(SidewalkDeviceMetadata -> SidewalkDeviceMetadata -> Bool)
-> (SidewalkDeviceMetadata -> SidewalkDeviceMetadata -> Bool)
-> Eq SidewalkDeviceMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SidewalkDeviceMetadata -> SidewalkDeviceMetadata -> Bool
$c/= :: SidewalkDeviceMetadata -> SidewalkDeviceMetadata -> Bool
== :: SidewalkDeviceMetadata -> SidewalkDeviceMetadata -> Bool
$c== :: SidewalkDeviceMetadata -> SidewalkDeviceMetadata -> Bool
Prelude.Eq, ReadPrec [SidewalkDeviceMetadata]
ReadPrec SidewalkDeviceMetadata
Int -> ReadS SidewalkDeviceMetadata
ReadS [SidewalkDeviceMetadata]
(Int -> ReadS SidewalkDeviceMetadata)
-> ReadS [SidewalkDeviceMetadata]
-> ReadPrec SidewalkDeviceMetadata
-> ReadPrec [SidewalkDeviceMetadata]
-> Read SidewalkDeviceMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SidewalkDeviceMetadata]
$creadListPrec :: ReadPrec [SidewalkDeviceMetadata]
readPrec :: ReadPrec SidewalkDeviceMetadata
$creadPrec :: ReadPrec SidewalkDeviceMetadata
readList :: ReadS [SidewalkDeviceMetadata]
$creadList :: ReadS [SidewalkDeviceMetadata]
readsPrec :: Int -> ReadS SidewalkDeviceMetadata
$creadsPrec :: Int -> ReadS SidewalkDeviceMetadata
Prelude.Read, Int -> SidewalkDeviceMetadata -> ShowS
[SidewalkDeviceMetadata] -> ShowS
SidewalkDeviceMetadata -> String
(Int -> SidewalkDeviceMetadata -> ShowS)
-> (SidewalkDeviceMetadata -> String)
-> ([SidewalkDeviceMetadata] -> ShowS)
-> Show SidewalkDeviceMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SidewalkDeviceMetadata] -> ShowS
$cshowList :: [SidewalkDeviceMetadata] -> ShowS
show :: SidewalkDeviceMetadata -> String
$cshow :: SidewalkDeviceMetadata -> String
showsPrec :: Int -> SidewalkDeviceMetadata -> ShowS
$cshowsPrec :: Int -> SidewalkDeviceMetadata -> ShowS
Prelude.Show, (forall x. SidewalkDeviceMetadata -> Rep SidewalkDeviceMetadata x)
-> (forall x.
    Rep SidewalkDeviceMetadata x -> SidewalkDeviceMetadata)
-> Generic SidewalkDeviceMetadata
forall x. Rep SidewalkDeviceMetadata x -> SidewalkDeviceMetadata
forall x. SidewalkDeviceMetadata -> Rep SidewalkDeviceMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SidewalkDeviceMetadata x -> SidewalkDeviceMetadata
$cfrom :: forall x. SidewalkDeviceMetadata -> Rep SidewalkDeviceMetadata x
Prelude.Generic)

-- |
-- Create a value of 'SidewalkDeviceMetadata' 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:
--
-- 'event', 'sidewalkDeviceMetadata_event' - Sidewalk device status notification.
--
-- 'deviceState', 'sidewalkDeviceMetadata_deviceState' - Device state defines the device status of sidewalk device.
--
-- 'batteryLevel', 'sidewalkDeviceMetadata_batteryLevel' - Sidewalk device battery level.
--
-- 'rssi', 'sidewalkDeviceMetadata_rssi' - The RSSI value.
newSidewalkDeviceMetadata ::
  SidewalkDeviceMetadata
newSidewalkDeviceMetadata :: SidewalkDeviceMetadata
newSidewalkDeviceMetadata =
  SidewalkDeviceMetadata' :: Maybe Event
-> Maybe DeviceState
-> Maybe BatteryLevel
-> Maybe Int
-> SidewalkDeviceMetadata
SidewalkDeviceMetadata'
    { $sel:event:SidewalkDeviceMetadata' :: Maybe Event
event = Maybe Event
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceState:SidewalkDeviceMetadata' :: Maybe DeviceState
deviceState = Maybe DeviceState
forall a. Maybe a
Prelude.Nothing,
      $sel:batteryLevel:SidewalkDeviceMetadata' :: Maybe BatteryLevel
batteryLevel = Maybe BatteryLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:rssi:SidewalkDeviceMetadata' :: Maybe Int
rssi = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Sidewalk device status notification.
sidewalkDeviceMetadata_event :: Lens.Lens' SidewalkDeviceMetadata (Prelude.Maybe Event)
sidewalkDeviceMetadata_event :: (Maybe Event -> f (Maybe Event))
-> SidewalkDeviceMetadata -> f SidewalkDeviceMetadata
sidewalkDeviceMetadata_event = (SidewalkDeviceMetadata -> Maybe Event)
-> (SidewalkDeviceMetadata
    -> Maybe Event -> SidewalkDeviceMetadata)
-> Lens
     SidewalkDeviceMetadata
     SidewalkDeviceMetadata
     (Maybe Event)
     (Maybe Event)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SidewalkDeviceMetadata' {Maybe Event
event :: Maybe Event
$sel:event:SidewalkDeviceMetadata' :: SidewalkDeviceMetadata -> Maybe Event
event} -> Maybe Event
event) (\s :: SidewalkDeviceMetadata
s@SidewalkDeviceMetadata' {} Maybe Event
a -> SidewalkDeviceMetadata
s {$sel:event:SidewalkDeviceMetadata' :: Maybe Event
event = Maybe Event
a} :: SidewalkDeviceMetadata)

-- | Device state defines the device status of sidewalk device.
sidewalkDeviceMetadata_deviceState :: Lens.Lens' SidewalkDeviceMetadata (Prelude.Maybe DeviceState)
sidewalkDeviceMetadata_deviceState :: (Maybe DeviceState -> f (Maybe DeviceState))
-> SidewalkDeviceMetadata -> f SidewalkDeviceMetadata
sidewalkDeviceMetadata_deviceState = (SidewalkDeviceMetadata -> Maybe DeviceState)
-> (SidewalkDeviceMetadata
    -> Maybe DeviceState -> SidewalkDeviceMetadata)
-> Lens
     SidewalkDeviceMetadata
     SidewalkDeviceMetadata
     (Maybe DeviceState)
     (Maybe DeviceState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SidewalkDeviceMetadata' {Maybe DeviceState
deviceState :: Maybe DeviceState
$sel:deviceState:SidewalkDeviceMetadata' :: SidewalkDeviceMetadata -> Maybe DeviceState
deviceState} -> Maybe DeviceState
deviceState) (\s :: SidewalkDeviceMetadata
s@SidewalkDeviceMetadata' {} Maybe DeviceState
a -> SidewalkDeviceMetadata
s {$sel:deviceState:SidewalkDeviceMetadata' :: Maybe DeviceState
deviceState = Maybe DeviceState
a} :: SidewalkDeviceMetadata)

-- | Sidewalk device battery level.
sidewalkDeviceMetadata_batteryLevel :: Lens.Lens' SidewalkDeviceMetadata (Prelude.Maybe BatteryLevel)
sidewalkDeviceMetadata_batteryLevel :: (Maybe BatteryLevel -> f (Maybe BatteryLevel))
-> SidewalkDeviceMetadata -> f SidewalkDeviceMetadata
sidewalkDeviceMetadata_batteryLevel = (SidewalkDeviceMetadata -> Maybe BatteryLevel)
-> (SidewalkDeviceMetadata
    -> Maybe BatteryLevel -> SidewalkDeviceMetadata)
-> Lens
     SidewalkDeviceMetadata
     SidewalkDeviceMetadata
     (Maybe BatteryLevel)
     (Maybe BatteryLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SidewalkDeviceMetadata' {Maybe BatteryLevel
batteryLevel :: Maybe BatteryLevel
$sel:batteryLevel:SidewalkDeviceMetadata' :: SidewalkDeviceMetadata -> Maybe BatteryLevel
batteryLevel} -> Maybe BatteryLevel
batteryLevel) (\s :: SidewalkDeviceMetadata
s@SidewalkDeviceMetadata' {} Maybe BatteryLevel
a -> SidewalkDeviceMetadata
s {$sel:batteryLevel:SidewalkDeviceMetadata' :: Maybe BatteryLevel
batteryLevel = Maybe BatteryLevel
a} :: SidewalkDeviceMetadata)

-- | The RSSI value.
sidewalkDeviceMetadata_rssi :: Lens.Lens' SidewalkDeviceMetadata (Prelude.Maybe Prelude.Int)
sidewalkDeviceMetadata_rssi :: (Maybe Int -> f (Maybe Int))
-> SidewalkDeviceMetadata -> f SidewalkDeviceMetadata
sidewalkDeviceMetadata_rssi = (SidewalkDeviceMetadata -> Maybe Int)
-> (SidewalkDeviceMetadata -> Maybe Int -> SidewalkDeviceMetadata)
-> Lens
     SidewalkDeviceMetadata
     SidewalkDeviceMetadata
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SidewalkDeviceMetadata' {Maybe Int
rssi :: Maybe Int
$sel:rssi:SidewalkDeviceMetadata' :: SidewalkDeviceMetadata -> Maybe Int
rssi} -> Maybe Int
rssi) (\s :: SidewalkDeviceMetadata
s@SidewalkDeviceMetadata' {} Maybe Int
a -> SidewalkDeviceMetadata
s {$sel:rssi:SidewalkDeviceMetadata' :: Maybe Int
rssi = Maybe Int
a} :: SidewalkDeviceMetadata)

instance Core.FromJSON SidewalkDeviceMetadata where
  parseJSON :: Value -> Parser SidewalkDeviceMetadata
parseJSON =
    String
-> (Object -> Parser SidewalkDeviceMetadata)
-> Value
-> Parser SidewalkDeviceMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SidewalkDeviceMetadata"
      ( \Object
x ->
          Maybe Event
-> Maybe DeviceState
-> Maybe BatteryLevel
-> Maybe Int
-> SidewalkDeviceMetadata
SidewalkDeviceMetadata'
            (Maybe Event
 -> Maybe DeviceState
 -> Maybe BatteryLevel
 -> Maybe Int
 -> SidewalkDeviceMetadata)
-> Parser (Maybe Event)
-> Parser
     (Maybe DeviceState
      -> Maybe BatteryLevel -> Maybe Int -> SidewalkDeviceMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Event)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Event")
            Parser
  (Maybe DeviceState
   -> Maybe BatteryLevel -> Maybe Int -> SidewalkDeviceMetadata)
-> Parser (Maybe DeviceState)
-> Parser
     (Maybe BatteryLevel -> Maybe Int -> SidewalkDeviceMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DeviceState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeviceState")
            Parser (Maybe BatteryLevel -> Maybe Int -> SidewalkDeviceMetadata)
-> Parser (Maybe BatteryLevel)
-> Parser (Maybe Int -> SidewalkDeviceMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BatteryLevel)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BatteryLevel")
            Parser (Maybe Int -> SidewalkDeviceMetadata)
-> Parser (Maybe Int) -> Parser SidewalkDeviceMetadata
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Rssi")
      )

instance Prelude.Hashable SidewalkDeviceMetadata

instance Prelude.NFData SidewalkDeviceMetadata