{-# 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.AppSync.Types.Type
-- 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.AppSync.Types.Type where

import Amazonka.AppSync.Types.TypeDefinitionFormat
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

-- | Describes a type.
--
-- /See:/ 'newType' smart constructor.
data Type = Type'
  { -- | The type Amazon Resource Name (ARN).
    Type -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The type definition.
    Type -> Maybe Text
definition :: Prelude.Maybe Prelude.Text,
    -- | The type description.
    Type -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The type format: SDL or JSON.
    Type -> Maybe TypeDefinitionFormat
format :: Prelude.Maybe TypeDefinitionFormat,
    -- | The type name.
    Type -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (Type -> Type -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Type -> Type -> Bool
$c/= :: Type -> Type -> Bool
== :: Type -> Type -> Bool
$c== :: Type -> Type -> Bool
Prelude.Eq, ReadPrec [Type]
ReadPrec Type
Int -> ReadS Type
ReadS [Type]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Type]
$creadListPrec :: ReadPrec [Type]
readPrec :: ReadPrec Type
$creadPrec :: ReadPrec Type
readList :: ReadS [Type]
$creadList :: ReadS [Type]
readsPrec :: Int -> ReadS Type
$creadsPrec :: Int -> ReadS Type
Prelude.Read, Int -> Type -> ShowS
[Type] -> ShowS
Type -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Type] -> ShowS
$cshowList :: [Type] -> ShowS
show :: Type -> String
$cshow :: Type -> String
showsPrec :: Int -> Type -> ShowS
$cshowsPrec :: Int -> Type -> ShowS
Prelude.Show, forall x. Rep Type x -> Type
forall x. Type -> Rep Type x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Type x -> Type
$cfrom :: forall x. Type -> Rep Type x
Prelude.Generic)

-- |
-- Create a value of 'Type' 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:
--
-- 'arn', 'type_arn' - The type Amazon Resource Name (ARN).
--
-- 'definition', 'type_definition' - The type definition.
--
-- 'description', 'type_description' - The type description.
--
-- 'format', 'type_format' - The type format: SDL or JSON.
--
-- 'name', 'type_name' - The type name.
newType ::
  Type
newType :: Type
newType =
  Type'
    { $sel:arn:Type' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:definition:Type' :: Maybe Text
definition = forall a. Maybe a
Prelude.Nothing,
      $sel:description:Type' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:format:Type' :: Maybe TypeDefinitionFormat
format = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Type' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | The type Amazon Resource Name (ARN).
type_arn :: Lens.Lens' Type (Prelude.Maybe Prelude.Text)
type_arn :: Lens' Type (Maybe Text)
type_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Type' {Maybe Text
arn :: Maybe Text
$sel:arn:Type' :: Type -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Type
s@Type' {} Maybe Text
a -> Type
s {$sel:arn:Type' :: Maybe Text
arn = Maybe Text
a} :: Type)

-- | The type definition.
type_definition :: Lens.Lens' Type (Prelude.Maybe Prelude.Text)
type_definition :: Lens' Type (Maybe Text)
type_definition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Type' {Maybe Text
definition :: Maybe Text
$sel:definition:Type' :: Type -> Maybe Text
definition} -> Maybe Text
definition) (\s :: Type
s@Type' {} Maybe Text
a -> Type
s {$sel:definition:Type' :: Maybe Text
definition = Maybe Text
a} :: Type)

-- | The type description.
type_description :: Lens.Lens' Type (Prelude.Maybe Prelude.Text)
type_description :: Lens' Type (Maybe Text)
type_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Type' {Maybe Text
description :: Maybe Text
$sel:description:Type' :: Type -> Maybe Text
description} -> Maybe Text
description) (\s :: Type
s@Type' {} Maybe Text
a -> Type
s {$sel:description:Type' :: Maybe Text
description = Maybe Text
a} :: Type)

-- | The type format: SDL or JSON.
type_format :: Lens.Lens' Type (Prelude.Maybe TypeDefinitionFormat)
type_format :: Lens' Type (Maybe TypeDefinitionFormat)
type_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Type' {Maybe TypeDefinitionFormat
format :: Maybe TypeDefinitionFormat
$sel:format:Type' :: Type -> Maybe TypeDefinitionFormat
format} -> Maybe TypeDefinitionFormat
format) (\s :: Type
s@Type' {} Maybe TypeDefinitionFormat
a -> Type
s {$sel:format:Type' :: Maybe TypeDefinitionFormat
format = Maybe TypeDefinitionFormat
a} :: Type)

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

instance Data.FromJSON Type where
  parseJSON :: Value -> Parser Type
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Type"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe TypeDefinitionFormat
-> Maybe Text
-> Type
Type'
            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
"arn")
            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
"definition")
            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
"description")
            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
"format")
            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
"name")
      )

instance Prelude.Hashable Type where
  hashWithSalt :: Int -> Type -> Int
hashWithSalt Int
_salt Type' {Maybe Text
Maybe TypeDefinitionFormat
name :: Maybe Text
format :: Maybe TypeDefinitionFormat
description :: Maybe Text
definition :: Maybe Text
arn :: Maybe Text
$sel:name:Type' :: Type -> Maybe Text
$sel:format:Type' :: Type -> Maybe TypeDefinitionFormat
$sel:description:Type' :: Type -> Maybe Text
$sel:definition:Type' :: Type -> Maybe Text
$sel:arn:Type' :: Type -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
definition
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TypeDefinitionFormat
format
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData Type where
  rnf :: Type -> ()
rnf Type' {Maybe Text
Maybe TypeDefinitionFormat
name :: Maybe Text
format :: Maybe TypeDefinitionFormat
description :: Maybe Text
definition :: Maybe Text
arn :: Maybe Text
$sel:name:Type' :: Type -> Maybe Text
$sel:format:Type' :: Type -> Maybe TypeDefinitionFormat
$sel:description:Type' :: Type -> Maybe Text
$sel:definition:Type' :: Type -> Maybe Text
$sel:arn:Type' :: Type -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
definition
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TypeDefinitionFormat
format
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name