{-# 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.ThingTypeProperties
-- 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.ThingTypeProperties 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 ThingTypeProperties contains information about the thing type
-- including: a thing type description, and a list of searchable thing
-- attribute names.
--
-- /See:/ 'newThingTypeProperties' smart constructor.
data ThingTypeProperties = ThingTypeProperties'
  { -- | A list of searchable thing attribute names.
    ThingTypeProperties -> Maybe [Text]
searchableAttributes :: Prelude.Maybe [Prelude.Text],
    -- | The description of the thing type.
    ThingTypeProperties -> Maybe Text
thingTypeDescription :: Prelude.Maybe Prelude.Text
  }
  deriving (ThingTypeProperties -> ThingTypeProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThingTypeProperties -> ThingTypeProperties -> Bool
$c/= :: ThingTypeProperties -> ThingTypeProperties -> Bool
== :: ThingTypeProperties -> ThingTypeProperties -> Bool
$c== :: ThingTypeProperties -> ThingTypeProperties -> Bool
Prelude.Eq, ReadPrec [ThingTypeProperties]
ReadPrec ThingTypeProperties
Int -> ReadS ThingTypeProperties
ReadS [ThingTypeProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThingTypeProperties]
$creadListPrec :: ReadPrec [ThingTypeProperties]
readPrec :: ReadPrec ThingTypeProperties
$creadPrec :: ReadPrec ThingTypeProperties
readList :: ReadS [ThingTypeProperties]
$creadList :: ReadS [ThingTypeProperties]
readsPrec :: Int -> ReadS ThingTypeProperties
$creadsPrec :: Int -> ReadS ThingTypeProperties
Prelude.Read, Int -> ThingTypeProperties -> ShowS
[ThingTypeProperties] -> ShowS
ThingTypeProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThingTypeProperties] -> ShowS
$cshowList :: [ThingTypeProperties] -> ShowS
show :: ThingTypeProperties -> String
$cshow :: ThingTypeProperties -> String
showsPrec :: Int -> ThingTypeProperties -> ShowS
$cshowsPrec :: Int -> ThingTypeProperties -> ShowS
Prelude.Show, forall x. Rep ThingTypeProperties x -> ThingTypeProperties
forall x. ThingTypeProperties -> Rep ThingTypeProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThingTypeProperties x -> ThingTypeProperties
$cfrom :: forall x. ThingTypeProperties -> Rep ThingTypeProperties x
Prelude.Generic)

-- |
-- Create a value of 'ThingTypeProperties' 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:
--
-- 'searchableAttributes', 'thingTypeProperties_searchableAttributes' - A list of searchable thing attribute names.
--
-- 'thingTypeDescription', 'thingTypeProperties_thingTypeDescription' - The description of the thing type.
newThingTypeProperties ::
  ThingTypeProperties
newThingTypeProperties :: ThingTypeProperties
newThingTypeProperties =
  ThingTypeProperties'
    { $sel:searchableAttributes:ThingTypeProperties' :: Maybe [Text]
searchableAttributes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:thingTypeDescription:ThingTypeProperties' :: Maybe Text
thingTypeDescription = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of searchable thing attribute names.
thingTypeProperties_searchableAttributes :: Lens.Lens' ThingTypeProperties (Prelude.Maybe [Prelude.Text])
thingTypeProperties_searchableAttributes :: Lens' ThingTypeProperties (Maybe [Text])
thingTypeProperties_searchableAttributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingTypeProperties' {Maybe [Text]
searchableAttributes :: Maybe [Text]
$sel:searchableAttributes:ThingTypeProperties' :: ThingTypeProperties -> Maybe [Text]
searchableAttributes} -> Maybe [Text]
searchableAttributes) (\s :: ThingTypeProperties
s@ThingTypeProperties' {} Maybe [Text]
a -> ThingTypeProperties
s {$sel:searchableAttributes:ThingTypeProperties' :: Maybe [Text]
searchableAttributes = Maybe [Text]
a} :: ThingTypeProperties) 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 description of the thing type.
thingTypeProperties_thingTypeDescription :: Lens.Lens' ThingTypeProperties (Prelude.Maybe Prelude.Text)
thingTypeProperties_thingTypeDescription :: Lens' ThingTypeProperties (Maybe Text)
thingTypeProperties_thingTypeDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingTypeProperties' {Maybe Text
thingTypeDescription :: Maybe Text
$sel:thingTypeDescription:ThingTypeProperties' :: ThingTypeProperties -> Maybe Text
thingTypeDescription} -> Maybe Text
thingTypeDescription) (\s :: ThingTypeProperties
s@ThingTypeProperties' {} Maybe Text
a -> ThingTypeProperties
s {$sel:thingTypeDescription:ThingTypeProperties' :: Maybe Text
thingTypeDescription = Maybe Text
a} :: ThingTypeProperties)

instance Data.FromJSON ThingTypeProperties where
  parseJSON :: Value -> Parser ThingTypeProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ThingTypeProperties"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> ThingTypeProperties
ThingTypeProperties'
            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
"searchableAttributes"
                            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
"thingTypeDescription")
      )

instance Prelude.Hashable ThingTypeProperties where
  hashWithSalt :: Int -> ThingTypeProperties -> Int
hashWithSalt Int
_salt ThingTypeProperties' {Maybe [Text]
Maybe Text
thingTypeDescription :: Maybe Text
searchableAttributes :: Maybe [Text]
$sel:thingTypeDescription:ThingTypeProperties' :: ThingTypeProperties -> Maybe Text
$sel:searchableAttributes:ThingTypeProperties' :: ThingTypeProperties -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
searchableAttributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingTypeDescription

instance Prelude.NFData ThingTypeProperties where
  rnf :: ThingTypeProperties -> ()
rnf ThingTypeProperties' {Maybe [Text]
Maybe Text
thingTypeDescription :: Maybe Text
searchableAttributes :: Maybe [Text]
$sel:thingTypeDescription:ThingTypeProperties' :: ThingTypeProperties -> Maybe Text
$sel:searchableAttributes:ThingTypeProperties' :: ThingTypeProperties -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
searchableAttributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingTypeDescription

instance Data.ToJSON ThingTypeProperties where
  toJSON :: ThingTypeProperties -> Value
toJSON ThingTypeProperties' {Maybe [Text]
Maybe Text
thingTypeDescription :: Maybe Text
searchableAttributes :: Maybe [Text]
$sel:thingTypeDescription:ThingTypeProperties' :: ThingTypeProperties -> Maybe Text
$sel:searchableAttributes:ThingTypeProperties' :: ThingTypeProperties -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"searchableAttributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
searchableAttributes,
            (Key
"thingTypeDescription" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
thingTypeDescription
          ]
      )