{-# 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.IoTAnalytics.Types.SchemaDefinition
-- 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.IoTAnalytics.Types.SchemaDefinition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTAnalytics.Types.Column
import qualified Amazonka.Prelude as Prelude

-- | Information needed to define a schema.
--
-- /See:/ 'newSchemaDefinition' smart constructor.
data SchemaDefinition = SchemaDefinition'
  { -- | Specifies one or more columns that store your data.
    --
    -- Each schema can have up to 100 columns. Each column can have up to 100
    -- nested types.
    SchemaDefinition -> Maybe [Column]
columns :: Prelude.Maybe [Column]
  }
  deriving (SchemaDefinition -> SchemaDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SchemaDefinition -> SchemaDefinition -> Bool
$c/= :: SchemaDefinition -> SchemaDefinition -> Bool
== :: SchemaDefinition -> SchemaDefinition -> Bool
$c== :: SchemaDefinition -> SchemaDefinition -> Bool
Prelude.Eq, ReadPrec [SchemaDefinition]
ReadPrec SchemaDefinition
Int -> ReadS SchemaDefinition
ReadS [SchemaDefinition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SchemaDefinition]
$creadListPrec :: ReadPrec [SchemaDefinition]
readPrec :: ReadPrec SchemaDefinition
$creadPrec :: ReadPrec SchemaDefinition
readList :: ReadS [SchemaDefinition]
$creadList :: ReadS [SchemaDefinition]
readsPrec :: Int -> ReadS SchemaDefinition
$creadsPrec :: Int -> ReadS SchemaDefinition
Prelude.Read, Int -> SchemaDefinition -> ShowS
[SchemaDefinition] -> ShowS
SchemaDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SchemaDefinition] -> ShowS
$cshowList :: [SchemaDefinition] -> ShowS
show :: SchemaDefinition -> String
$cshow :: SchemaDefinition -> String
showsPrec :: Int -> SchemaDefinition -> ShowS
$cshowsPrec :: Int -> SchemaDefinition -> ShowS
Prelude.Show, forall x. Rep SchemaDefinition x -> SchemaDefinition
forall x. SchemaDefinition -> Rep SchemaDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SchemaDefinition x -> SchemaDefinition
$cfrom :: forall x. SchemaDefinition -> Rep SchemaDefinition x
Prelude.Generic)

-- |
-- Create a value of 'SchemaDefinition' 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:
--
-- 'columns', 'schemaDefinition_columns' - Specifies one or more columns that store your data.
--
-- Each schema can have up to 100 columns. Each column can have up to 100
-- nested types.
newSchemaDefinition ::
  SchemaDefinition
newSchemaDefinition :: SchemaDefinition
newSchemaDefinition =
  SchemaDefinition' {$sel:columns:SchemaDefinition' :: Maybe [Column]
columns = forall a. Maybe a
Prelude.Nothing}

-- | Specifies one or more columns that store your data.
--
-- Each schema can have up to 100 columns. Each column can have up to 100
-- nested types.
schemaDefinition_columns :: Lens.Lens' SchemaDefinition (Prelude.Maybe [Column])
schemaDefinition_columns :: Lens' SchemaDefinition (Maybe [Column])
schemaDefinition_columns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SchemaDefinition' {Maybe [Column]
columns :: Maybe [Column]
$sel:columns:SchemaDefinition' :: SchemaDefinition -> Maybe [Column]
columns} -> Maybe [Column]
columns) (\s :: SchemaDefinition
s@SchemaDefinition' {} Maybe [Column]
a -> SchemaDefinition
s {$sel:columns:SchemaDefinition' :: Maybe [Column]
columns = Maybe [Column]
a} :: SchemaDefinition) 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 SchemaDefinition where
  parseJSON :: Value -> Parser SchemaDefinition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SchemaDefinition"
      ( \Object
x ->
          Maybe [Column] -> SchemaDefinition
SchemaDefinition'
            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
"columns" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SchemaDefinition where
  hashWithSalt :: Int -> SchemaDefinition -> Int
hashWithSalt Int
_salt SchemaDefinition' {Maybe [Column]
columns :: Maybe [Column]
$sel:columns:SchemaDefinition' :: SchemaDefinition -> Maybe [Column]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Column]
columns

instance Prelude.NFData SchemaDefinition where
  rnf :: SchemaDefinition -> ()
rnf SchemaDefinition' {Maybe [Column]
columns :: Maybe [Column]
$sel:columns:SchemaDefinition' :: SchemaDefinition -> Maybe [Column]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [Column]
columns

instance Data.ToJSON SchemaDefinition where
  toJSON :: SchemaDefinition -> Value
toJSON SchemaDefinition' {Maybe [Column]
columns :: Maybe [Column]
$sel:columns:SchemaDefinition' :: SchemaDefinition -> Maybe [Column]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"columns" 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 [Column]
columns]
      )