{-# 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.Row
-- 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.Row where

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

-- | The rows that comprise a query result table.
--
-- /See:/ 'newRow' smart constructor.
data Row = Row'
  { -- | The data that populates a row in a query result table.
    Row -> Maybe [Datum]
data' :: Prelude.Maybe [Datum]
  }
  deriving (Row -> Row -> Bool
(Row -> Row -> Bool) -> (Row -> Row -> Bool) -> Eq Row
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Row -> Row -> Bool
$c/= :: Row -> Row -> Bool
== :: Row -> Row -> Bool
$c== :: Row -> Row -> Bool
Prelude.Eq, ReadPrec [Row]
ReadPrec Row
Int -> ReadS Row
ReadS [Row]
(Int -> ReadS Row)
-> ReadS [Row] -> ReadPrec Row -> ReadPrec [Row] -> Read Row
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Row]
$creadListPrec :: ReadPrec [Row]
readPrec :: ReadPrec Row
$creadPrec :: ReadPrec Row
readList :: ReadS [Row]
$creadList :: ReadS [Row]
readsPrec :: Int -> ReadS Row
$creadsPrec :: Int -> ReadS Row
Prelude.Read, Int -> Row -> ShowS
[Row] -> ShowS
Row -> String
(Int -> Row -> ShowS)
-> (Row -> String) -> ([Row] -> ShowS) -> Show Row
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Row] -> ShowS
$cshowList :: [Row] -> ShowS
show :: Row -> String
$cshow :: Row -> String
showsPrec :: Int -> Row -> ShowS
$cshowsPrec :: Int -> Row -> ShowS
Prelude.Show, (forall x. Row -> Rep Row x)
-> (forall x. Rep Row x -> Row) -> Generic Row
forall x. Rep Row x -> Row
forall x. Row -> Rep Row x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Row x -> Row
$cfrom :: forall x. Row -> Rep Row x
Prelude.Generic)

-- |
-- Create a value of 'Row' 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:
--
-- 'data'', 'row_data' - The data that populates a row in a query result table.
newRow ::
  Row
newRow :: Row
newRow = Row' :: Maybe [Datum] -> Row
Row' {$sel:data':Row' :: Maybe [Datum]
data' = Maybe [Datum]
forall a. Maybe a
Prelude.Nothing}

-- | The data that populates a row in a query result table.
row_data :: Lens.Lens' Row (Prelude.Maybe [Datum])
row_data :: (Maybe [Datum] -> f (Maybe [Datum])) -> Row -> f Row
row_data = (Row -> Maybe [Datum])
-> (Row -> Maybe [Datum] -> Row)
-> Lens Row Row (Maybe [Datum]) (Maybe [Datum])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Row' {Maybe [Datum]
data' :: Maybe [Datum]
$sel:data':Row' :: Row -> Maybe [Datum]
data'} -> Maybe [Datum]
data') (\s :: Row
s@Row' {} Maybe [Datum]
a -> Row
s {$sel:data':Row' :: Maybe [Datum]
data' = Maybe [Datum]
a} :: Row) ((Maybe [Datum] -> f (Maybe [Datum])) -> Row -> f Row)
-> ((Maybe [Datum] -> f (Maybe [Datum]))
    -> Maybe [Datum] -> f (Maybe [Datum]))
-> (Maybe [Datum] -> f (Maybe [Datum]))
-> Row
-> f Row
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Datum] [Datum] [Datum] [Datum]
-> Iso
     (Maybe [Datum]) (Maybe [Datum]) (Maybe [Datum]) (Maybe [Datum])
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 [Datum] [Datum] [Datum] [Datum]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable Row

instance Prelude.NFData Row