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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.ThingConnectivity
import qualified Amazonka.Prelude as Prelude

-- | The thing search index document.
--
-- /See:/ 'newThingDocument' smart constructor.
data ThingDocument = ThingDocument'
  { -- | The attributes.
    ThingDocument -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Indicates whether the thing is connected to the Amazon Web Services IoT
    -- Core service.
    ThingDocument -> Maybe ThingConnectivity
connectivity :: Prelude.Maybe ThingConnectivity,
    -- | Contains Device Defender data.
    --
    -- For more information about Device Defender, see
    -- <https://docs.aws.amazon.com/iot/latest/developerguide/device-defender.html Device Defender>.
    ThingDocument -> Maybe Text
deviceDefender :: Prelude.Maybe Prelude.Text,
    -- | The unnamed shadow and named shadow.
    --
    -- For more information about shadows, see
    -- <https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html IoT Device Shadow service.>
    ThingDocument -> Maybe Text
shadow :: Prelude.Maybe Prelude.Text,
    -- | Thing group names.
    ThingDocument -> Maybe [Text]
thingGroupNames :: Prelude.Maybe [Prelude.Text],
    -- | The thing ID.
    ThingDocument -> Maybe Text
thingId :: Prelude.Maybe Prelude.Text,
    -- | The thing name.
    ThingDocument -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text,
    -- | The thing type name.
    ThingDocument -> Maybe Text
thingTypeName :: Prelude.Maybe Prelude.Text
  }
  deriving (ThingDocument -> ThingDocument -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThingDocument -> ThingDocument -> Bool
$c/= :: ThingDocument -> ThingDocument -> Bool
== :: ThingDocument -> ThingDocument -> Bool
$c== :: ThingDocument -> ThingDocument -> Bool
Prelude.Eq, ReadPrec [ThingDocument]
ReadPrec ThingDocument
Int -> ReadS ThingDocument
ReadS [ThingDocument]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThingDocument]
$creadListPrec :: ReadPrec [ThingDocument]
readPrec :: ReadPrec ThingDocument
$creadPrec :: ReadPrec ThingDocument
readList :: ReadS [ThingDocument]
$creadList :: ReadS [ThingDocument]
readsPrec :: Int -> ReadS ThingDocument
$creadsPrec :: Int -> ReadS ThingDocument
Prelude.Read, Int -> ThingDocument -> ShowS
[ThingDocument] -> ShowS
ThingDocument -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThingDocument] -> ShowS
$cshowList :: [ThingDocument] -> ShowS
show :: ThingDocument -> String
$cshow :: ThingDocument -> String
showsPrec :: Int -> ThingDocument -> ShowS
$cshowsPrec :: Int -> ThingDocument -> ShowS
Prelude.Show, forall x. Rep ThingDocument x -> ThingDocument
forall x. ThingDocument -> Rep ThingDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThingDocument x -> ThingDocument
$cfrom :: forall x. ThingDocument -> Rep ThingDocument x
Prelude.Generic)

-- |
-- Create a value of 'ThingDocument' 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', 'thingDocument_attributes' - The attributes.
--
-- 'connectivity', 'thingDocument_connectivity' - Indicates whether the thing is connected to the Amazon Web Services IoT
-- Core service.
--
-- 'deviceDefender', 'thingDocument_deviceDefender' - Contains Device Defender data.
--
-- For more information about Device Defender, see
-- <https://docs.aws.amazon.com/iot/latest/developerguide/device-defender.html Device Defender>.
--
-- 'shadow', 'thingDocument_shadow' - The unnamed shadow and named shadow.
--
-- For more information about shadows, see
-- <https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html IoT Device Shadow service.>
--
-- 'thingGroupNames', 'thingDocument_thingGroupNames' - Thing group names.
--
-- 'thingId', 'thingDocument_thingId' - The thing ID.
--
-- 'thingName', 'thingDocument_thingName' - The thing name.
--
-- 'thingTypeName', 'thingDocument_thingTypeName' - The thing type name.
newThingDocument ::
  ThingDocument
newThingDocument :: ThingDocument
newThingDocument =
  ThingDocument'
    { $sel:attributes:ThingDocument' :: Maybe (HashMap Text Text)
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:connectivity:ThingDocument' :: Maybe ThingConnectivity
connectivity = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceDefender:ThingDocument' :: Maybe Text
deviceDefender = forall a. Maybe a
Prelude.Nothing,
      $sel:shadow:ThingDocument' :: Maybe Text
shadow = forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupNames:ThingDocument' :: Maybe [Text]
thingGroupNames = forall a. Maybe a
Prelude.Nothing,
      $sel:thingId:ThingDocument' :: Maybe Text
thingId = forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:ThingDocument' :: Maybe Text
thingName = forall a. Maybe a
Prelude.Nothing,
      $sel:thingTypeName:ThingDocument' :: Maybe Text
thingTypeName = forall a. Maybe a
Prelude.Nothing
    }

-- | The attributes.
thingDocument_attributes :: Lens.Lens' ThingDocument (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
thingDocument_attributes :: Lens' ThingDocument (Maybe (HashMap Text Text))
thingDocument_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingDocument' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:ThingDocument' :: ThingDocument -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: ThingDocument
s@ThingDocument' {} Maybe (HashMap Text Text)
a -> ThingDocument
s {$sel:attributes:ThingDocument' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: ThingDocument) 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

-- | Indicates whether the thing is connected to the Amazon Web Services IoT
-- Core service.
thingDocument_connectivity :: Lens.Lens' ThingDocument (Prelude.Maybe ThingConnectivity)
thingDocument_connectivity :: Lens' ThingDocument (Maybe ThingConnectivity)
thingDocument_connectivity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingDocument' {Maybe ThingConnectivity
connectivity :: Maybe ThingConnectivity
$sel:connectivity:ThingDocument' :: ThingDocument -> Maybe ThingConnectivity
connectivity} -> Maybe ThingConnectivity
connectivity) (\s :: ThingDocument
s@ThingDocument' {} Maybe ThingConnectivity
a -> ThingDocument
s {$sel:connectivity:ThingDocument' :: Maybe ThingConnectivity
connectivity = Maybe ThingConnectivity
a} :: ThingDocument)

-- | Contains Device Defender data.
--
-- For more information about Device Defender, see
-- <https://docs.aws.amazon.com/iot/latest/developerguide/device-defender.html Device Defender>.
thingDocument_deviceDefender :: Lens.Lens' ThingDocument (Prelude.Maybe Prelude.Text)
thingDocument_deviceDefender :: Lens' ThingDocument (Maybe Text)
thingDocument_deviceDefender = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingDocument' {Maybe Text
deviceDefender :: Maybe Text
$sel:deviceDefender:ThingDocument' :: ThingDocument -> Maybe Text
deviceDefender} -> Maybe Text
deviceDefender) (\s :: ThingDocument
s@ThingDocument' {} Maybe Text
a -> ThingDocument
s {$sel:deviceDefender:ThingDocument' :: Maybe Text
deviceDefender = Maybe Text
a} :: ThingDocument)

-- | The unnamed shadow and named shadow.
--
-- For more information about shadows, see
-- <https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html IoT Device Shadow service.>
thingDocument_shadow :: Lens.Lens' ThingDocument (Prelude.Maybe Prelude.Text)
thingDocument_shadow :: Lens' ThingDocument (Maybe Text)
thingDocument_shadow = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingDocument' {Maybe Text
shadow :: Maybe Text
$sel:shadow:ThingDocument' :: ThingDocument -> Maybe Text
shadow} -> Maybe Text
shadow) (\s :: ThingDocument
s@ThingDocument' {} Maybe Text
a -> ThingDocument
s {$sel:shadow:ThingDocument' :: Maybe Text
shadow = Maybe Text
a} :: ThingDocument)

-- | Thing group names.
thingDocument_thingGroupNames :: Lens.Lens' ThingDocument (Prelude.Maybe [Prelude.Text])
thingDocument_thingGroupNames :: Lens' ThingDocument (Maybe [Text])
thingDocument_thingGroupNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingDocument' {Maybe [Text]
thingGroupNames :: Maybe [Text]
$sel:thingGroupNames:ThingDocument' :: ThingDocument -> Maybe [Text]
thingGroupNames} -> Maybe [Text]
thingGroupNames) (\s :: ThingDocument
s@ThingDocument' {} Maybe [Text]
a -> ThingDocument
s {$sel:thingGroupNames:ThingDocument' :: Maybe [Text]
thingGroupNames = Maybe [Text]
a} :: ThingDocument) 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 ID.
thingDocument_thingId :: Lens.Lens' ThingDocument (Prelude.Maybe Prelude.Text)
thingDocument_thingId :: Lens' ThingDocument (Maybe Text)
thingDocument_thingId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingDocument' {Maybe Text
thingId :: Maybe Text
$sel:thingId:ThingDocument' :: ThingDocument -> Maybe Text
thingId} -> Maybe Text
thingId) (\s :: ThingDocument
s@ThingDocument' {} Maybe Text
a -> ThingDocument
s {$sel:thingId:ThingDocument' :: Maybe Text
thingId = Maybe Text
a} :: ThingDocument)

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

-- | The thing type name.
thingDocument_thingTypeName :: Lens.Lens' ThingDocument (Prelude.Maybe Prelude.Text)
thingDocument_thingTypeName :: Lens' ThingDocument (Maybe Text)
thingDocument_thingTypeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingDocument' {Maybe Text
thingTypeName :: Maybe Text
$sel:thingTypeName:ThingDocument' :: ThingDocument -> Maybe Text
thingTypeName} -> Maybe Text
thingTypeName) (\s :: ThingDocument
s@ThingDocument' {} Maybe Text
a -> ThingDocument
s {$sel:thingTypeName:ThingDocument' :: Maybe Text
thingTypeName = Maybe Text
a} :: ThingDocument)

instance Data.FromJSON ThingDocument where
  parseJSON :: Value -> Parser ThingDocument
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ThingDocument"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe ThingConnectivity
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> ThingDocument
ThingDocument'
            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
"connectivity")
            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
"deviceDefender")
            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
"shadow")
            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
"thingGroupNames"
                            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
"thingId")
            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")
      )

instance Prelude.Hashable ThingDocument where
  hashWithSalt :: Int -> ThingDocument -> Int
hashWithSalt Int
_salt ThingDocument' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe ThingConnectivity
thingTypeName :: Maybe Text
thingName :: Maybe Text
thingId :: Maybe Text
thingGroupNames :: Maybe [Text]
shadow :: Maybe Text
deviceDefender :: Maybe Text
connectivity :: Maybe ThingConnectivity
attributes :: Maybe (HashMap Text Text)
$sel:thingTypeName:ThingDocument' :: ThingDocument -> Maybe Text
$sel:thingName:ThingDocument' :: ThingDocument -> Maybe Text
$sel:thingId:ThingDocument' :: ThingDocument -> Maybe Text
$sel:thingGroupNames:ThingDocument' :: ThingDocument -> Maybe [Text]
$sel:shadow:ThingDocument' :: ThingDocument -> Maybe Text
$sel:deviceDefender:ThingDocument' :: ThingDocument -> Maybe Text
$sel:connectivity:ThingDocument' :: ThingDocument -> Maybe ThingConnectivity
$sel:attributes:ThingDocument' :: ThingDocument -> 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 ThingConnectivity
connectivity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deviceDefender
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
shadow
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
thingGroupNames
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingTypeName

instance Prelude.NFData ThingDocument where
  rnf :: ThingDocument -> ()
rnf ThingDocument' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe ThingConnectivity
thingTypeName :: Maybe Text
thingName :: Maybe Text
thingId :: Maybe Text
thingGroupNames :: Maybe [Text]
shadow :: Maybe Text
deviceDefender :: Maybe Text
connectivity :: Maybe ThingConnectivity
attributes :: Maybe (HashMap Text Text)
$sel:thingTypeName:ThingDocument' :: ThingDocument -> Maybe Text
$sel:thingName:ThingDocument' :: ThingDocument -> Maybe Text
$sel:thingId:ThingDocument' :: ThingDocument -> Maybe Text
$sel:thingGroupNames:ThingDocument' :: ThingDocument -> Maybe [Text]
$sel:shadow:ThingDocument' :: ThingDocument -> Maybe Text
$sel:deviceDefender:ThingDocument' :: ThingDocument -> Maybe Text
$sel:connectivity:ThingDocument' :: ThingDocument -> Maybe ThingConnectivity
$sel:attributes:ThingDocument' :: ThingDocument -> 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 ThingConnectivity
connectivity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deviceDefender
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
shadow
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
thingGroupNames
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingId
      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