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

import qualified Amazonka.Core as Core
import Amazonka.IoT1ClickDevices.Types.Attributes
import qualified Amazonka.Lens as Lens
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
(Device -> Device -> Bool)
-> (Device -> Device -> Bool) -> Eq Device
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]
(Int -> ReadS Device)
-> ReadS [Device]
-> ReadPrec Device
-> ReadPrec [Device]
-> Read 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
(Int -> Device -> ShowS)
-> (Device -> String) -> ([Device] -> ShowS) -> Show Device
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. Device -> Rep Device x)
-> (forall x. Rep Device x -> Device) -> Generic Device
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' :: Maybe Attributes -> Maybe Text -> Maybe Text -> Device
Device'
    { $sel:attributes:Device' :: Maybe Attributes
attributes = Maybe Attributes
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceId:Device' :: Maybe Text
deviceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Device' :: Maybe Text
type' = Maybe Text
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 :: (Maybe Attributes -> f (Maybe Attributes)) -> Device -> f Device
device_attributes = (Device -> Maybe Attributes)
-> (Device -> Maybe Attributes -> Device)
-> Lens Device Device (Maybe Attributes) (Maybe 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 :: (Maybe Text -> f (Maybe Text)) -> Device -> f Device
device_deviceId = (Device -> Maybe Text)
-> (Device -> Maybe Text -> Device)
-> Lens Device Device (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> Device -> f Device
device_type = (Device -> Maybe Text)
-> (Device -> Maybe Text -> Device)
-> Lens Device Device (Maybe Text) (Maybe Text)
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 Core.FromJSON Device where
  parseJSON :: Value -> Parser Device
parseJSON =
    String -> (Object -> Parser Device) -> Value -> Parser Device
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Device"
      ( \Object
x ->
          Maybe Attributes -> Maybe Text -> Maybe Text -> Device
Device'
            (Maybe Attributes -> Maybe Text -> Maybe Text -> Device)
-> Parser (Maybe Attributes)
-> Parser (Maybe Text -> Maybe Text -> Device)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Attributes)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributes")
            Parser (Maybe Text -> Maybe Text -> Device)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Device)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"deviceId")
            Parser (Maybe Text -> Device)
-> Parser (Maybe Text) -> Parser Device
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
      )

instance Prelude.Hashable Device

instance Prelude.NFData Device