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

-- | Information of a particular device.
--
-- /See:/ 'newDevice' smart constructor.
data Device = Device'
  { -- | Description of the device.
    Device -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Amazon Web Services Internet of Things (IoT) object name.
    Device -> Maybe Text
iotThingName :: Prelude.Maybe Prelude.Text,
    -- | The name of the device.
    Device -> Text
deviceName :: 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:
--
-- 'description', 'device_description' - Description of the device.
--
-- 'iotThingName', 'device_iotThingName' - Amazon Web Services Internet of Things (IoT) object name.
--
-- 'deviceName', 'device_deviceName' - The name of the device.
newDevice ::
  -- | 'deviceName'
  Prelude.Text ->
  Device
newDevice :: Text -> Device
newDevice Text
pDeviceName_ =
  Device'
    { $sel:description:Device' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:iotThingName:Device' :: Maybe Text
iotThingName = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceName:Device' :: Text
deviceName = Text
pDeviceName_
    }

-- | Description of the device.
device_description :: Lens.Lens' Device (Prelude.Maybe Prelude.Text)
device_description :: Lens' Device (Maybe Text)
device_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe Text
description :: Maybe Text
$sel:description:Device' :: Device -> Maybe Text
description} -> Maybe Text
description) (\s :: Device
s@Device' {} Maybe Text
a -> Device
s {$sel:description:Device' :: Maybe Text
description = Maybe Text
a} :: Device)

-- | Amazon Web Services Internet of Things (IoT) object name.
device_iotThingName :: Lens.Lens' Device (Prelude.Maybe Prelude.Text)
device_iotThingName :: Lens' Device (Maybe Text)
device_iotThingName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe Text
iotThingName :: Maybe Text
$sel:iotThingName:Device' :: Device -> Maybe Text
iotThingName} -> Maybe Text
iotThingName) (\s :: Device
s@Device' {} Maybe Text
a -> Device
s {$sel:iotThingName:Device' :: Maybe Text
iotThingName = Maybe Text
a} :: Device)

-- | The name of the device.
device_deviceName :: Lens.Lens' Device Prelude.Text
device_deviceName :: Lens' Device Text
device_deviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Text
deviceName :: Text
$sel:deviceName:Device' :: Device -> Text
deviceName} -> Text
deviceName) (\s :: Device
s@Device' {} Text
a -> Device
s {$sel:deviceName:Device' :: Text
deviceName = Text
a} :: Device)

instance Prelude.Hashable Device where
  hashWithSalt :: Int -> Device -> Int
hashWithSalt Int
_salt Device' {Maybe Text
Text
deviceName :: Text
iotThingName :: Maybe Text
description :: Maybe Text
$sel:deviceName:Device' :: Device -> Text
$sel:iotThingName:Device' :: Device -> Maybe Text
$sel:description:Device' :: Device -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
iotThingName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deviceName

instance Prelude.NFData Device where
  rnf :: Device -> ()
rnf Device' {Maybe Text
Text
deviceName :: Text
iotThingName :: Maybe Text
description :: Maybe Text
$sel:deviceName:Device' :: Device -> Text
$sel:iotThingName:Device' :: Device -> Maybe Text
$sel:description:Device' :: Device -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iotThingName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
deviceName

instance Data.ToJSON Device where
  toJSON :: Device -> Value
toJSON Device' {Maybe Text
Text
deviceName :: Text
iotThingName :: Maybe Text
description :: Maybe Text
$sel:deviceName:Device' :: Device -> Text
$sel:iotThingName:Device' :: Device -> Maybe Text
$sel:description:Device' :: Device -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Key
"IotThingName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
iotThingName,
            forall a. a -> Maybe a
Prelude.Just (Key
"DeviceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
deviceName)
          ]
      )