{-# 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.CognitoIdentityProvider.Types.SchemaAttributeType
-- 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.CognitoIdentityProvider.Types.SchemaAttributeType where

import Amazonka.CognitoIdentityProvider.Types.AttributeDataType
import Amazonka.CognitoIdentityProvider.Types.NumberAttributeConstraintsType
import Amazonka.CognitoIdentityProvider.Types.StringAttributeConstraintsType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the schema attribute.
--
-- /See:/ 'newSchemaAttributeType' smart constructor.
data SchemaAttributeType = SchemaAttributeType'
  { -- | Specifies the constraints for an attribute of the number type.
    SchemaAttributeType -> Maybe NumberAttributeConstraintsType
numberAttributeConstraints :: Prelude.Maybe NumberAttributeConstraintsType,
    -- | Specifies whether a user pool attribute is required. If the attribute is
    -- required and the user does not provide a value, registration or sign-in
    -- will fail.
    SchemaAttributeType -> Maybe Bool
required :: Prelude.Maybe Prelude.Bool,
    -- | The attribute data type.
    SchemaAttributeType -> Maybe AttributeDataType
attributeDataType :: Prelude.Maybe AttributeDataType,
    -- | Specifies the constraints for an attribute of the string type.
    SchemaAttributeType -> Maybe StringAttributeConstraintsType
stringAttributeConstraints :: Prelude.Maybe StringAttributeConstraintsType,
    -- | A schema attribute of the name type.
    SchemaAttributeType -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | We recommend that you use
    -- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UserPoolClientType.html#CognitoUserPools-Type-UserPoolClientType-WriteAttributes WriteAttributes>
    -- in the user pool client to control how attributes can be mutated for new
    -- use cases instead of using @DeveloperOnlyAttribute@.
    --
    -- Specifies whether the attribute type is developer only. This attribute
    -- can only be modified by an administrator. Users will not be able to
    -- modify this attribute using their access token. For example,
    -- @DeveloperOnlyAttribute@ can be modified using AdminUpdateUserAttributes
    -- but cannot be updated using UpdateUserAttributes.
    SchemaAttributeType -> Maybe Bool
developerOnlyAttribute :: Prelude.Maybe Prelude.Bool,
    -- | Specifies whether the value of the attribute can be changed.
    --
    -- For any user pool attribute that\'s mapped to an identity provider
    -- attribute, you must set this parameter to @true@. Amazon Cognito updates
    -- mapped attributes when users sign in to your application through an
    -- identity provider. If an attribute is immutable, Amazon Cognito throws
    -- an error when it attempts to update the attribute. For more information,
    -- see
    -- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-specifying-attribute-mapping.html Specifying Identity Provider Attribute Mappings for Your User Pool>.
    SchemaAttributeType -> Maybe Bool
mutable :: Prelude.Maybe Prelude.Bool
  }
  deriving (SchemaAttributeType -> SchemaAttributeType -> Bool
(SchemaAttributeType -> SchemaAttributeType -> Bool)
-> (SchemaAttributeType -> SchemaAttributeType -> Bool)
-> Eq SchemaAttributeType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaAttributeType -> SchemaAttributeType -> Bool
$c/= :: SchemaAttributeType -> SchemaAttributeType -> Bool
== :: SchemaAttributeType -> SchemaAttributeType -> Bool
$c== :: SchemaAttributeType -> SchemaAttributeType -> Bool
Prelude.Eq, ReadPrec [SchemaAttributeType]
ReadPrec SchemaAttributeType
Int -> ReadS SchemaAttributeType
ReadS [SchemaAttributeType]
(Int -> ReadS SchemaAttributeType)
-> ReadS [SchemaAttributeType]
-> ReadPrec SchemaAttributeType
-> ReadPrec [SchemaAttributeType]
-> Read SchemaAttributeType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchemaAttributeType]
$creadListPrec :: ReadPrec [SchemaAttributeType]
readPrec :: ReadPrec SchemaAttributeType
$creadPrec :: ReadPrec SchemaAttributeType
readList :: ReadS [SchemaAttributeType]
$creadList :: ReadS [SchemaAttributeType]
readsPrec :: Int -> ReadS SchemaAttributeType
$creadsPrec :: Int -> ReadS SchemaAttributeType
Prelude.Read, Int -> SchemaAttributeType -> ShowS
[SchemaAttributeType] -> ShowS
SchemaAttributeType -> String
(Int -> SchemaAttributeType -> ShowS)
-> (SchemaAttributeType -> String)
-> ([SchemaAttributeType] -> ShowS)
-> Show SchemaAttributeType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaAttributeType] -> ShowS
$cshowList :: [SchemaAttributeType] -> ShowS
show :: SchemaAttributeType -> String
$cshow :: SchemaAttributeType -> String
showsPrec :: Int -> SchemaAttributeType -> ShowS
$cshowsPrec :: Int -> SchemaAttributeType -> ShowS
Prelude.Show, (forall x. SchemaAttributeType -> Rep SchemaAttributeType x)
-> (forall x. Rep SchemaAttributeType x -> SchemaAttributeType)
-> Generic SchemaAttributeType
forall x. Rep SchemaAttributeType x -> SchemaAttributeType
forall x. SchemaAttributeType -> Rep SchemaAttributeType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SchemaAttributeType x -> SchemaAttributeType
$cfrom :: forall x. SchemaAttributeType -> Rep SchemaAttributeType x
Prelude.Generic)

-- |
-- Create a value of 'SchemaAttributeType' 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:
--
-- 'numberAttributeConstraints', 'schemaAttributeType_numberAttributeConstraints' - Specifies the constraints for an attribute of the number type.
--
-- 'required', 'schemaAttributeType_required' - Specifies whether a user pool attribute is required. If the attribute is
-- required and the user does not provide a value, registration or sign-in
-- will fail.
--
-- 'attributeDataType', 'schemaAttributeType_attributeDataType' - The attribute data type.
--
-- 'stringAttributeConstraints', 'schemaAttributeType_stringAttributeConstraints' - Specifies the constraints for an attribute of the string type.
--
-- 'name', 'schemaAttributeType_name' - A schema attribute of the name type.
--
-- 'developerOnlyAttribute', 'schemaAttributeType_developerOnlyAttribute' - We recommend that you use
-- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UserPoolClientType.html#CognitoUserPools-Type-UserPoolClientType-WriteAttributes WriteAttributes>
-- in the user pool client to control how attributes can be mutated for new
-- use cases instead of using @DeveloperOnlyAttribute@.
--
-- Specifies whether the attribute type is developer only. This attribute
-- can only be modified by an administrator. Users will not be able to
-- modify this attribute using their access token. For example,
-- @DeveloperOnlyAttribute@ can be modified using AdminUpdateUserAttributes
-- but cannot be updated using UpdateUserAttributes.
--
-- 'mutable', 'schemaAttributeType_mutable' - Specifies whether the value of the attribute can be changed.
--
-- For any user pool attribute that\'s mapped to an identity provider
-- attribute, you must set this parameter to @true@. Amazon Cognito updates
-- mapped attributes when users sign in to your application through an
-- identity provider. If an attribute is immutable, Amazon Cognito throws
-- an error when it attempts to update the attribute. For more information,
-- see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-specifying-attribute-mapping.html Specifying Identity Provider Attribute Mappings for Your User Pool>.
newSchemaAttributeType ::
  SchemaAttributeType
newSchemaAttributeType :: SchemaAttributeType
newSchemaAttributeType =
  SchemaAttributeType' :: Maybe NumberAttributeConstraintsType
-> Maybe Bool
-> Maybe AttributeDataType
-> Maybe StringAttributeConstraintsType
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> SchemaAttributeType
SchemaAttributeType'
    { $sel:numberAttributeConstraints:SchemaAttributeType' :: Maybe NumberAttributeConstraintsType
numberAttributeConstraints =
        Maybe NumberAttributeConstraintsType
forall a. Maybe a
Prelude.Nothing,
      $sel:required:SchemaAttributeType' :: Maybe Bool
required = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeDataType:SchemaAttributeType' :: Maybe AttributeDataType
attributeDataType = Maybe AttributeDataType
forall a. Maybe a
Prelude.Nothing,
      $sel:stringAttributeConstraints:SchemaAttributeType' :: Maybe StringAttributeConstraintsType
stringAttributeConstraints = Maybe StringAttributeConstraintsType
forall a. Maybe a
Prelude.Nothing,
      $sel:name:SchemaAttributeType' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:developerOnlyAttribute:SchemaAttributeType' :: Maybe Bool
developerOnlyAttribute = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:mutable:SchemaAttributeType' :: Maybe Bool
mutable = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the constraints for an attribute of the number type.
schemaAttributeType_numberAttributeConstraints :: Lens.Lens' SchemaAttributeType (Prelude.Maybe NumberAttributeConstraintsType)
schemaAttributeType_numberAttributeConstraints :: (Maybe NumberAttributeConstraintsType
 -> f (Maybe NumberAttributeConstraintsType))
-> SchemaAttributeType -> f SchemaAttributeType
schemaAttributeType_numberAttributeConstraints = (SchemaAttributeType -> Maybe NumberAttributeConstraintsType)
-> (SchemaAttributeType
    -> Maybe NumberAttributeConstraintsType -> SchemaAttributeType)
-> Lens
     SchemaAttributeType
     SchemaAttributeType
     (Maybe NumberAttributeConstraintsType)
     (Maybe NumberAttributeConstraintsType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaAttributeType' {Maybe NumberAttributeConstraintsType
numberAttributeConstraints :: Maybe NumberAttributeConstraintsType
$sel:numberAttributeConstraints:SchemaAttributeType' :: SchemaAttributeType -> Maybe NumberAttributeConstraintsType
numberAttributeConstraints} -> Maybe NumberAttributeConstraintsType
numberAttributeConstraints) (\s :: SchemaAttributeType
s@SchemaAttributeType' {} Maybe NumberAttributeConstraintsType
a -> SchemaAttributeType
s {$sel:numberAttributeConstraints:SchemaAttributeType' :: Maybe NumberAttributeConstraintsType
numberAttributeConstraints = Maybe NumberAttributeConstraintsType
a} :: SchemaAttributeType)

-- | Specifies whether a user pool attribute is required. If the attribute is
-- required and the user does not provide a value, registration or sign-in
-- will fail.
schemaAttributeType_required :: Lens.Lens' SchemaAttributeType (Prelude.Maybe Prelude.Bool)
schemaAttributeType_required :: (Maybe Bool -> f (Maybe Bool))
-> SchemaAttributeType -> f SchemaAttributeType
schemaAttributeType_required = (SchemaAttributeType -> Maybe Bool)
-> (SchemaAttributeType -> Maybe Bool -> SchemaAttributeType)
-> Lens
     SchemaAttributeType SchemaAttributeType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaAttributeType' {Maybe Bool
required :: Maybe Bool
$sel:required:SchemaAttributeType' :: SchemaAttributeType -> Maybe Bool
required} -> Maybe Bool
required) (\s :: SchemaAttributeType
s@SchemaAttributeType' {} Maybe Bool
a -> SchemaAttributeType
s {$sel:required:SchemaAttributeType' :: Maybe Bool
required = Maybe Bool
a} :: SchemaAttributeType)

-- | The attribute data type.
schemaAttributeType_attributeDataType :: Lens.Lens' SchemaAttributeType (Prelude.Maybe AttributeDataType)
schemaAttributeType_attributeDataType :: (Maybe AttributeDataType -> f (Maybe AttributeDataType))
-> SchemaAttributeType -> f SchemaAttributeType
schemaAttributeType_attributeDataType = (SchemaAttributeType -> Maybe AttributeDataType)
-> (SchemaAttributeType
    -> Maybe AttributeDataType -> SchemaAttributeType)
-> Lens
     SchemaAttributeType
     SchemaAttributeType
     (Maybe AttributeDataType)
     (Maybe AttributeDataType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaAttributeType' {Maybe AttributeDataType
attributeDataType :: Maybe AttributeDataType
$sel:attributeDataType:SchemaAttributeType' :: SchemaAttributeType -> Maybe AttributeDataType
attributeDataType} -> Maybe AttributeDataType
attributeDataType) (\s :: SchemaAttributeType
s@SchemaAttributeType' {} Maybe AttributeDataType
a -> SchemaAttributeType
s {$sel:attributeDataType:SchemaAttributeType' :: Maybe AttributeDataType
attributeDataType = Maybe AttributeDataType
a} :: SchemaAttributeType)

-- | Specifies the constraints for an attribute of the string type.
schemaAttributeType_stringAttributeConstraints :: Lens.Lens' SchemaAttributeType (Prelude.Maybe StringAttributeConstraintsType)
schemaAttributeType_stringAttributeConstraints :: (Maybe StringAttributeConstraintsType
 -> f (Maybe StringAttributeConstraintsType))
-> SchemaAttributeType -> f SchemaAttributeType
schemaAttributeType_stringAttributeConstraints = (SchemaAttributeType -> Maybe StringAttributeConstraintsType)
-> (SchemaAttributeType
    -> Maybe StringAttributeConstraintsType -> SchemaAttributeType)
-> Lens
     SchemaAttributeType
     SchemaAttributeType
     (Maybe StringAttributeConstraintsType)
     (Maybe StringAttributeConstraintsType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaAttributeType' {Maybe StringAttributeConstraintsType
stringAttributeConstraints :: Maybe StringAttributeConstraintsType
$sel:stringAttributeConstraints:SchemaAttributeType' :: SchemaAttributeType -> Maybe StringAttributeConstraintsType
stringAttributeConstraints} -> Maybe StringAttributeConstraintsType
stringAttributeConstraints) (\s :: SchemaAttributeType
s@SchemaAttributeType' {} Maybe StringAttributeConstraintsType
a -> SchemaAttributeType
s {$sel:stringAttributeConstraints:SchemaAttributeType' :: Maybe StringAttributeConstraintsType
stringAttributeConstraints = Maybe StringAttributeConstraintsType
a} :: SchemaAttributeType)

-- | A schema attribute of the name type.
schemaAttributeType_name :: Lens.Lens' SchemaAttributeType (Prelude.Maybe Prelude.Text)
schemaAttributeType_name :: (Maybe Text -> f (Maybe Text))
-> SchemaAttributeType -> f SchemaAttributeType
schemaAttributeType_name = (SchemaAttributeType -> Maybe Text)
-> (SchemaAttributeType -> Maybe Text -> SchemaAttributeType)
-> Lens
     SchemaAttributeType SchemaAttributeType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaAttributeType' {Maybe Text
name :: Maybe Text
$sel:name:SchemaAttributeType' :: SchemaAttributeType -> Maybe Text
name} -> Maybe Text
name) (\s :: SchemaAttributeType
s@SchemaAttributeType' {} Maybe Text
a -> SchemaAttributeType
s {$sel:name:SchemaAttributeType' :: Maybe Text
name = Maybe Text
a} :: SchemaAttributeType)

-- | We recommend that you use
-- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_UserPoolClientType.html#CognitoUserPools-Type-UserPoolClientType-WriteAttributes WriteAttributes>
-- in the user pool client to control how attributes can be mutated for new
-- use cases instead of using @DeveloperOnlyAttribute@.
--
-- Specifies whether the attribute type is developer only. This attribute
-- can only be modified by an administrator. Users will not be able to
-- modify this attribute using their access token. For example,
-- @DeveloperOnlyAttribute@ can be modified using AdminUpdateUserAttributes
-- but cannot be updated using UpdateUserAttributes.
schemaAttributeType_developerOnlyAttribute :: Lens.Lens' SchemaAttributeType (Prelude.Maybe Prelude.Bool)
schemaAttributeType_developerOnlyAttribute :: (Maybe Bool -> f (Maybe Bool))
-> SchemaAttributeType -> f SchemaAttributeType
schemaAttributeType_developerOnlyAttribute = (SchemaAttributeType -> Maybe Bool)
-> (SchemaAttributeType -> Maybe Bool -> SchemaAttributeType)
-> Lens
     SchemaAttributeType SchemaAttributeType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaAttributeType' {Maybe Bool
developerOnlyAttribute :: Maybe Bool
$sel:developerOnlyAttribute:SchemaAttributeType' :: SchemaAttributeType -> Maybe Bool
developerOnlyAttribute} -> Maybe Bool
developerOnlyAttribute) (\s :: SchemaAttributeType
s@SchemaAttributeType' {} Maybe Bool
a -> SchemaAttributeType
s {$sel:developerOnlyAttribute:SchemaAttributeType' :: Maybe Bool
developerOnlyAttribute = Maybe Bool
a} :: SchemaAttributeType)

-- | Specifies whether the value of the attribute can be changed.
--
-- For any user pool attribute that\'s mapped to an identity provider
-- attribute, you must set this parameter to @true@. Amazon Cognito updates
-- mapped attributes when users sign in to your application through an
-- identity provider. If an attribute is immutable, Amazon Cognito throws
-- an error when it attempts to update the attribute. For more information,
-- see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-specifying-attribute-mapping.html Specifying Identity Provider Attribute Mappings for Your User Pool>.
schemaAttributeType_mutable :: Lens.Lens' SchemaAttributeType (Prelude.Maybe Prelude.Bool)
schemaAttributeType_mutable :: (Maybe Bool -> f (Maybe Bool))
-> SchemaAttributeType -> f SchemaAttributeType
schemaAttributeType_mutable = (SchemaAttributeType -> Maybe Bool)
-> (SchemaAttributeType -> Maybe Bool -> SchemaAttributeType)
-> Lens
     SchemaAttributeType SchemaAttributeType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaAttributeType' {Maybe Bool
mutable :: Maybe Bool
$sel:mutable:SchemaAttributeType' :: SchemaAttributeType -> Maybe Bool
mutable} -> Maybe Bool
mutable) (\s :: SchemaAttributeType
s@SchemaAttributeType' {} Maybe Bool
a -> SchemaAttributeType
s {$sel:mutable:SchemaAttributeType' :: Maybe Bool
mutable = Maybe Bool
a} :: SchemaAttributeType)

instance Core.FromJSON SchemaAttributeType where
  parseJSON :: Value -> Parser SchemaAttributeType
parseJSON =
    String
-> (Object -> Parser SchemaAttributeType)
-> Value
-> Parser SchemaAttributeType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SchemaAttributeType"
      ( \Object
x ->
          Maybe NumberAttributeConstraintsType
-> Maybe Bool
-> Maybe AttributeDataType
-> Maybe StringAttributeConstraintsType
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> SchemaAttributeType
SchemaAttributeType'
            (Maybe NumberAttributeConstraintsType
 -> Maybe Bool
 -> Maybe AttributeDataType
 -> Maybe StringAttributeConstraintsType
 -> Maybe Text
 -> Maybe Bool
 -> Maybe Bool
 -> SchemaAttributeType)
-> Parser (Maybe NumberAttributeConstraintsType)
-> Parser
     (Maybe Bool
      -> Maybe AttributeDataType
      -> Maybe StringAttributeConstraintsType
      -> Maybe Text
      -> Maybe Bool
      -> Maybe Bool
      -> SchemaAttributeType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe NumberAttributeConstraintsType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NumberAttributeConstraints")
            Parser
  (Maybe Bool
   -> Maybe AttributeDataType
   -> Maybe StringAttributeConstraintsType
   -> Maybe Text
   -> Maybe Bool
   -> Maybe Bool
   -> SchemaAttributeType)
-> Parser (Maybe Bool)
-> Parser
     (Maybe AttributeDataType
      -> Maybe StringAttributeConstraintsType
      -> Maybe Text
      -> Maybe Bool
      -> Maybe Bool
      -> SchemaAttributeType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Required")
            Parser
  (Maybe AttributeDataType
   -> Maybe StringAttributeConstraintsType
   -> Maybe Text
   -> Maybe Bool
   -> Maybe Bool
   -> SchemaAttributeType)
-> Parser (Maybe AttributeDataType)
-> Parser
     (Maybe StringAttributeConstraintsType
      -> Maybe Text -> Maybe Bool -> Maybe Bool -> SchemaAttributeType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AttributeDataType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttributeDataType")
            Parser
  (Maybe StringAttributeConstraintsType
   -> Maybe Text -> Maybe Bool -> Maybe Bool -> SchemaAttributeType)
-> Parser (Maybe StringAttributeConstraintsType)
-> Parser
     (Maybe Text -> Maybe Bool -> Maybe Bool -> SchemaAttributeType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StringAttributeConstraintsType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StringAttributeConstraints")
            Parser
  (Maybe Text -> Maybe Bool -> Maybe Bool -> SchemaAttributeType)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> Maybe Bool -> SchemaAttributeType)
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 Bool -> Maybe Bool -> SchemaAttributeType)
-> Parser (Maybe Bool)
-> Parser (Maybe Bool -> SchemaAttributeType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeveloperOnlyAttribute")
            Parser (Maybe Bool -> SchemaAttributeType)
-> Parser (Maybe Bool) -> Parser SchemaAttributeType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Mutable")
      )

instance Prelude.Hashable SchemaAttributeType

instance Prelude.NFData SchemaAttributeType

instance Core.ToJSON SchemaAttributeType where
  toJSON :: SchemaAttributeType -> Value
toJSON SchemaAttributeType' {Maybe Bool
Maybe Text
Maybe AttributeDataType
Maybe NumberAttributeConstraintsType
Maybe StringAttributeConstraintsType
mutable :: Maybe Bool
developerOnlyAttribute :: Maybe Bool
name :: Maybe Text
stringAttributeConstraints :: Maybe StringAttributeConstraintsType
attributeDataType :: Maybe AttributeDataType
required :: Maybe Bool
numberAttributeConstraints :: Maybe NumberAttributeConstraintsType
$sel:mutable:SchemaAttributeType' :: SchemaAttributeType -> Maybe Bool
$sel:developerOnlyAttribute:SchemaAttributeType' :: SchemaAttributeType -> Maybe Bool
$sel:name:SchemaAttributeType' :: SchemaAttributeType -> Maybe Text
$sel:stringAttributeConstraints:SchemaAttributeType' :: SchemaAttributeType -> Maybe StringAttributeConstraintsType
$sel:attributeDataType:SchemaAttributeType' :: SchemaAttributeType -> Maybe AttributeDataType
$sel:required:SchemaAttributeType' :: SchemaAttributeType -> Maybe Bool
$sel:numberAttributeConstraints:SchemaAttributeType' :: SchemaAttributeType -> Maybe NumberAttributeConstraintsType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NumberAttributeConstraints" Text -> NumberAttributeConstraintsType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NumberAttributeConstraintsType -> Pair)
-> Maybe NumberAttributeConstraintsType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NumberAttributeConstraintsType
numberAttributeConstraints,
            (Text
"Required" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
required,
            (Text
"AttributeDataType" Text -> AttributeDataType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AttributeDataType -> Pair)
-> Maybe AttributeDataType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AttributeDataType
attributeDataType,
            (Text
"StringAttributeConstraints" Text -> StringAttributeConstraintsType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (StringAttributeConstraintsType -> Pair)
-> Maybe StringAttributeConstraintsType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StringAttributeConstraintsType
stringAttributeConstraints,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"DeveloperOnlyAttribute" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
developerOnlyAttribute,
            (Text
"Mutable" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
mutable
          ]
      )