{-# 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.ColumnInfo
-- 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.ColumnInfo 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.Type

-- | Contains the metadata for query results such as the column names, data
-- types, and other attributes.
--
-- /See:/ 'newColumnInfo' smart constructor.
data ColumnInfo = ColumnInfo'
  { -- | The name of the result set column. The name of the result set is
    -- available for columns of all data types except for arrays.
    ColumnInfo -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The data type of the result set column. The data type can be a scalar or
    -- complex. Scalar data types are integers, strings, doubles, Booleans, and
    -- others. Complex data types are types such as arrays, rows, and others.
    ColumnInfo -> Type
type' :: Type
  }
  deriving (ColumnInfo -> ColumnInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnInfo -> ColumnInfo -> Bool
$c/= :: ColumnInfo -> ColumnInfo -> Bool
== :: ColumnInfo -> ColumnInfo -> Bool
$c== :: ColumnInfo -> ColumnInfo -> Bool
Prelude.Eq, ReadPrec [ColumnInfo]
ReadPrec ColumnInfo
Int -> ReadS ColumnInfo
ReadS [ColumnInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnInfo]
$creadListPrec :: ReadPrec [ColumnInfo]
readPrec :: ReadPrec ColumnInfo
$creadPrec :: ReadPrec ColumnInfo
readList :: ReadS [ColumnInfo]
$creadList :: ReadS [ColumnInfo]
readsPrec :: Int -> ReadS ColumnInfo
$creadsPrec :: Int -> ReadS ColumnInfo
Prelude.Read, Int -> ColumnInfo -> ShowS
[ColumnInfo] -> ShowS
ColumnInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnInfo] -> ShowS
$cshowList :: [ColumnInfo] -> ShowS
show :: ColumnInfo -> String
$cshow :: ColumnInfo -> String
showsPrec :: Int -> ColumnInfo -> ShowS
$cshowsPrec :: Int -> ColumnInfo -> ShowS
Prelude.Show, forall x. Rep ColumnInfo x -> ColumnInfo
forall x. ColumnInfo -> Rep ColumnInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnInfo x -> ColumnInfo
$cfrom :: forall x. ColumnInfo -> Rep ColumnInfo x
Prelude.Generic)

-- |
-- Create a value of 'ColumnInfo' 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:
--
-- 'name', 'columnInfo_name' - The name of the result set column. The name of the result set is
-- available for columns of all data types except for arrays.
--
-- 'type'', 'columnInfo_type' - The data type of the result set column. The data type can be a scalar or
-- complex. Scalar data types are integers, strings, doubles, Booleans, and
-- others. Complex data types are types such as arrays, rows, and others.
newColumnInfo ::
  -- | 'type''
  Type ->
  ColumnInfo
newColumnInfo :: Type -> ColumnInfo
newColumnInfo Type
pType_ =
  ColumnInfo' {$sel:name:ColumnInfo' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing, $sel:type':ColumnInfo' :: Type
type' = Type
pType_}

-- | The name of the result set column. The name of the result set is
-- available for columns of all data types except for arrays.
columnInfo_name :: Lens.Lens' ColumnInfo (Prelude.Maybe Prelude.Text)
columnInfo_name :: Lens' ColumnInfo (Maybe Text)
columnInfo_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnInfo' {Maybe Text
name :: Maybe Text
$sel:name:ColumnInfo' :: ColumnInfo -> Maybe Text
name} -> Maybe Text
name) (\s :: ColumnInfo
s@ColumnInfo' {} Maybe Text
a -> ColumnInfo
s {$sel:name:ColumnInfo' :: Maybe Text
name = Maybe Text
a} :: ColumnInfo)

-- | The data type of the result set column. The data type can be a scalar or
-- complex. Scalar data types are integers, strings, doubles, Booleans, and
-- others. Complex data types are types such as arrays, rows, and others.
columnInfo_type :: Lens.Lens' ColumnInfo Type
columnInfo_type :: Lens' ColumnInfo Type
columnInfo_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnInfo' {Type
type' :: Type
$sel:type':ColumnInfo' :: ColumnInfo -> Type
type'} -> Type
type') (\s :: ColumnInfo
s@ColumnInfo' {} Type
a -> ColumnInfo
s {$sel:type':ColumnInfo' :: Type
type' = Type
a} :: ColumnInfo)

instance Data.FromJSON ColumnInfo where
  parseJSON :: Value -> Parser ColumnInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColumnInfo"
      ( \Object
x ->
          Maybe Text -> Type -> ColumnInfo
ColumnInfo'
            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
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
      )

instance Prelude.Hashable ColumnInfo where
  hashWithSalt :: Int -> ColumnInfo -> Int
hashWithSalt Int
_salt ColumnInfo' {Maybe Text
Type
type' :: Type
name :: Maybe Text
$sel:type':ColumnInfo' :: ColumnInfo -> Type
$sel:name:ColumnInfo' :: ColumnInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Type
type'

instance Prelude.NFData ColumnInfo where
  rnf :: ColumnInfo -> ()
rnf ColumnInfo' {Maybe Text
Type
type' :: Type
name :: Maybe Text
$sel:type':ColumnInfo' :: ColumnInfo -> Type
$sel:name:ColumnInfo' :: ColumnInfo -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Type
type'