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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | The name of the thing type, if the thing has been associated with a
    -- type.
    ThingAttribute -> Maybe Text
thingTypeName :: Prelude.Maybe Prelude.Text,
    -- | The thing ARN.
    ThingAttribute -> Maybe Text
thingArn :: Prelude.Maybe Prelude.Text,
    -- | 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 version of the thing record in the registry.
    ThingAttribute -> Maybe Integer
version :: Prelude.Maybe Prelude.Integer,
    -- | The name of the thing.
    ThingAttribute -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text
  }
  deriving (ThingAttribute -> ThingAttribute -> Bool
(ThingAttribute -> ThingAttribute -> Bool)
-> (ThingAttribute -> ThingAttribute -> Bool) -> Eq ThingAttribute
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]
(Int -> ReadS ThingAttribute)
-> ReadS [ThingAttribute]
-> ReadPrec ThingAttribute
-> ReadPrec [ThingAttribute]
-> Read 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
(Int -> ThingAttribute -> ShowS)
-> (ThingAttribute -> String)
-> ([ThingAttribute] -> ShowS)
-> Show ThingAttribute
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. ThingAttribute -> Rep ThingAttribute x)
-> (forall x. Rep ThingAttribute x -> ThingAttribute)
-> Generic ThingAttribute
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:
--
-- 'thingTypeName', 'thingAttribute_thingTypeName' - The name of the thing type, if the thing has been associated with a
-- type.
--
-- 'thingArn', 'thingAttribute_thingArn' - The thing ARN.
--
-- 'attributes', 'thingAttribute_attributes' - A list of thing attributes which are name-value pairs.
--
-- 'version', 'thingAttribute_version' - The version of the thing record in the registry.
--
-- 'thingName', 'thingAttribute_thingName' - The name of the thing.
newThingAttribute ::
  ThingAttribute
newThingAttribute :: ThingAttribute
newThingAttribute =
  ThingAttribute' :: Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Integer
-> Maybe Text
-> ThingAttribute
ThingAttribute'
    { $sel:thingTypeName:ThingAttribute' :: Maybe Text
thingTypeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:thingArn:ThingAttribute' :: Maybe Text
thingArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:ThingAttribute' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:version:ThingAttribute' :: Maybe Integer
version = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:ThingAttribute' :: Maybe Text
thingName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ThingAttribute -> f ThingAttribute
thingAttribute_thingTypeName = (ThingAttribute -> Maybe Text)
-> (ThingAttribute -> Maybe Text -> ThingAttribute)
-> Lens ThingAttribute ThingAttribute (Maybe Text) (Maybe Text)
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 thing ARN.
thingAttribute_thingArn :: Lens.Lens' ThingAttribute (Prelude.Maybe Prelude.Text)
thingAttribute_thingArn :: (Maybe Text -> f (Maybe Text))
-> ThingAttribute -> f ThingAttribute
thingAttribute_thingArn = (ThingAttribute -> Maybe Text)
-> (ThingAttribute -> Maybe Text -> ThingAttribute)
-> Lens ThingAttribute ThingAttribute (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ThingAttribute -> f ThingAttribute
thingAttribute_attributes = (ThingAttribute -> Maybe (HashMap Text Text))
-> (ThingAttribute -> Maybe (HashMap Text Text) -> ThingAttribute)
-> Lens
     ThingAttribute
     ThingAttribute
     (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 (\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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ThingAttribute -> f ThingAttribute)
-> ((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)))
-> ThingAttribute
-> f ThingAttribute
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 version of the thing record in the registry.
thingAttribute_version :: Lens.Lens' ThingAttribute (Prelude.Maybe Prelude.Integer)
thingAttribute_version :: (Maybe Integer -> f (Maybe Integer))
-> ThingAttribute -> f ThingAttribute
thingAttribute_version = (ThingAttribute -> Maybe Integer)
-> (ThingAttribute -> Maybe Integer -> ThingAttribute)
-> Lens
     ThingAttribute ThingAttribute (Maybe Integer) (Maybe Integer)
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)

-- | The name of the thing.
thingAttribute_thingName :: Lens.Lens' ThingAttribute (Prelude.Maybe Prelude.Text)
thingAttribute_thingName :: (Maybe Text -> f (Maybe Text))
-> ThingAttribute -> f ThingAttribute
thingAttribute_thingName = (ThingAttribute -> Maybe Text)
-> (ThingAttribute -> Maybe Text -> ThingAttribute)
-> Lens ThingAttribute ThingAttribute (Maybe Text) (Maybe Text)
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)

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

instance Prelude.NFData ThingAttribute