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

import Amazonka.AppSync.Types.TypeDefinitionFormat
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a type.
--
-- /See:/ 'newType' smart constructor.
data Type = Type'
  { -- | The type ARN.
    Type -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The type definition.
    Type -> Maybe Text
definition :: 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,
    -- | The type description.
    Type -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (Type -> Type -> Bool
(Type -> Type -> Bool) -> (Type -> Type -> Bool) -> Eq Type
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]
(Int -> ReadS Type)
-> ReadS [Type] -> ReadPrec Type -> ReadPrec [Type] -> Read 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
(Int -> Type -> ShowS)
-> (Type -> String) -> ([Type] -> ShowS) -> Show Type
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. Type -> Rep Type x)
-> (forall x. Rep Type x -> Type) -> Generic Type
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 ARN.
--
-- 'definition', 'type_definition' - The type definition.
--
-- 'format', 'type_format' - The type format: SDL or JSON.
--
-- 'name', 'type_name' - The type name.
--
-- 'description', 'type_description' - The type description.
newType ::
  Type
newType :: Type
newType =
  Type' :: Maybe Text
-> Maybe Text
-> Maybe TypeDefinitionFormat
-> Maybe Text
-> Maybe Text
-> Type
Type'
    { $sel:arn:Type' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:definition:Type' :: Maybe Text
definition = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:format:Type' :: Maybe TypeDefinitionFormat
format = Maybe TypeDefinitionFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Type' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Type' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type ARN.
type_arn :: Lens.Lens' Type (Prelude.Maybe Prelude.Text)
type_arn :: (Maybe Text -> f (Maybe Text)) -> Type -> f Type
type_arn = (Type -> Maybe Text)
-> (Type -> Maybe Text -> Type)
-> Lens Type Type (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> Type -> f Type
type_definition = (Type -> Maybe Text)
-> (Type -> Maybe Text -> Type)
-> Lens Type Type (Maybe Text) (Maybe Text)
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 format: SDL or JSON.
type_format :: Lens.Lens' Type (Prelude.Maybe TypeDefinitionFormat)
type_format :: (Maybe TypeDefinitionFormat -> f (Maybe TypeDefinitionFormat))
-> Type -> f Type
type_format = (Type -> Maybe TypeDefinitionFormat)
-> (Type -> Maybe TypeDefinitionFormat -> Type)
-> Lens
     Type Type (Maybe TypeDefinitionFormat) (Maybe TypeDefinitionFormat)
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 :: (Maybe Text -> f (Maybe Text)) -> Type -> f Type
type_name = (Type -> Maybe Text)
-> (Type -> Maybe Text -> Type)
-> Lens Type Type (Maybe Text) (Maybe Text)
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)

-- | The type description.
type_description :: Lens.Lens' Type (Prelude.Maybe Prelude.Text)
type_description :: (Maybe Text -> f (Maybe Text)) -> Type -> f Type
type_description = (Type -> Maybe Text)
-> (Type -> Maybe Text -> Type)
-> Lens Type Type (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable Type

instance Prelude.NFData Type