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

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

-- | The thing search index document.
--
-- /See:/ 'newThingDocument' smart constructor.
data ThingDocument = ThingDocument'
  { -- | Thing group names.
    ThingDocument -> Maybe [Text]
thingGroupNames :: Prelude.Maybe [Prelude.Text],
    -- | The thing type name.
    ThingDocument -> Maybe Text
thingTypeName :: Prelude.Maybe Prelude.Text,
    -- | The shadow.
    ThingDocument -> Maybe Text
shadow :: Prelude.Maybe Prelude.Text,
    -- | 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,
    -- | The thing name.
    ThingDocument -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text,
    -- | The thing ID.
    ThingDocument -> Maybe Text
thingId :: Prelude.Maybe Prelude.Text
  }
  deriving (ThingDocument -> ThingDocument -> Bool
(ThingDocument -> ThingDocument -> Bool)
-> (ThingDocument -> ThingDocument -> Bool) -> Eq ThingDocument
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]
(Int -> ReadS ThingDocument)
-> ReadS [ThingDocument]
-> ReadPrec ThingDocument
-> ReadPrec [ThingDocument]
-> Read 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
(Int -> ThingDocument -> ShowS)
-> (ThingDocument -> String)
-> ([ThingDocument] -> ShowS)
-> Show ThingDocument
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. ThingDocument -> Rep ThingDocument x)
-> (forall x. Rep ThingDocument x -> ThingDocument)
-> Generic ThingDocument
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:
--
-- 'thingGroupNames', 'thingDocument_thingGroupNames' - Thing group names.
--
-- 'thingTypeName', 'thingDocument_thingTypeName' - The thing type name.
--
-- 'shadow', 'thingDocument_shadow' - The shadow.
--
-- 'attributes', 'thingDocument_attributes' - The attributes.
--
-- 'connectivity', 'thingDocument_connectivity' - Indicates whether the thing is connected to the Amazon Web Services IoT
-- Core service.
--
-- 'thingName', 'thingDocument_thingName' - The thing name.
--
-- 'thingId', 'thingDocument_thingId' - The thing ID.
newThingDocument ::
  ThingDocument
newThingDocument :: ThingDocument
newThingDocument =
  ThingDocument' :: Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe ThingConnectivity
-> Maybe Text
-> Maybe Text
-> ThingDocument
ThingDocument'
    { $sel:thingGroupNames:ThingDocument' :: Maybe [Text]
thingGroupNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:thingTypeName:ThingDocument' :: Maybe Text
thingTypeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:shadow:ThingDocument' :: Maybe Text
shadow = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:ThingDocument' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:connectivity:ThingDocument' :: Maybe ThingConnectivity
connectivity = Maybe ThingConnectivity
forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:ThingDocument' :: Maybe Text
thingName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:thingId:ThingDocument' :: Maybe Text
thingId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Thing group names.
thingDocument_thingGroupNames :: Lens.Lens' ThingDocument (Prelude.Maybe [Prelude.Text])
thingDocument_thingGroupNames :: (Maybe [Text] -> f (Maybe [Text]))
-> ThingDocument -> f ThingDocument
thingDocument_thingGroupNames = (ThingDocument -> Maybe [Text])
-> (ThingDocument -> Maybe [Text] -> ThingDocument)
-> Lens ThingDocument ThingDocument (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ThingDocument -> f ThingDocument)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ThingDocument
-> f ThingDocument
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The thing type name.
thingDocument_thingTypeName :: Lens.Lens' ThingDocument (Prelude.Maybe Prelude.Text)
thingDocument_thingTypeName :: (Maybe Text -> f (Maybe Text)) -> ThingDocument -> f ThingDocument
thingDocument_thingTypeName = (ThingDocument -> Maybe Text)
-> (ThingDocument -> Maybe Text -> ThingDocument)
-> Lens ThingDocument ThingDocument (Maybe Text) (Maybe Text)
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)

-- | The shadow.
thingDocument_shadow :: Lens.Lens' ThingDocument (Prelude.Maybe Prelude.Text)
thingDocument_shadow :: (Maybe Text -> f (Maybe Text)) -> ThingDocument -> f ThingDocument
thingDocument_shadow = (ThingDocument -> Maybe Text)
-> (ThingDocument -> Maybe Text -> ThingDocument)
-> Lens ThingDocument ThingDocument (Maybe Text) (Maybe Text)
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)

-- | The attributes.
thingDocument_attributes :: Lens.Lens' ThingDocument (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
thingDocument_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ThingDocument -> f ThingDocument
thingDocument_attributes = (ThingDocument -> Maybe (HashMap Text Text))
-> (ThingDocument -> Maybe (HashMap Text Text) -> ThingDocument)
-> Lens
     ThingDocument
     ThingDocument
     (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 (\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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ThingDocument -> f ThingDocument)
-> ((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)))
-> ThingDocument
-> f ThingDocument
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

-- | Indicates whether the thing is connected to the Amazon Web Services IoT
-- Core service.
thingDocument_connectivity :: Lens.Lens' ThingDocument (Prelude.Maybe ThingConnectivity)
thingDocument_connectivity :: (Maybe ThingConnectivity -> f (Maybe ThingConnectivity))
-> ThingDocument -> f ThingDocument
thingDocument_connectivity = (ThingDocument -> Maybe ThingConnectivity)
-> (ThingDocument -> Maybe ThingConnectivity -> ThingDocument)
-> Lens
     ThingDocument
     ThingDocument
     (Maybe ThingConnectivity)
     (Maybe ThingConnectivity)
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)

-- | The thing name.
thingDocument_thingName :: Lens.Lens' ThingDocument (Prelude.Maybe Prelude.Text)
thingDocument_thingName :: (Maybe Text -> f (Maybe Text)) -> ThingDocument -> f ThingDocument
thingDocument_thingName = (ThingDocument -> Maybe Text)
-> (ThingDocument -> Maybe Text -> ThingDocument)
-> Lens ThingDocument ThingDocument (Maybe Text) (Maybe Text)
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 ID.
thingDocument_thingId :: Lens.Lens' ThingDocument (Prelude.Maybe Prelude.Text)
thingDocument_thingId :: (Maybe Text -> f (Maybe Text)) -> ThingDocument -> f ThingDocument
thingDocument_thingId = (ThingDocument -> Maybe Text)
-> (ThingDocument -> Maybe Text -> ThingDocument)
-> Lens ThingDocument ThingDocument (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON ThingDocument where
  parseJSON :: Value -> Parser ThingDocument
parseJSON =
    String
-> (Object -> Parser ThingDocument)
-> Value
-> Parser ThingDocument
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ThingDocument"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe ThingConnectivity
-> Maybe Text
-> Maybe Text
-> ThingDocument
ThingDocument'
            (Maybe [Text]
 -> Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe ThingConnectivity
 -> Maybe Text
 -> Maybe Text
 -> ThingDocument)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe ThingConnectivity
      -> Maybe Text
      -> Maybe Text
      -> ThingDocument)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"thingGroupNames"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe ThingConnectivity
   -> Maybe Text
   -> Maybe Text
   -> ThingDocument)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe ThingConnectivity
      -> Maybe Text
      -> Maybe Text
      -> ThingDocument)
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
"thingTypeName")
            Parser
  (Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe ThingConnectivity
   -> Maybe Text
   -> Maybe Text
   -> ThingDocument)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe ThingConnectivity
      -> Maybe Text
      -> Maybe Text
      -> ThingDocument)
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
"shadow")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe ThingConnectivity
   -> Maybe Text
   -> Maybe Text
   -> ThingDocument)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe ThingConnectivity
      -> Maybe Text -> Maybe Text -> ThingDocument)
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 ThingConnectivity
   -> Maybe Text -> Maybe Text -> ThingDocument)
-> Parser (Maybe ThingConnectivity)
-> Parser (Maybe Text -> Maybe Text -> ThingDocument)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ThingConnectivity)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"connectivity")
            Parser (Maybe Text -> Maybe Text -> ThingDocument)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ThingDocument)
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")
            Parser (Maybe Text -> ThingDocument)
-> Parser (Maybe Text) -> Parser ThingDocument
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
"thingId")
      )

instance Prelude.Hashable ThingDocument

instance Prelude.NFData ThingDocument