{-# 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 #-}
module Amazonka.Forecast.Types.SchemaAttribute where
import qualified Amazonka.Core as Core
import Amazonka.Forecast.Types.AttributeType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data SchemaAttribute = SchemaAttribute'
{
SchemaAttribute -> Maybe AttributeType
attributeType :: Prelude.Maybe AttributeType,
SchemaAttribute -> Maybe Text
attributeName :: Prelude.Maybe Prelude.Text
}
deriving (SchemaAttribute -> SchemaAttribute -> Bool
(SchemaAttribute -> SchemaAttribute -> Bool)
-> (SchemaAttribute -> SchemaAttribute -> Bool)
-> Eq SchemaAttribute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaAttribute -> SchemaAttribute -> Bool
$c/= :: SchemaAttribute -> SchemaAttribute -> Bool
== :: SchemaAttribute -> SchemaAttribute -> Bool
$c== :: SchemaAttribute -> SchemaAttribute -> Bool
Prelude.Eq, ReadPrec [SchemaAttribute]
ReadPrec SchemaAttribute
Int -> ReadS SchemaAttribute
ReadS [SchemaAttribute]
(Int -> ReadS SchemaAttribute)
-> ReadS [SchemaAttribute]
-> ReadPrec SchemaAttribute
-> ReadPrec [SchemaAttribute]
-> Read SchemaAttribute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchemaAttribute]
$creadListPrec :: ReadPrec [SchemaAttribute]
readPrec :: ReadPrec SchemaAttribute
$creadPrec :: ReadPrec SchemaAttribute
readList :: ReadS [SchemaAttribute]
$creadList :: ReadS [SchemaAttribute]
readsPrec :: Int -> ReadS SchemaAttribute
$creadsPrec :: Int -> ReadS SchemaAttribute
Prelude.Read, Int -> SchemaAttribute -> ShowS
[SchemaAttribute] -> ShowS
SchemaAttribute -> String
(Int -> SchemaAttribute -> ShowS)
-> (SchemaAttribute -> String)
-> ([SchemaAttribute] -> ShowS)
-> Show SchemaAttribute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaAttribute] -> ShowS
$cshowList :: [SchemaAttribute] -> ShowS
show :: SchemaAttribute -> String
$cshow :: SchemaAttribute -> String
showsPrec :: Int -> SchemaAttribute -> ShowS
$cshowsPrec :: Int -> SchemaAttribute -> ShowS
Prelude.Show, (forall x. SchemaAttribute -> Rep SchemaAttribute x)
-> (forall x. Rep SchemaAttribute x -> SchemaAttribute)
-> Generic SchemaAttribute
forall x. Rep SchemaAttribute x -> SchemaAttribute
forall x. SchemaAttribute -> Rep SchemaAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SchemaAttribute x -> SchemaAttribute
$cfrom :: forall x. SchemaAttribute -> Rep SchemaAttribute x
Prelude.Generic)
newSchemaAttribute ::
SchemaAttribute
newSchemaAttribute :: SchemaAttribute
newSchemaAttribute =
SchemaAttribute' :: Maybe AttributeType -> Maybe Text -> SchemaAttribute
SchemaAttribute'
{ $sel:attributeType:SchemaAttribute' :: Maybe AttributeType
attributeType = Maybe AttributeType
forall a. Maybe a
Prelude.Nothing,
$sel:attributeName:SchemaAttribute' :: Maybe Text
attributeName = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
schemaAttribute_attributeType :: Lens.Lens' SchemaAttribute (Prelude.Maybe AttributeType)
schemaAttribute_attributeType :: (Maybe AttributeType -> f (Maybe AttributeType))
-> SchemaAttribute -> f SchemaAttribute
schemaAttribute_attributeType = (SchemaAttribute -> Maybe AttributeType)
-> (SchemaAttribute -> Maybe AttributeType -> SchemaAttribute)
-> Lens
SchemaAttribute
SchemaAttribute
(Maybe AttributeType)
(Maybe AttributeType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaAttribute' {Maybe AttributeType
attributeType :: Maybe AttributeType
$sel:attributeType:SchemaAttribute' :: SchemaAttribute -> Maybe AttributeType
attributeType} -> Maybe AttributeType
attributeType) (\s :: SchemaAttribute
s@SchemaAttribute' {} Maybe AttributeType
a -> SchemaAttribute
s {$sel:attributeType:SchemaAttribute' :: Maybe AttributeType
attributeType = Maybe AttributeType
a} :: SchemaAttribute)
schemaAttribute_attributeName :: Lens.Lens' SchemaAttribute (Prelude.Maybe Prelude.Text)
schemaAttribute_attributeName :: (Maybe Text -> f (Maybe Text))
-> SchemaAttribute -> f SchemaAttribute
schemaAttribute_attributeName = (SchemaAttribute -> Maybe Text)
-> (SchemaAttribute -> Maybe Text -> SchemaAttribute)
-> Lens SchemaAttribute SchemaAttribute (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaAttribute' {Maybe Text
attributeName :: Maybe Text
$sel:attributeName:SchemaAttribute' :: SchemaAttribute -> Maybe Text
attributeName} -> Maybe Text
attributeName) (\s :: SchemaAttribute
s@SchemaAttribute' {} Maybe Text
a -> SchemaAttribute
s {$sel:attributeName:SchemaAttribute' :: Maybe Text
attributeName = Maybe Text
a} :: SchemaAttribute)
instance Core.FromJSON SchemaAttribute where
parseJSON :: Value -> Parser SchemaAttribute
parseJSON =
String
-> (Object -> Parser SchemaAttribute)
-> Value
-> Parser SchemaAttribute
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"SchemaAttribute"
( \Object
x ->
Maybe AttributeType -> Maybe Text -> SchemaAttribute
SchemaAttribute'
(Maybe AttributeType -> Maybe Text -> SchemaAttribute)
-> Parser (Maybe AttributeType)
-> Parser (Maybe Text -> SchemaAttribute)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AttributeType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AttributeType")
Parser (Maybe Text -> SchemaAttribute)
-> Parser (Maybe Text) -> Parser SchemaAttribute
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
"AttributeName")
)
instance Prelude.Hashable SchemaAttribute
instance Prelude.NFData SchemaAttribute
instance Core.ToJSON SchemaAttribute where
toJSON :: SchemaAttribute -> Value
toJSON SchemaAttribute' {Maybe Text
Maybe AttributeType
attributeName :: Maybe Text
attributeType :: Maybe AttributeType
$sel:attributeName:SchemaAttribute' :: SchemaAttribute -> Maybe Text
$sel:attributeType:SchemaAttribute' :: SchemaAttribute -> Maybe AttributeType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"AttributeType" Text -> AttributeType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AttributeType -> Pair) -> Maybe AttributeType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AttributeType
attributeType,
(Text
"AttributeName" 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
attributeName
]
)