{-# 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.Schema where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Forecast.Types.SchemaAttribute
import qualified Amazonka.Prelude as Prelude
data Schema = Schema'
{
Schema -> Maybe (NonEmpty SchemaAttribute)
attributes :: Prelude.Maybe (Prelude.NonEmpty SchemaAttribute)
}
deriving (Schema -> Schema -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Schema -> Schema -> Bool
$c/= :: Schema -> Schema -> Bool
== :: Schema -> Schema -> Bool
$c== :: Schema -> Schema -> Bool
Prelude.Eq, ReadPrec [Schema]
ReadPrec Schema
Int -> ReadS Schema
ReadS [Schema]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Schema]
$creadListPrec :: ReadPrec [Schema]
readPrec :: ReadPrec Schema
$creadPrec :: ReadPrec Schema
readList :: ReadS [Schema]
$creadList :: ReadS [Schema]
readsPrec :: Int -> ReadS Schema
$creadsPrec :: Int -> ReadS Schema
Prelude.Read, Int -> Schema -> ShowS
[Schema] -> ShowS
Schema -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Schema] -> ShowS
$cshowList :: [Schema] -> ShowS
show :: Schema -> String
$cshow :: Schema -> String
showsPrec :: Int -> Schema -> ShowS
$cshowsPrec :: Int -> Schema -> ShowS
Prelude.Show, forall x. Rep Schema x -> Schema
forall x. Schema -> Rep Schema x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Schema x -> Schema
$cfrom :: forall x. Schema -> Rep Schema x
Prelude.Generic)
newSchema ::
Schema
newSchema :: Schema
newSchema = Schema' {$sel:attributes:Schema' :: Maybe (NonEmpty SchemaAttribute)
attributes = forall a. Maybe a
Prelude.Nothing}
schema_attributes :: Lens.Lens' Schema (Prelude.Maybe (Prelude.NonEmpty SchemaAttribute))
schema_attributes :: Lens' Schema (Maybe (NonEmpty SchemaAttribute))
schema_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Schema' {Maybe (NonEmpty SchemaAttribute)
attributes :: Maybe (NonEmpty SchemaAttribute)
$sel:attributes:Schema' :: Schema -> Maybe (NonEmpty SchemaAttribute)
attributes} -> Maybe (NonEmpty SchemaAttribute)
attributes) (\s :: Schema
s@Schema' {} Maybe (NonEmpty SchemaAttribute)
a -> Schema
s {$sel:attributes:Schema' :: Maybe (NonEmpty SchemaAttribute)
attributes = Maybe (NonEmpty SchemaAttribute)
a} :: Schema) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Data.FromJSON Schema where
parseJSON :: Value -> Parser Schema
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"Schema"
( \Object
x ->
Maybe (NonEmpty SchemaAttribute) -> Schema
Schema' 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
"Attributes")
)
instance Prelude.Hashable Schema where
hashWithSalt :: Int -> Schema -> Int
hashWithSalt Int
_salt Schema' {Maybe (NonEmpty SchemaAttribute)
attributes :: Maybe (NonEmpty SchemaAttribute)
$sel:attributes:Schema' :: Schema -> Maybe (NonEmpty SchemaAttribute)
..} =
Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty SchemaAttribute)
attributes
instance Prelude.NFData Schema where
rnf :: Schema -> ()
rnf Schema' {Maybe (NonEmpty SchemaAttribute)
attributes :: Maybe (NonEmpty SchemaAttribute)
$sel:attributes:Schema' :: Schema -> Maybe (NonEmpty SchemaAttribute)
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty SchemaAttribute)
attributes
instance Data.ToJSON Schema where
toJSON :: Schema -> Value
toJSON Schema' {Maybe (NonEmpty SchemaAttribute)
attributes :: Maybe (NonEmpty SchemaAttribute)
$sel:attributes:Schema' :: Schema -> Maybe (NonEmpty SchemaAttribute)
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Key
"Attributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty SchemaAttribute)
attributes]
)