{-# 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.HoneyCode.Types.ResultRow
-- 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.HoneyCode.Types.ResultRow where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.HoneyCode.Types.DataItem
import qualified Amazonka.Prelude as Prelude

-- | A single row in the ResultSet.
--
-- /See:/ 'newResultRow' smart constructor.
data ResultRow = ResultRow'
  { -- | The ID for a particular row.
    ResultRow -> Maybe Text
rowId :: Prelude.Maybe Prelude.Text,
    -- | List of all the data cells in a row.
    ResultRow -> [Sensitive DataItem]
dataItems :: [Data.Sensitive DataItem]
  }
  deriving (ResultRow -> ResultRow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultRow -> ResultRow -> Bool
$c/= :: ResultRow -> ResultRow -> Bool
== :: ResultRow -> ResultRow -> Bool
$c== :: ResultRow -> ResultRow -> Bool
Prelude.Eq, Int -> ResultRow -> ShowS
[ResultRow] -> ShowS
ResultRow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultRow] -> ShowS
$cshowList :: [ResultRow] -> ShowS
show :: ResultRow -> String
$cshow :: ResultRow -> String
showsPrec :: Int -> ResultRow -> ShowS
$cshowsPrec :: Int -> ResultRow -> ShowS
Prelude.Show, forall x. Rep ResultRow x -> ResultRow
forall x. ResultRow -> Rep ResultRow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultRow x -> ResultRow
$cfrom :: forall x. ResultRow -> Rep ResultRow x
Prelude.Generic)

-- |
-- Create a value of 'ResultRow' 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:
--
-- 'rowId', 'resultRow_rowId' - The ID for a particular row.
--
-- 'dataItems', 'resultRow_dataItems' - List of all the data cells in a row.
newResultRow ::
  ResultRow
newResultRow :: ResultRow
newResultRow =
  ResultRow'
    { $sel:rowId:ResultRow' :: Maybe Text
rowId = forall a. Maybe a
Prelude.Nothing,
      $sel:dataItems:ResultRow' :: [Sensitive DataItem]
dataItems = forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID for a particular row.
resultRow_rowId :: Lens.Lens' ResultRow (Prelude.Maybe Prelude.Text)
resultRow_rowId :: Lens' ResultRow (Maybe Text)
resultRow_rowId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultRow' {Maybe Text
rowId :: Maybe Text
$sel:rowId:ResultRow' :: ResultRow -> Maybe Text
rowId} -> Maybe Text
rowId) (\s :: ResultRow
s@ResultRow' {} Maybe Text
a -> ResultRow
s {$sel:rowId:ResultRow' :: Maybe Text
rowId = Maybe Text
a} :: ResultRow)

-- | List of all the data cells in a row.
resultRow_dataItems :: Lens.Lens' ResultRow [DataItem]
resultRow_dataItems :: Lens' ResultRow [DataItem]
resultRow_dataItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResultRow' {[Sensitive DataItem]
dataItems :: [Sensitive DataItem]
$sel:dataItems:ResultRow' :: ResultRow -> [Sensitive DataItem]
dataItems} -> [Sensitive DataItem]
dataItems) (\s :: ResultRow
s@ResultRow' {} [Sensitive DataItem]
a -> ResultRow
s {$sel:dataItems:ResultRow' :: [Sensitive DataItem]
dataItems = [Sensitive DataItem]
a} :: ResultRow) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ResultRow where
  parseJSON :: Value -> Parser ResultRow
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResultRow"
      ( \Object
x ->
          Maybe Text -> [Sensitive DataItem] -> ResultRow
ResultRow'
            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
"rowId")
            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
"dataItems" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ResultRow where
  hashWithSalt :: Int -> ResultRow -> Int
hashWithSalt Int
_salt ResultRow' {[Sensitive DataItem]
Maybe Text
dataItems :: [Sensitive DataItem]
rowId :: Maybe Text
$sel:dataItems:ResultRow' :: ResultRow -> [Sensitive DataItem]
$sel:rowId:ResultRow' :: ResultRow -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
rowId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Sensitive DataItem]
dataItems

instance Prelude.NFData ResultRow where
  rnf :: ResultRow -> ()
rnf ResultRow' {[Sensitive DataItem]
Maybe Text
dataItems :: [Sensitive DataItem]
rowId :: Maybe Text
$sel:dataItems:ResultRow' :: ResultRow -> [Sensitive DataItem]
$sel:rowId:ResultRow' :: ResultRow -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
rowId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Sensitive DataItem]
dataItems