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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import {-# SOURCE #-} Amazonka.TimeStreamQuery.Types.ColumnInfo
import Amazonka.TimeStreamQuery.Types.ScalarType

-- | Contains the data type of a column in a query result set. The data type
-- can be scalar or complex. The supported scalar data types are integers,
-- Boolean, string, double, timestamp, date, time, and intervals. The
-- supported complex data types are arrays, rows, and timeseries.
--
-- /See:/ 'newType' smart constructor.
data Type = Type'
  { -- | Indicates if the column is an array.
    Type -> Maybe ColumnInfo
arrayColumnInfo :: Prelude.Maybe ColumnInfo,
    -- | Indicates if the column is a row.
    Type -> Maybe [ColumnInfo]
rowColumnInfo :: Prelude.Maybe [ColumnInfo],
    -- | Indicates if the column is of type string, integer, Boolean, double,
    -- timestamp, date, time.
    Type -> Maybe ScalarType
scalarType :: Prelude.Maybe ScalarType,
    -- | Indicates if the column is a timeseries data type.
    Type -> Maybe ColumnInfo
timeSeriesMeasureValueColumnInfo :: Prelude.Maybe ColumnInfo
  }
  deriving (Type -> Type -> Bool
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]
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
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. 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:
--
-- 'arrayColumnInfo', 'type_arrayColumnInfo' - Indicates if the column is an array.
--
-- 'rowColumnInfo', 'type_rowColumnInfo' - Indicates if the column is a row.
--
-- 'scalarType', 'type_scalarType' - Indicates if the column is of type string, integer, Boolean, double,
-- timestamp, date, time.
--
-- 'timeSeriesMeasureValueColumnInfo', 'type_timeSeriesMeasureValueColumnInfo' - Indicates if the column is a timeseries data type.
newType ::
  Type
newType :: Type
newType =
  Type'
    { $sel:arrayColumnInfo:Type' :: Maybe ColumnInfo
arrayColumnInfo = forall a. Maybe a
Prelude.Nothing,
      $sel:rowColumnInfo:Type' :: Maybe [ColumnInfo]
rowColumnInfo = forall a. Maybe a
Prelude.Nothing,
      $sel:scalarType:Type' :: Maybe ScalarType
scalarType = forall a. Maybe a
Prelude.Nothing,
      $sel:timeSeriesMeasureValueColumnInfo:Type' :: Maybe ColumnInfo
timeSeriesMeasureValueColumnInfo = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates if the column is an array.
type_arrayColumnInfo :: Lens.Lens' Type (Prelude.Maybe ColumnInfo)
type_arrayColumnInfo :: Lens' Type (Maybe ColumnInfo)
type_arrayColumnInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Type' {Maybe ColumnInfo
arrayColumnInfo :: Maybe ColumnInfo
$sel:arrayColumnInfo:Type' :: Type -> Maybe ColumnInfo
arrayColumnInfo} -> Maybe ColumnInfo
arrayColumnInfo) (\s :: Type
s@Type' {} Maybe ColumnInfo
a -> Type
s {$sel:arrayColumnInfo:Type' :: Maybe ColumnInfo
arrayColumnInfo = Maybe ColumnInfo
a} :: Type)

-- | Indicates if the column is a row.
type_rowColumnInfo :: Lens.Lens' Type (Prelude.Maybe [ColumnInfo])
type_rowColumnInfo :: Lens' Type (Maybe [ColumnInfo])
type_rowColumnInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Type' {Maybe [ColumnInfo]
rowColumnInfo :: Maybe [ColumnInfo]
$sel:rowColumnInfo:Type' :: Type -> Maybe [ColumnInfo]
rowColumnInfo} -> Maybe [ColumnInfo]
rowColumnInfo) (\s :: Type
s@Type' {} Maybe [ColumnInfo]
a -> Type
s {$sel:rowColumnInfo:Type' :: Maybe [ColumnInfo]
rowColumnInfo = Maybe [ColumnInfo]
a} :: Type) 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

-- | Indicates if the column is of type string, integer, Boolean, double,
-- timestamp, date, time.
type_scalarType :: Lens.Lens' Type (Prelude.Maybe ScalarType)
type_scalarType :: Lens' Type (Maybe ScalarType)
type_scalarType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Type' {Maybe ScalarType
scalarType :: Maybe ScalarType
$sel:scalarType:Type' :: Type -> Maybe ScalarType
scalarType} -> Maybe ScalarType
scalarType) (\s :: Type
s@Type' {} Maybe ScalarType
a -> Type
s {$sel:scalarType:Type' :: Maybe ScalarType
scalarType = Maybe ScalarType
a} :: Type)

-- | Indicates if the column is a timeseries data type.
type_timeSeriesMeasureValueColumnInfo :: Lens.Lens' Type (Prelude.Maybe ColumnInfo)
type_timeSeriesMeasureValueColumnInfo :: Lens' Type (Maybe ColumnInfo)
type_timeSeriesMeasureValueColumnInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Type' {Maybe ColumnInfo
timeSeriesMeasureValueColumnInfo :: Maybe ColumnInfo
$sel:timeSeriesMeasureValueColumnInfo:Type' :: Type -> Maybe ColumnInfo
timeSeriesMeasureValueColumnInfo} -> Maybe ColumnInfo
timeSeriesMeasureValueColumnInfo) (\s :: Type
s@Type' {} Maybe ColumnInfo
a -> Type
s {$sel:timeSeriesMeasureValueColumnInfo:Type' :: Maybe ColumnInfo
timeSeriesMeasureValueColumnInfo = Maybe ColumnInfo
a} :: Type)

instance Data.FromJSON Type where
  parseJSON :: Value -> Parser Type
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Type"
      ( \Object
x ->
          Maybe ColumnInfo
-> Maybe [ColumnInfo]
-> Maybe ScalarType
-> Maybe ColumnInfo
-> Type
Type'
            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
"ArrayColumnInfo")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RowColumnInfo" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ScalarType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TimeSeriesMeasureValueColumnInfo")
      )

instance Prelude.Hashable Type where
  hashWithSalt :: Int -> Type -> Int
hashWithSalt Int
_salt Type' {Maybe [ColumnInfo]
Maybe ColumnInfo
Maybe ScalarType
timeSeriesMeasureValueColumnInfo :: Maybe ColumnInfo
scalarType :: Maybe ScalarType
rowColumnInfo :: Maybe [ColumnInfo]
arrayColumnInfo :: Maybe ColumnInfo
$sel:timeSeriesMeasureValueColumnInfo:Type' :: Type -> Maybe ColumnInfo
$sel:scalarType:Type' :: Type -> Maybe ScalarType
$sel:rowColumnInfo:Type' :: Type -> Maybe [ColumnInfo]
$sel:arrayColumnInfo:Type' :: Type -> Maybe ColumnInfo
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ColumnInfo
arrayColumnInfo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ColumnInfo]
rowColumnInfo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ScalarType
scalarType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ColumnInfo
timeSeriesMeasureValueColumnInfo

instance Prelude.NFData Type where
  rnf :: Type -> ()
rnf Type' {Maybe [ColumnInfo]
Maybe ColumnInfo
Maybe ScalarType
timeSeriesMeasureValueColumnInfo :: Maybe ColumnInfo
scalarType :: Maybe ScalarType
rowColumnInfo :: Maybe [ColumnInfo]
arrayColumnInfo :: Maybe ColumnInfo
$sel:timeSeriesMeasureValueColumnInfo:Type' :: Type -> Maybe ColumnInfo
$sel:scalarType:Type' :: Type -> Maybe ScalarType
$sel:rowColumnInfo:Type' :: Type -> Maybe [ColumnInfo]
$sel:arrayColumnInfo:Type' :: Type -> Maybe ColumnInfo
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ColumnInfo
arrayColumnInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ColumnInfo]
rowColumnInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ScalarType
scalarType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ColumnInfo
timeSeriesMeasureValueColumnInfo