{-# 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.IoT.Types.ThingAttribute
-- 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.IoT.Types.ThingAttribute 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

-- | The properties of the thing, including thing name, thing type name, and
-- a list of thing attributes.
--
-- /See:/ 'newThingAttribute' smart constructor.
data ThingAttribute = ThingAttribute'
  { -- | A list of thing attributes which are name-value pairs.
    ThingAttribute -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The thing ARN.
    ThingAttribute -> Maybe Text
thingArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the thing.
    ThingAttribute -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text,
    -- | The name of the thing type, if the thing has been associated with a
    -- type.
    ThingAttribute -> Maybe Text
thingTypeName :: Prelude.Maybe Prelude.Text,
    -- | The version of the thing record in the registry.
    ThingAttribute -> Maybe Integer
version :: Prelude.Maybe Prelude.Integer
  }
  deriving (ThingAttribute -> ThingAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThingAttribute -> ThingAttribute -> Bool
$c/= :: ThingAttribute -> ThingAttribute -> Bool
== :: ThingAttribute -> ThingAttribute -> Bool
$c== :: ThingAttribute -> ThingAttribute -> Bool
Prelude.Eq, ReadPrec [ThingAttribute]
ReadPrec ThingAttribute
Int -> ReadS ThingAttribute
ReadS [ThingAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThingAttribute]
$creadListPrec :: ReadPrec [ThingAttribute]
readPrec :: ReadPrec ThingAttribute
$creadPrec :: ReadPrec ThingAttribute
readList :: ReadS [ThingAttribute]
$creadList :: ReadS [ThingAttribute]
readsPrec :: Int -> ReadS ThingAttribute
$creadsPrec :: Int -> ReadS ThingAttribute
Prelude.Read, Int -> ThingAttribute -> ShowS
[ThingAttribute] -> ShowS
ThingAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThingAttribute] -> ShowS
$cshowList :: [ThingAttribute] -> ShowS
show :: ThingAttribute -> String
$cshow :: ThingAttribute -> String
showsPrec :: Int -> ThingAttribute -> ShowS
$cshowsPrec :: Int -> ThingAttribute -> ShowS
Prelude.Show, forall x. Rep ThingAttribute x -> ThingAttribute
forall x. ThingAttribute -> Rep ThingAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThingAttribute x -> ThingAttribute
$cfrom :: forall x. ThingAttribute -> Rep ThingAttribute x
Prelude.Generic)

-- |
-- Create a value of 'ThingAttribute' 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', 'thingAttribute_attributes' - A list of thing attributes which are name-value pairs.
--
-- 'thingArn', 'thingAttribute_thingArn' - The thing ARN.
--
-- 'thingName', 'thingAttribute_thingName' - The name of the thing.
--
-- 'thingTypeName', 'thingAttribute_thingTypeName' - The name of the thing type, if the thing has been associated with a
-- type.
--
-- 'version', 'thingAttribute_version' - The version of the thing record in the registry.
newThingAttribute ::
  ThingAttribute
newThingAttribute :: ThingAttribute
newThingAttribute =
  ThingAttribute'
    { $sel:attributes:ThingAttribute' :: Maybe (HashMap Text Text)
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:thingArn:ThingAttribute' :: Maybe Text
thingArn = forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:ThingAttribute' :: Maybe Text
thingName = forall a. Maybe a
Prelude.Nothing,
      $sel:thingTypeName:ThingAttribute' :: Maybe Text
thingTypeName = forall a. Maybe a
Prelude.Nothing,
      $sel:version:ThingAttribute' :: Maybe Integer
version = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of thing attributes which are name-value pairs.
thingAttribute_attributes :: Lens.Lens' ThingAttribute (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
thingAttribute_attributes :: Lens' ThingAttribute (Maybe (HashMap Text Text))
thingAttribute_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingAttribute' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:ThingAttribute' :: ThingAttribute -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: ThingAttribute
s@ThingAttribute' {} Maybe (HashMap Text Text)
a -> ThingAttribute
s {$sel:attributes:ThingAttribute' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: ThingAttribute) 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 thing ARN.
thingAttribute_thingArn :: Lens.Lens' ThingAttribute (Prelude.Maybe Prelude.Text)
thingAttribute_thingArn :: Lens' ThingAttribute (Maybe Text)
thingAttribute_thingArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingAttribute' {Maybe Text
thingArn :: Maybe Text
$sel:thingArn:ThingAttribute' :: ThingAttribute -> Maybe Text
thingArn} -> Maybe Text
thingArn) (\s :: ThingAttribute
s@ThingAttribute' {} Maybe Text
a -> ThingAttribute
s {$sel:thingArn:ThingAttribute' :: Maybe Text
thingArn = Maybe Text
a} :: ThingAttribute)

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

-- | The name of the thing type, if the thing has been associated with a
-- type.
thingAttribute_thingTypeName :: Lens.Lens' ThingAttribute (Prelude.Maybe Prelude.Text)
thingAttribute_thingTypeName :: Lens' ThingAttribute (Maybe Text)
thingAttribute_thingTypeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingAttribute' {Maybe Text
thingTypeName :: Maybe Text
$sel:thingTypeName:ThingAttribute' :: ThingAttribute -> Maybe Text
thingTypeName} -> Maybe Text
thingTypeName) (\s :: ThingAttribute
s@ThingAttribute' {} Maybe Text
a -> ThingAttribute
s {$sel:thingTypeName:ThingAttribute' :: Maybe Text
thingTypeName = Maybe Text
a} :: ThingAttribute)

-- | The version of the thing record in the registry.
thingAttribute_version :: Lens.Lens' ThingAttribute (Prelude.Maybe Prelude.Integer)
thingAttribute_version :: Lens' ThingAttribute (Maybe Integer)
thingAttribute_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingAttribute' {Maybe Integer
version :: Maybe Integer
$sel:version:ThingAttribute' :: ThingAttribute -> Maybe Integer
version} -> Maybe Integer
version) (\s :: ThingAttribute
s@ThingAttribute' {} Maybe Integer
a -> ThingAttribute
s {$sel:version:ThingAttribute' :: Maybe Integer
version = Maybe Integer
a} :: ThingAttribute)

instance Data.FromJSON ThingAttribute where
  parseJSON :: Value -> Parser ThingAttribute
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ThingAttribute"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Integer
-> ThingAttribute
ThingAttribute'
            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
"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
"thingArn")
            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
"thingName")
            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
"thingTypeName")
            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
"version")
      )

instance Prelude.Hashable ThingAttribute where
  hashWithSalt :: Int -> ThingAttribute -> Int
hashWithSalt Int
_salt ThingAttribute' {Maybe Integer
Maybe Text
Maybe (HashMap Text Text)
version :: Maybe Integer
thingTypeName :: Maybe Text
thingName :: Maybe Text
thingArn :: Maybe Text
attributes :: Maybe (HashMap Text Text)
$sel:version:ThingAttribute' :: ThingAttribute -> Maybe Integer
$sel:thingTypeName:ThingAttribute' :: ThingAttribute -> Maybe Text
$sel:thingName:ThingAttribute' :: ThingAttribute -> Maybe Text
$sel:thingArn:ThingAttribute' :: ThingAttribute -> Maybe Text
$sel:attributes:ThingAttribute' :: ThingAttribute -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      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
thingArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingTypeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
version

instance Prelude.NFData ThingAttribute where
  rnf :: ThingAttribute -> ()
rnf ThingAttribute' {Maybe Integer
Maybe Text
Maybe (HashMap Text Text)
version :: Maybe Integer
thingTypeName :: Maybe Text
thingName :: Maybe Text
thingArn :: Maybe Text
attributes :: Maybe (HashMap Text Text)
$sel:version:ThingAttribute' :: ThingAttribute -> Maybe Integer
$sel:thingTypeName:ThingAttribute' :: ThingAttribute -> Maybe Text
$sel:thingName:ThingAttribute' :: ThingAttribute -> Maybe Text
$sel:thingArn:ThingAttribute' :: ThingAttribute -> Maybe Text
$sel:attributes:ThingAttribute' :: ThingAttribute -> Maybe (HashMap Text Text)
..} =
    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
thingArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingTypeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
version