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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newDeviceDescription' smart constructor.
data DeviceDescription = DeviceDescription'
  { -- | A value between 0 and 1 inclusive, representing the fraction of life
    -- remaining for the device.
    DeviceDescription -> Maybe Double
remainingLife :: Prelude.Maybe Prelude.Double,
    -- | A Boolean value indicating whether or not the device is enabled.
    DeviceDescription -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | 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,
    -- | The type of the device, such as \"button\".
    DeviceDescription -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | 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)
  }
  deriving (DeviceDescription -> DeviceDescription -> Bool
(DeviceDescription -> DeviceDescription -> Bool)
-> (DeviceDescription -> DeviceDescription -> Bool)
-> Eq DeviceDescription
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]
(Int -> ReadS DeviceDescription)
-> ReadS [DeviceDescription]
-> ReadPrec DeviceDescription
-> ReadPrec [DeviceDescription]
-> Read 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
(Int -> DeviceDescription -> ShowS)
-> (DeviceDescription -> String)
-> ([DeviceDescription] -> ShowS)
-> Show DeviceDescription
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. DeviceDescription -> Rep DeviceDescription x)
-> (forall x. Rep DeviceDescription x -> DeviceDescription)
-> Generic DeviceDescription
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:
--
-- 'remainingLife', 'deviceDescription_remainingLife' - A value between 0 and 1 inclusive, representing the fraction of life
-- remaining for the device.
--
-- 'enabled', 'deviceDescription_enabled' - A Boolean value indicating whether or not the device is enabled.
--
-- '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.
--
-- 'type'', 'deviceDescription_type' - The type of the device, such as \"button\".
--
-- 'tags', 'deviceDescription_tags' - The tags currently associated with the AWS IoT 1-Click device.
newDeviceDescription ::
  DeviceDescription
newDeviceDescription :: DeviceDescription
newDeviceDescription =
  DeviceDescription' :: Maybe Double
-> Maybe Bool
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> DeviceDescription
DeviceDescription'
    { $sel:remainingLife:DeviceDescription' :: Maybe Double
remainingLife = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:DeviceDescription' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:DeviceDescription' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:DeviceDescription' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceId:DeviceDescription' :: Maybe Text
deviceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':DeviceDescription' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:DeviceDescription' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Double -> f (Maybe Double))
-> DeviceDescription -> f DeviceDescription
deviceDescription_remainingLife = (DeviceDescription -> Maybe Double)
-> (DeviceDescription -> Maybe Double -> DeviceDescription)
-> Lens
     DeviceDescription DeviceDescription (Maybe Double) (Maybe Double)
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)

-- | A Boolean value indicating whether or not the device is enabled.
deviceDescription_enabled :: Lens.Lens' DeviceDescription (Prelude.Maybe Prelude.Bool)
deviceDescription_enabled :: (Maybe Bool -> f (Maybe Bool))
-> DeviceDescription -> f DeviceDescription
deviceDescription_enabled = (DeviceDescription -> Maybe Bool)
-> (DeviceDescription -> Maybe Bool -> DeviceDescription)
-> Lens
     DeviceDescription DeviceDescription (Maybe Bool) (Maybe Bool)
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)

-- | The ARN of the device.
deviceDescription_arn :: Lens.Lens' DeviceDescription (Prelude.Maybe Prelude.Text)
deviceDescription_arn :: (Maybe Text -> f (Maybe Text))
-> DeviceDescription -> f DeviceDescription
deviceDescription_arn = (DeviceDescription -> Maybe Text)
-> (DeviceDescription -> Maybe Text -> DeviceDescription)
-> Lens
     DeviceDescription DeviceDescription (Maybe Text) (Maybe Text)
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DeviceDescription -> f DeviceDescription
deviceDescription_attributes = (DeviceDescription -> Maybe (HashMap Text Text))
-> (DeviceDescription
    -> Maybe (HashMap Text Text) -> DeviceDescription)
-> Lens
     DeviceDescription
     DeviceDescription
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> DeviceDescription -> f DeviceDescription)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DeviceDescription
-> f DeviceDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
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 :: (Maybe Text -> f (Maybe Text))
-> DeviceDescription -> f DeviceDescription
deviceDescription_deviceId = (DeviceDescription -> Maybe Text)
-> (DeviceDescription -> Maybe Text -> DeviceDescription)
-> Lens
     DeviceDescription DeviceDescription (Maybe Text) (Maybe Text)
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)

-- | The type of the device, such as \"button\".
deviceDescription_type :: Lens.Lens' DeviceDescription (Prelude.Maybe Prelude.Text)
deviceDescription_type :: (Maybe Text -> f (Maybe Text))
-> DeviceDescription -> f DeviceDescription
deviceDescription_type = (DeviceDescription -> Maybe Text)
-> (DeviceDescription -> Maybe Text -> DeviceDescription)
-> Lens
     DeviceDescription DeviceDescription (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DeviceDescription -> f DeviceDescription
deviceDescription_tags = (DeviceDescription -> Maybe (HashMap Text Text))
-> (DeviceDescription
    -> Maybe (HashMap Text Text) -> DeviceDescription)
-> Lens
     DeviceDescription
     DeviceDescription
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> DeviceDescription -> f DeviceDescription)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DeviceDescription
-> f DeviceDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON DeviceDescription where
  parseJSON :: Value -> Parser DeviceDescription
parseJSON =
    String
-> (Object -> Parser DeviceDescription)
-> Value
-> Parser DeviceDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeviceDescription"
      ( \Object
x ->
          Maybe Double
-> Maybe Bool
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> DeviceDescription
DeviceDescription'
            (Maybe Double
 -> Maybe Bool
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> DeviceDescription)
-> Parser (Maybe Double)
-> Parser
     (Maybe Bool
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> DeviceDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"remainingLife")
            Parser
  (Maybe Bool
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> DeviceDescription)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> DeviceDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"enabled")
            Parser
  (Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> DeviceDescription)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe Text
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> DeviceDescription)
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
"arn")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe Text
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> DeviceDescription)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe (HashMap Text Text) -> DeviceDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributes" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe (HashMap Text Text) -> DeviceDescription)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe (HashMap Text Text) -> DeviceDescription)
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 -> Maybe (HashMap Text Text) -> DeviceDescription)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> DeviceDescription)
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")
            Parser (Maybe (HashMap Text Text) -> DeviceDescription)
-> Parser (Maybe (HashMap Text Text)) -> Parser DeviceDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tags" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable DeviceDescription

instance Prelude.NFData DeviceDescription