{-# 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.TableRow
-- 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.TableRow 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.Cell
import qualified Amazonka.Prelude as Prelude

-- | An object that contains attributes about a single row in a table
--
-- /See:/ 'newTableRow' smart constructor.
data TableRow = TableRow'
  { -- | The id of the row in the table.
    TableRow -> Text
rowId :: Prelude.Text,
    -- | A list of cells in the table row. The cells appear in the same order as
    -- the columns of the table.
    TableRow -> [Sensitive Cell]
cells :: [Data.Sensitive Cell]
  }
  deriving (TableRow -> TableRow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TableRow -> TableRow -> Bool
$c/= :: TableRow -> TableRow -> Bool
== :: TableRow -> TableRow -> Bool
$c== :: TableRow -> TableRow -> Bool
Prelude.Eq, Int -> TableRow -> ShowS
[TableRow] -> ShowS
TableRow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TableRow] -> ShowS
$cshowList :: [TableRow] -> ShowS
show :: TableRow -> String
$cshow :: TableRow -> String
showsPrec :: Int -> TableRow -> ShowS
$cshowsPrec :: Int -> TableRow -> ShowS
Prelude.Show, forall x. Rep TableRow x -> TableRow
forall x. TableRow -> Rep TableRow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TableRow x -> TableRow
$cfrom :: forall x. TableRow -> Rep TableRow x
Prelude.Generic)

-- |
-- Create a value of 'TableRow' 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', 'tableRow_rowId' - The id of the row in the table.
--
-- 'cells', 'tableRow_cells' - A list of cells in the table row. The cells appear in the same order as
-- the columns of the table.
newTableRow ::
  -- | 'rowId'
  Prelude.Text ->
  TableRow
newTableRow :: Text -> TableRow
newTableRow Text
pRowId_ =
  TableRow' {$sel:rowId:TableRow' :: Text
rowId = Text
pRowId_, $sel:cells:TableRow' :: [Sensitive Cell]
cells = forall a. Monoid a => a
Prelude.mempty}

-- | The id of the row in the table.
tableRow_rowId :: Lens.Lens' TableRow Prelude.Text
tableRow_rowId :: Lens' TableRow Text
tableRow_rowId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableRow' {Text
rowId :: Text
$sel:rowId:TableRow' :: TableRow -> Text
rowId} -> Text
rowId) (\s :: TableRow
s@TableRow' {} Text
a -> TableRow
s {$sel:rowId:TableRow' :: Text
rowId = Text
a} :: TableRow)

-- | A list of cells in the table row. The cells appear in the same order as
-- the columns of the table.
tableRow_cells :: Lens.Lens' TableRow [Cell]
tableRow_cells :: Lens' TableRow [Cell]
tableRow_cells = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableRow' {[Sensitive Cell]
cells :: [Sensitive Cell]
$sel:cells:TableRow' :: TableRow -> [Sensitive Cell]
cells} -> [Sensitive Cell]
cells) (\s :: TableRow
s@TableRow' {} [Sensitive Cell]
a -> TableRow
s {$sel:cells:TableRow' :: [Sensitive Cell]
cells = [Sensitive Cell]
a} :: TableRow) 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 TableRow where
  parseJSON :: Value -> Parser TableRow
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TableRow"
      ( \Object
x ->
          Text -> [Sensitive Cell] -> TableRow
TableRow'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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
"cells" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable TableRow where
  hashWithSalt :: Int -> TableRow -> Int
hashWithSalt Int
_salt TableRow' {[Sensitive Cell]
Text
cells :: [Sensitive Cell]
rowId :: Text
$sel:cells:TableRow' :: TableRow -> [Sensitive Cell]
$sel:rowId:TableRow' :: TableRow -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
rowId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Sensitive Cell]
cells

instance Prelude.NFData TableRow where
  rnf :: TableRow -> ()
rnf TableRow' {[Sensitive Cell]
Text
cells :: [Sensitive Cell]
rowId :: Text
$sel:cells:TableRow' :: TableRow -> [Sensitive Cell]
$sel:rowId:TableRow' :: TableRow -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
rowId seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Sensitive Cell]
cells