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

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.ThingTypeMetadata
import Amazonka.IoT.Types.ThingTypeProperties
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The definition of the thing type, including thing type name and
-- description.
--
-- /See:/ 'newThingTypeDefinition' smart constructor.
data ThingTypeDefinition = ThingTypeDefinition'
  { -- | The ThingTypeProperties for the thing type.
    ThingTypeDefinition -> Maybe ThingTypeProperties
thingTypeProperties :: Prelude.Maybe ThingTypeProperties,
    -- | The name of the thing type.
    ThingTypeDefinition -> Maybe Text
thingTypeName :: Prelude.Maybe Prelude.Text,
    -- | The ThingTypeMetadata contains additional information about the thing
    -- type including: creation date and time, a value indicating whether the
    -- thing type is deprecated, and a date and time when it was deprecated.
    ThingTypeDefinition -> Maybe ThingTypeMetadata
thingTypeMetadata :: Prelude.Maybe ThingTypeMetadata,
    -- | The thing type ARN.
    ThingTypeDefinition -> Maybe Text
thingTypeArn :: Prelude.Maybe Prelude.Text
  }
  deriving (ThingTypeDefinition -> ThingTypeDefinition -> Bool
(ThingTypeDefinition -> ThingTypeDefinition -> Bool)
-> (ThingTypeDefinition -> ThingTypeDefinition -> Bool)
-> Eq ThingTypeDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThingTypeDefinition -> ThingTypeDefinition -> Bool
$c/= :: ThingTypeDefinition -> ThingTypeDefinition -> Bool
== :: ThingTypeDefinition -> ThingTypeDefinition -> Bool
$c== :: ThingTypeDefinition -> ThingTypeDefinition -> Bool
Prelude.Eq, ReadPrec [ThingTypeDefinition]
ReadPrec ThingTypeDefinition
Int -> ReadS ThingTypeDefinition
ReadS [ThingTypeDefinition]
(Int -> ReadS ThingTypeDefinition)
-> ReadS [ThingTypeDefinition]
-> ReadPrec ThingTypeDefinition
-> ReadPrec [ThingTypeDefinition]
-> Read ThingTypeDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThingTypeDefinition]
$creadListPrec :: ReadPrec [ThingTypeDefinition]
readPrec :: ReadPrec ThingTypeDefinition
$creadPrec :: ReadPrec ThingTypeDefinition
readList :: ReadS [ThingTypeDefinition]
$creadList :: ReadS [ThingTypeDefinition]
readsPrec :: Int -> ReadS ThingTypeDefinition
$creadsPrec :: Int -> ReadS ThingTypeDefinition
Prelude.Read, Int -> ThingTypeDefinition -> ShowS
[ThingTypeDefinition] -> ShowS
ThingTypeDefinition -> String
(Int -> ThingTypeDefinition -> ShowS)
-> (ThingTypeDefinition -> String)
-> ([ThingTypeDefinition] -> ShowS)
-> Show ThingTypeDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThingTypeDefinition] -> ShowS
$cshowList :: [ThingTypeDefinition] -> ShowS
show :: ThingTypeDefinition -> String
$cshow :: ThingTypeDefinition -> String
showsPrec :: Int -> ThingTypeDefinition -> ShowS
$cshowsPrec :: Int -> ThingTypeDefinition -> ShowS
Prelude.Show, (forall x. ThingTypeDefinition -> Rep ThingTypeDefinition x)
-> (forall x. Rep ThingTypeDefinition x -> ThingTypeDefinition)
-> Generic ThingTypeDefinition
forall x. Rep ThingTypeDefinition x -> ThingTypeDefinition
forall x. ThingTypeDefinition -> Rep ThingTypeDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThingTypeDefinition x -> ThingTypeDefinition
$cfrom :: forall x. ThingTypeDefinition -> Rep ThingTypeDefinition x
Prelude.Generic)

-- |
-- Create a value of 'ThingTypeDefinition' 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:
--
-- 'thingTypeProperties', 'thingTypeDefinition_thingTypeProperties' - The ThingTypeProperties for the thing type.
--
-- 'thingTypeName', 'thingTypeDefinition_thingTypeName' - The name of the thing type.
--
-- 'thingTypeMetadata', 'thingTypeDefinition_thingTypeMetadata' - The ThingTypeMetadata contains additional information about the thing
-- type including: creation date and time, a value indicating whether the
-- thing type is deprecated, and a date and time when it was deprecated.
--
-- 'thingTypeArn', 'thingTypeDefinition_thingTypeArn' - The thing type ARN.
newThingTypeDefinition ::
  ThingTypeDefinition
newThingTypeDefinition :: ThingTypeDefinition
newThingTypeDefinition =
  ThingTypeDefinition' :: Maybe ThingTypeProperties
-> Maybe Text
-> Maybe ThingTypeMetadata
-> Maybe Text
-> ThingTypeDefinition
ThingTypeDefinition'
    { $sel:thingTypeProperties:ThingTypeDefinition' :: Maybe ThingTypeProperties
thingTypeProperties =
        Maybe ThingTypeProperties
forall a. Maybe a
Prelude.Nothing,
      $sel:thingTypeName:ThingTypeDefinition' :: Maybe Text
thingTypeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:thingTypeMetadata:ThingTypeDefinition' :: Maybe ThingTypeMetadata
thingTypeMetadata = Maybe ThingTypeMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:thingTypeArn:ThingTypeDefinition' :: Maybe Text
thingTypeArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ThingTypeProperties for the thing type.
thingTypeDefinition_thingTypeProperties :: Lens.Lens' ThingTypeDefinition (Prelude.Maybe ThingTypeProperties)
thingTypeDefinition_thingTypeProperties :: (Maybe ThingTypeProperties -> f (Maybe ThingTypeProperties))
-> ThingTypeDefinition -> f ThingTypeDefinition
thingTypeDefinition_thingTypeProperties = (ThingTypeDefinition -> Maybe ThingTypeProperties)
-> (ThingTypeDefinition
    -> Maybe ThingTypeProperties -> ThingTypeDefinition)
-> Lens
     ThingTypeDefinition
     ThingTypeDefinition
     (Maybe ThingTypeProperties)
     (Maybe ThingTypeProperties)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingTypeDefinition' {Maybe ThingTypeProperties
thingTypeProperties :: Maybe ThingTypeProperties
$sel:thingTypeProperties:ThingTypeDefinition' :: ThingTypeDefinition -> Maybe ThingTypeProperties
thingTypeProperties} -> Maybe ThingTypeProperties
thingTypeProperties) (\s :: ThingTypeDefinition
s@ThingTypeDefinition' {} Maybe ThingTypeProperties
a -> ThingTypeDefinition
s {$sel:thingTypeProperties:ThingTypeDefinition' :: Maybe ThingTypeProperties
thingTypeProperties = Maybe ThingTypeProperties
a} :: ThingTypeDefinition)

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

-- | The ThingTypeMetadata contains additional information about the thing
-- type including: creation date and time, a value indicating whether the
-- thing type is deprecated, and a date and time when it was deprecated.
thingTypeDefinition_thingTypeMetadata :: Lens.Lens' ThingTypeDefinition (Prelude.Maybe ThingTypeMetadata)
thingTypeDefinition_thingTypeMetadata :: (Maybe ThingTypeMetadata -> f (Maybe ThingTypeMetadata))
-> ThingTypeDefinition -> f ThingTypeDefinition
thingTypeDefinition_thingTypeMetadata = (ThingTypeDefinition -> Maybe ThingTypeMetadata)
-> (ThingTypeDefinition
    -> Maybe ThingTypeMetadata -> ThingTypeDefinition)
-> Lens
     ThingTypeDefinition
     ThingTypeDefinition
     (Maybe ThingTypeMetadata)
     (Maybe ThingTypeMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingTypeDefinition' {Maybe ThingTypeMetadata
thingTypeMetadata :: Maybe ThingTypeMetadata
$sel:thingTypeMetadata:ThingTypeDefinition' :: ThingTypeDefinition -> Maybe ThingTypeMetadata
thingTypeMetadata} -> Maybe ThingTypeMetadata
thingTypeMetadata) (\s :: ThingTypeDefinition
s@ThingTypeDefinition' {} Maybe ThingTypeMetadata
a -> ThingTypeDefinition
s {$sel:thingTypeMetadata:ThingTypeDefinition' :: Maybe ThingTypeMetadata
thingTypeMetadata = Maybe ThingTypeMetadata
a} :: ThingTypeDefinition)

-- | The thing type ARN.
thingTypeDefinition_thingTypeArn :: Lens.Lens' ThingTypeDefinition (Prelude.Maybe Prelude.Text)
thingTypeDefinition_thingTypeArn :: (Maybe Text -> f (Maybe Text))
-> ThingTypeDefinition -> f ThingTypeDefinition
thingTypeDefinition_thingTypeArn = (ThingTypeDefinition -> Maybe Text)
-> (ThingTypeDefinition -> Maybe Text -> ThingTypeDefinition)
-> Lens
     ThingTypeDefinition ThingTypeDefinition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingTypeDefinition' {Maybe Text
thingTypeArn :: Maybe Text
$sel:thingTypeArn:ThingTypeDefinition' :: ThingTypeDefinition -> Maybe Text
thingTypeArn} -> Maybe Text
thingTypeArn) (\s :: ThingTypeDefinition
s@ThingTypeDefinition' {} Maybe Text
a -> ThingTypeDefinition
s {$sel:thingTypeArn:ThingTypeDefinition' :: Maybe Text
thingTypeArn = Maybe Text
a} :: ThingTypeDefinition)

instance Core.FromJSON ThingTypeDefinition where
  parseJSON :: Value -> Parser ThingTypeDefinition
parseJSON =
    String
-> (Object -> Parser ThingTypeDefinition)
-> Value
-> Parser ThingTypeDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ThingTypeDefinition"
      ( \Object
x ->
          Maybe ThingTypeProperties
-> Maybe Text
-> Maybe ThingTypeMetadata
-> Maybe Text
-> ThingTypeDefinition
ThingTypeDefinition'
            (Maybe ThingTypeProperties
 -> Maybe Text
 -> Maybe ThingTypeMetadata
 -> Maybe Text
 -> ThingTypeDefinition)
-> Parser (Maybe ThingTypeProperties)
-> Parser
     (Maybe Text
      -> Maybe ThingTypeMetadata -> Maybe Text -> ThingTypeDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ThingTypeProperties)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"thingTypeProperties")
            Parser
  (Maybe Text
   -> Maybe ThingTypeMetadata -> Maybe Text -> ThingTypeDefinition)
-> Parser (Maybe Text)
-> Parser
     (Maybe ThingTypeMetadata -> Maybe Text -> ThingTypeDefinition)
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 ThingTypeMetadata -> Maybe Text -> ThingTypeDefinition)
-> Parser (Maybe ThingTypeMetadata)
-> Parser (Maybe Text -> ThingTypeDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ThingTypeMetadata)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"thingTypeMetadata")
            Parser (Maybe Text -> ThingTypeDefinition)
-> Parser (Maybe Text) -> Parser ThingTypeDefinition
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
"thingTypeArn")
      )

instance Prelude.Hashable ThingTypeDefinition

instance Prelude.NFData ThingTypeDefinition