{-# 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.Athena.Types.ResultSetMetadata
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Athena.Types.ResultSetMetadata where

import Amazonka.Athena.Types.ColumnInfo
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The metadata that describes the column structure and data types of a
-- table of query results. To return a @ResultSetMetadata@ object, use
-- GetQueryResults.
--
-- /See:/ 'newResultSetMetadata' smart constructor.
data ResultSetMetadata = ResultSetMetadata'
  { -- | Information about the columns returned in a query result metadata.
    ResultSetMetadata -> Maybe [ColumnInfo]
columnInfo :: Prelude.Maybe [ColumnInfo]
  }
  deriving (ResultSetMetadata -> ResultSetMetadata -> Bool
(ResultSetMetadata -> ResultSetMetadata -> Bool)
-> (ResultSetMetadata -> ResultSetMetadata -> Bool)
-> Eq ResultSetMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultSetMetadata -> ResultSetMetadata -> Bool
$c/= :: ResultSetMetadata -> ResultSetMetadata -> Bool
== :: ResultSetMetadata -> ResultSetMetadata -> Bool
$c== :: ResultSetMetadata -> ResultSetMetadata -> Bool
Prelude.Eq, ReadPrec [ResultSetMetadata]
ReadPrec ResultSetMetadata
Int -> ReadS ResultSetMetadata
ReadS [ResultSetMetadata]
(Int -> ReadS ResultSetMetadata)
-> ReadS [ResultSetMetadata]
-> ReadPrec ResultSetMetadata
-> ReadPrec [ResultSetMetadata]
-> Read ResultSetMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResultSetMetadata]
$creadListPrec :: ReadPrec [ResultSetMetadata]
readPrec :: ReadPrec ResultSetMetadata
$creadPrec :: ReadPrec ResultSetMetadata
readList :: ReadS [ResultSetMetadata]
$creadList :: ReadS [ResultSetMetadata]
readsPrec :: Int -> ReadS ResultSetMetadata
$creadsPrec :: Int -> ReadS ResultSetMetadata
Prelude.Read, Int -> ResultSetMetadata -> ShowS
[ResultSetMetadata] -> ShowS
ResultSetMetadata -> String
(Int -> ResultSetMetadata -> ShowS)
-> (ResultSetMetadata -> String)
-> ([ResultSetMetadata] -> ShowS)
-> Show ResultSetMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultSetMetadata] -> ShowS
$cshowList :: [ResultSetMetadata] -> ShowS
show :: ResultSetMetadata -> String
$cshow :: ResultSetMetadata -> String
showsPrec :: Int -> ResultSetMetadata -> ShowS
$cshowsPrec :: Int -> ResultSetMetadata -> ShowS
Prelude.Show, (forall x. ResultSetMetadata -> Rep ResultSetMetadata x)
-> (forall x. Rep ResultSetMetadata x -> ResultSetMetadata)
-> Generic ResultSetMetadata
forall x. Rep ResultSetMetadata x -> ResultSetMetadata
forall x. ResultSetMetadata -> Rep ResultSetMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultSetMetadata x -> ResultSetMetadata
$cfrom :: forall x. ResultSetMetadata -> Rep ResultSetMetadata x
Prelude.Generic)

-- |
-- Create a value of 'ResultSetMetadata' 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:
--
-- 'columnInfo', 'resultSetMetadata_columnInfo' - Information about the columns returned in a query result metadata.
newResultSetMetadata ::
  ResultSetMetadata
newResultSetMetadata :: ResultSetMetadata
newResultSetMetadata =
  ResultSetMetadata' :: Maybe [ColumnInfo] -> ResultSetMetadata
ResultSetMetadata' {$sel:columnInfo:ResultSetMetadata' :: Maybe [ColumnInfo]
columnInfo = Maybe [ColumnInfo]
forall a. Maybe a
Prelude.Nothing}

-- | Information about the columns returned in a query result metadata.
resultSetMetadata_columnInfo :: Lens.Lens' ResultSetMetadata (Prelude.Maybe [ColumnInfo])
resultSetMetadata_columnInfo :: (Maybe [ColumnInfo] -> f (Maybe [ColumnInfo]))
-> ResultSetMetadata -> f ResultSetMetadata
resultSetMetadata_columnInfo = (ResultSetMetadata -> Maybe [ColumnInfo])
-> (ResultSetMetadata -> Maybe [ColumnInfo] -> ResultSetMetadata)
-> Lens
     ResultSetMetadata
     ResultSetMetadata
     (Maybe [ColumnInfo])
     (Maybe [ColumnInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultSetMetadata' {Maybe [ColumnInfo]
columnInfo :: Maybe [ColumnInfo]
$sel:columnInfo:ResultSetMetadata' :: ResultSetMetadata -> Maybe [ColumnInfo]
columnInfo} -> Maybe [ColumnInfo]
columnInfo) (\s :: ResultSetMetadata
s@ResultSetMetadata' {} Maybe [ColumnInfo]
a -> ResultSetMetadata
s {$sel:columnInfo:ResultSetMetadata' :: Maybe [ColumnInfo]
columnInfo = Maybe [ColumnInfo]
a} :: ResultSetMetadata) ((Maybe [ColumnInfo] -> f (Maybe [ColumnInfo]))
 -> ResultSetMetadata -> f ResultSetMetadata)
-> ((Maybe [ColumnInfo] -> f (Maybe [ColumnInfo]))
    -> Maybe [ColumnInfo] -> f (Maybe [ColumnInfo]))
-> (Maybe [ColumnInfo] -> f (Maybe [ColumnInfo]))
-> ResultSetMetadata
-> f ResultSetMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ColumnInfo] [ColumnInfo] [ColumnInfo] [ColumnInfo]
-> Iso
     (Maybe [ColumnInfo])
     (Maybe [ColumnInfo])
     (Maybe [ColumnInfo])
     (Maybe [ColumnInfo])
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 AnIso [ColumnInfo] [ColumnInfo] [ColumnInfo] [ColumnInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ResultSetMetadata where
  parseJSON :: Value -> Parser ResultSetMetadata
parseJSON =
    String
-> (Object -> Parser ResultSetMetadata)
-> Value
-> Parser ResultSetMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResultSetMetadata"
      ( \Object
x ->
          Maybe [ColumnInfo] -> ResultSetMetadata
ResultSetMetadata'
            (Maybe [ColumnInfo] -> ResultSetMetadata)
-> Parser (Maybe [ColumnInfo]) -> Parser ResultSetMetadata
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [ColumnInfo]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ColumnInfo" Parser (Maybe (Maybe [ColumnInfo]))
-> Maybe [ColumnInfo] -> Parser (Maybe [ColumnInfo])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ColumnInfo]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResultSetMetadata

instance Prelude.NFData ResultSetMetadata