{-# 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.IoT1ClickDevices.Types.Device
-- 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.IoT1ClickDevices.Types.Device where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT1ClickDevices.Types.Attributes
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newDevice' smart constructor.
data Device = Device'
  { -- | The user specified attributes associated with the device for an event.
    Device -> Maybe Attributes
attributes :: Prelude.Maybe Attributes,
    -- | The unique identifier of the device.
    Device -> Maybe Text
deviceId :: Prelude.Maybe Prelude.Text,
    -- | The device type, such as \"button\".
    Device -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (Device -> Device -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Device -> Device -> Bool
$c/= :: Device -> Device -> Bool
== :: Device -> Device -> Bool
$c== :: Device -> Device -> Bool
Prelude.Eq, ReadPrec [Device]
ReadPrec Device
Int -> ReadS Device
ReadS [Device]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Device]
$creadListPrec :: ReadPrec [Device]
readPrec :: ReadPrec Device
$creadPrec :: ReadPrec Device
readList :: ReadS [Device]
$creadList :: ReadS [Device]
readsPrec :: Int -> ReadS Device
$creadsPrec :: Int -> ReadS Device
Prelude.Read, Int -> Device -> ShowS
[Device] -> ShowS
Device -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Device] -> ShowS
$cshowList :: [Device] -> ShowS
show :: Device -> String
$cshow :: Device -> String
showsPrec :: Int -> Device -> ShowS
$cshowsPrec :: Int -> Device -> ShowS
Prelude.Show, forall x. Rep Device x -> Device
forall x. Device -> Rep Device x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Device x -> Device
$cfrom :: forall x. Device -> Rep Device x
Prelude.Generic)

-- |
-- Create a value of 'Device' 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:
--
-- 'attributes', 'device_attributes' - The user specified attributes associated with the device for an event.
--
-- 'deviceId', 'device_deviceId' - The unique identifier of the device.
--
-- 'type'', 'device_type' - The device type, such as \"button\".
newDevice ::
  Device
newDevice :: Device
newDevice =
  Device'
    { $sel:attributes:Device' :: Maybe Attributes
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceId:Device' :: Maybe Text
deviceId = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Device' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The user specified attributes associated with the device for an event.
device_attributes :: Lens.Lens' Device (Prelude.Maybe Attributes)
device_attributes :: Lens' Device (Maybe Attributes)
device_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe Attributes
attributes :: Maybe Attributes
$sel:attributes:Device' :: Device -> Maybe Attributes
attributes} -> Maybe Attributes
attributes) (\s :: Device
s@Device' {} Maybe Attributes
a -> Device
s {$sel:attributes:Device' :: Maybe Attributes
attributes = Maybe Attributes
a} :: Device)

-- | The unique identifier of the device.
device_deviceId :: Lens.Lens' Device (Prelude.Maybe Prelude.Text)
device_deviceId :: Lens' Device (Maybe Text)
device_deviceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe Text
deviceId :: Maybe Text
$sel:deviceId:Device' :: Device -> Maybe Text
deviceId} -> Maybe Text
deviceId) (\s :: Device
s@Device' {} Maybe Text
a -> Device
s {$sel:deviceId:Device' :: Maybe Text
deviceId = Maybe Text
a} :: Device)

-- | The device type, such as \"button\".
device_type :: Lens.Lens' Device (Prelude.Maybe Prelude.Text)
device_type :: Lens' Device (Maybe Text)
device_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe Text
type' :: Maybe Text
$sel:type':Device' :: Device -> Maybe Text
type'} -> Maybe Text
type') (\s :: Device
s@Device' {} Maybe Text
a -> Device
s {$sel:type':Device' :: Maybe Text
type' = Maybe Text
a} :: Device)

instance Data.FromJSON Device where
  parseJSON :: Value -> Parser Device
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Device"
      ( \Object
x ->
          Maybe Attributes -> Maybe Text -> Maybe Text -> Device
Device'
            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
"attributes")
            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
"deviceId")
            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
"type")
      )

instance Prelude.Hashable Device where
  hashWithSalt :: Int -> Device -> Int
hashWithSalt Int
_salt Device' {Maybe Text
Maybe Attributes
type' :: Maybe Text
deviceId :: Maybe Text
attributes :: Maybe Attributes
$sel:type':Device' :: Device -> Maybe Text
$sel:deviceId:Device' :: Device -> Maybe Text
$sel:attributes:Device' :: Device -> Maybe Attributes
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Attributes
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deviceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance Prelude.NFData Device where
  rnf :: Device -> ()
rnf Device' {Maybe Text
Maybe Attributes
type' :: Maybe Text
deviceId :: Maybe Text
attributes :: Maybe Attributes
$sel:type':Device' :: Device -> Maybe Text
$sel:deviceId:Device' :: Device -> Maybe Text
$sel:attributes:Device' :: Device -> Maybe Attributes
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Attributes
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deviceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'