{-# 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.IoTThingsGraph.Types.Thing
-- 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.IoTThingsGraph.Types.Thing where

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

-- | An AWS IoT thing.
--
-- /See:/ 'newThing' smart constructor.
data Thing = Thing'
  { -- | The ARN of the thing.
    Thing -> Maybe Text
thingArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the thing.
    Thing -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text
  }
  deriving (Thing -> Thing -> Bool
(Thing -> Thing -> Bool) -> (Thing -> Thing -> Bool) -> Eq Thing
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Thing -> Thing -> Bool
$c/= :: Thing -> Thing -> Bool
== :: Thing -> Thing -> Bool
$c== :: Thing -> Thing -> Bool
Prelude.Eq, ReadPrec [Thing]
ReadPrec Thing
Int -> ReadS Thing
ReadS [Thing]
(Int -> ReadS Thing)
-> ReadS [Thing]
-> ReadPrec Thing
-> ReadPrec [Thing]
-> Read Thing
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Thing]
$creadListPrec :: ReadPrec [Thing]
readPrec :: ReadPrec Thing
$creadPrec :: ReadPrec Thing
readList :: ReadS [Thing]
$creadList :: ReadS [Thing]
readsPrec :: Int -> ReadS Thing
$creadsPrec :: Int -> ReadS Thing
Prelude.Read, Int -> Thing -> ShowS
[Thing] -> ShowS
Thing -> String
(Int -> Thing -> ShowS)
-> (Thing -> String) -> ([Thing] -> ShowS) -> Show Thing
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Thing] -> ShowS
$cshowList :: [Thing] -> ShowS
show :: Thing -> String
$cshow :: Thing -> String
showsPrec :: Int -> Thing -> ShowS
$cshowsPrec :: Int -> Thing -> ShowS
Prelude.Show, (forall x. Thing -> Rep Thing x)
-> (forall x. Rep Thing x -> Thing) -> Generic Thing
forall x. Rep Thing x -> Thing
forall x. Thing -> Rep Thing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Thing x -> Thing
$cfrom :: forall x. Thing -> Rep Thing x
Prelude.Generic)

-- |
-- Create a value of 'Thing' 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:
--
-- 'thingArn', 'thing_thingArn' - The ARN of the thing.
--
-- 'thingName', 'thing_thingName' - The name of the thing.
newThing ::
  Thing
newThing :: Thing
newThing =
  Thing' :: Maybe Text -> Maybe Text -> Thing
Thing'
    { $sel:thingArn:Thing' :: Maybe Text
thingArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:Thing' :: Maybe Text
thingName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the thing.
thing_thingArn :: Lens.Lens' Thing (Prelude.Maybe Prelude.Text)
thing_thingArn :: (Maybe Text -> f (Maybe Text)) -> Thing -> f Thing
thing_thingArn = (Thing -> Maybe Text)
-> (Thing -> Maybe Text -> Thing)
-> Lens Thing Thing (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Thing' {Maybe Text
thingArn :: Maybe Text
$sel:thingArn:Thing' :: Thing -> Maybe Text
thingArn} -> Maybe Text
thingArn) (\s :: Thing
s@Thing' {} Maybe Text
a -> Thing
s {$sel:thingArn:Thing' :: Maybe Text
thingArn = Maybe Text
a} :: Thing)

-- | The name of the thing.
thing_thingName :: Lens.Lens' Thing (Prelude.Maybe Prelude.Text)
thing_thingName :: (Maybe Text -> f (Maybe Text)) -> Thing -> f Thing
thing_thingName = (Thing -> Maybe Text)
-> (Thing -> Maybe Text -> Thing)
-> Lens Thing Thing (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Thing' {Maybe Text
thingName :: Maybe Text
$sel:thingName:Thing' :: Thing -> Maybe Text
thingName} -> Maybe Text
thingName) (\s :: Thing
s@Thing' {} Maybe Text
a -> Thing
s {$sel:thingName:Thing' :: Maybe Text
thingName = Maybe Text
a} :: Thing)

instance Core.FromJSON Thing where
  parseJSON :: Value -> Parser Thing
parseJSON =
    String -> (Object -> Parser Thing) -> Value -> Parser Thing
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Thing"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Thing
Thing'
            (Maybe Text -> Maybe Text -> Thing)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Thing)
forall (f :: * -> *) a b. Functor 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
"thingArn")
            Parser (Maybe Text -> Thing) -> Parser (Maybe Text) -> Parser Thing
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
"thingName")
      )

instance Prelude.Hashable Thing

instance Prelude.NFData Thing