{-# 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.DeviceDescription
-- 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.DeviceDescription 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

-- | /See:/ 'newDeviceDescription' smart constructor.
data DeviceDescription = DeviceDescription'
  { -- | The ARN of the device.
    DeviceDescription -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | An array of zero or more elements of DeviceAttribute objects providing
    -- user specified device attributes.
    DeviceDescription -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The unique identifier of the device.
    DeviceDescription -> Maybe Text
deviceId :: Prelude.Maybe Prelude.Text,
    -- | A Boolean value indicating whether or not the device is enabled.
    DeviceDescription -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | A value between 0 and 1 inclusive, representing the fraction of life
    -- remaining for the device.
    DeviceDescription -> Maybe Double
remainingLife :: Prelude.Maybe Prelude.Double,
    -- | The tags currently associated with the AWS IoT 1-Click device.
    DeviceDescription -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The type of the device, such as \"button\".
    DeviceDescription -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (DeviceDescription -> DeviceDescription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeviceDescription -> DeviceDescription -> Bool
$c/= :: DeviceDescription -> DeviceDescription -> Bool
== :: DeviceDescription -> DeviceDescription -> Bool
$c== :: DeviceDescription -> DeviceDescription -> Bool
Prelude.Eq, ReadPrec [DeviceDescription]
ReadPrec DeviceDescription
Int -> ReadS DeviceDescription
ReadS [DeviceDescription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeviceDescription]
$creadListPrec :: ReadPrec [DeviceDescription]
readPrec :: ReadPrec DeviceDescription
$creadPrec :: ReadPrec DeviceDescription
readList :: ReadS [DeviceDescription]
$creadList :: ReadS [DeviceDescription]
readsPrec :: Int -> ReadS DeviceDescription
$creadsPrec :: Int -> ReadS DeviceDescription
Prelude.Read, Int -> DeviceDescription -> ShowS
[DeviceDescription] -> ShowS
DeviceDescription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeviceDescription] -> ShowS
$cshowList :: [DeviceDescription] -> ShowS
show :: DeviceDescription -> String
$cshow :: DeviceDescription -> String
showsPrec :: Int -> DeviceDescription -> ShowS
$cshowsPrec :: Int -> DeviceDescription -> ShowS
Prelude.Show, forall x. Rep DeviceDescription x -> DeviceDescription
forall x. DeviceDescription -> Rep DeviceDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeviceDescription x -> DeviceDescription
$cfrom :: forall x. DeviceDescription -> Rep DeviceDescription x
Prelude.Generic)

-- |
-- Create a value of 'DeviceDescription' 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:
--
-- 'arn', 'deviceDescription_arn' - The ARN of the device.
--
-- 'attributes', 'deviceDescription_attributes' - An array of zero or more elements of DeviceAttribute objects providing
-- user specified device attributes.
--
-- 'deviceId', 'deviceDescription_deviceId' - The unique identifier of the device.
--
-- 'enabled', 'deviceDescription_enabled' - A Boolean value indicating whether or not the device is enabled.
--
-- 'remainingLife', 'deviceDescription_remainingLife' - A value between 0 and 1 inclusive, representing the fraction of life
-- remaining for the device.
--
-- 'tags', 'deviceDescription_tags' - The tags currently associated with the AWS IoT 1-Click device.
--
-- 'type'', 'deviceDescription_type' - The type of the device, such as \"button\".
newDeviceDescription ::
  DeviceDescription
newDeviceDescription :: DeviceDescription
newDeviceDescription =
  DeviceDescription'
    { $sel:arn:DeviceDescription' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:DeviceDescription' :: Maybe (HashMap Text Text)
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceId:DeviceDescription' :: Maybe Text
deviceId = forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:DeviceDescription' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:remainingLife:DeviceDescription' :: Maybe Double
remainingLife = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:DeviceDescription' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:type':DeviceDescription' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the device.
deviceDescription_arn :: Lens.Lens' DeviceDescription (Prelude.Maybe Prelude.Text)
deviceDescription_arn :: Lens' DeviceDescription (Maybe Text)
deviceDescription_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceDescription' {Maybe Text
arn :: Maybe Text
$sel:arn:DeviceDescription' :: DeviceDescription -> Maybe Text
arn} -> Maybe Text
arn) (\s :: DeviceDescription
s@DeviceDescription' {} Maybe Text
a -> DeviceDescription
s {$sel:arn:DeviceDescription' :: Maybe Text
arn = Maybe Text
a} :: DeviceDescription)

-- | An array of zero or more elements of DeviceAttribute objects providing
-- user specified device attributes.
deviceDescription_attributes :: Lens.Lens' DeviceDescription (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
deviceDescription_attributes :: Lens' DeviceDescription (Maybe (HashMap Text Text))
deviceDescription_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceDescription' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:DeviceDescription' :: DeviceDescription -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: DeviceDescription
s@DeviceDescription' {} Maybe (HashMap Text Text)
a -> DeviceDescription
s {$sel:attributes:DeviceDescription' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: DeviceDescription) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | A Boolean value indicating whether or not the device is enabled.
deviceDescription_enabled :: Lens.Lens' DeviceDescription (Prelude.Maybe Prelude.Bool)
deviceDescription_enabled :: Lens' DeviceDescription (Maybe Bool)
deviceDescription_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceDescription' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:DeviceDescription' :: DeviceDescription -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: DeviceDescription
s@DeviceDescription' {} Maybe Bool
a -> DeviceDescription
s {$sel:enabled:DeviceDescription' :: Maybe Bool
enabled = Maybe Bool
a} :: DeviceDescription)

-- | A value between 0 and 1 inclusive, representing the fraction of life
-- remaining for the device.
deviceDescription_remainingLife :: Lens.Lens' DeviceDescription (Prelude.Maybe Prelude.Double)
deviceDescription_remainingLife :: Lens' DeviceDescription (Maybe Double)
deviceDescription_remainingLife = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceDescription' {Maybe Double
remainingLife :: Maybe Double
$sel:remainingLife:DeviceDescription' :: DeviceDescription -> Maybe Double
remainingLife} -> Maybe Double
remainingLife) (\s :: DeviceDescription
s@DeviceDescription' {} Maybe Double
a -> DeviceDescription
s {$sel:remainingLife:DeviceDescription' :: Maybe Double
remainingLife = Maybe Double
a} :: DeviceDescription)

-- | The tags currently associated with the AWS IoT 1-Click device.
deviceDescription_tags :: Lens.Lens' DeviceDescription (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
deviceDescription_tags :: Lens' DeviceDescription (Maybe (HashMap Text Text))
deviceDescription_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceDescription' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:DeviceDescription' :: DeviceDescription -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: DeviceDescription
s@DeviceDescription' {} Maybe (HashMap Text Text)
a -> DeviceDescription
s {$sel:tags:DeviceDescription' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: DeviceDescription) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Data.FromJSON DeviceDescription where
  parseJSON :: Value -> Parser DeviceDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DeviceDescription"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Bool
-> Maybe Double
-> Maybe (HashMap Text Text)
-> Maybe Text
-> DeviceDescription
DeviceDescription'
            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
"arn")
            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
"attributes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"enabled")
            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
"remainingLife")
            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
"tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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 DeviceDescription where
  hashWithSalt :: Int -> DeviceDescription -> Int
hashWithSalt Int
_salt DeviceDescription' {Maybe Bool
Maybe Double
Maybe Text
Maybe (HashMap Text Text)
type' :: Maybe Text
tags :: Maybe (HashMap Text Text)
remainingLife :: Maybe Double
enabled :: Maybe Bool
deviceId :: Maybe Text
attributes :: Maybe (HashMap Text Text)
arn :: Maybe Text
$sel:type':DeviceDescription' :: DeviceDescription -> Maybe Text
$sel:tags:DeviceDescription' :: DeviceDescription -> Maybe (HashMap Text Text)
$sel:remainingLife:DeviceDescription' :: DeviceDescription -> Maybe Double
$sel:enabled:DeviceDescription' :: DeviceDescription -> Maybe Bool
$sel:deviceId:DeviceDescription' :: DeviceDescription -> Maybe Text
$sel:attributes:DeviceDescription' :: DeviceDescription -> Maybe (HashMap Text Text)
$sel:arn:DeviceDescription' :: DeviceDescription -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deviceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
remainingLife
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance Prelude.NFData DeviceDescription where
  rnf :: DeviceDescription -> ()
rnf DeviceDescription' {Maybe Bool
Maybe Double
Maybe Text
Maybe (HashMap Text Text)
type' :: Maybe Text
tags :: Maybe (HashMap Text Text)
remainingLife :: Maybe Double
enabled :: Maybe Bool
deviceId :: Maybe Text
attributes :: Maybe (HashMap Text Text)
arn :: Maybe Text
$sel:type':DeviceDescription' :: DeviceDescription -> Maybe Text
$sel:tags:DeviceDescription' :: DeviceDescription -> Maybe (HashMap Text Text)
$sel:remainingLife:DeviceDescription' :: DeviceDescription -> Maybe Double
$sel:enabled:DeviceDescription' :: DeviceDescription -> Maybe Bool
$sel:deviceId:DeviceDescription' :: DeviceDescription -> Maybe Text
$sel:attributes:DeviceDescription' :: DeviceDescription -> Maybe (HashMap Text Text)
$sel:arn:DeviceDescription' :: DeviceDescription -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
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 Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
remainingLife
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'