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

import qualified Amazonka.Core as Core
import Amazonka.HoneyCode.Types.Cell
import qualified Amazonka.Lens as Lens
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 :: [Core.Sensitive Cell]
  }
  deriving (TableRow -> TableRow -> Bool
(TableRow -> TableRow -> Bool)
-> (TableRow -> TableRow -> Bool) -> Eq TableRow
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
(Int -> TableRow -> ShowS)
-> (TableRow -> String) -> ([TableRow] -> ShowS) -> Show TableRow
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. TableRow -> Rep TableRow x)
-> (forall x. Rep TableRow x -> TableRow) -> Generic TableRow
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' :: Text -> [Sensitive Cell] -> TableRow
TableRow' {$sel:rowId:TableRow' :: Text
rowId = Text
pRowId_, $sel:cells:TableRow' :: [Sensitive Cell]
cells = [Sensitive Cell]
forall a. Monoid a => a
Prelude.mempty}

-- | The id of the row in the table.
tableRow_rowId :: Lens.Lens' TableRow Prelude.Text
tableRow_rowId :: (Text -> f Text) -> TableRow -> f TableRow
tableRow_rowId = (TableRow -> Text)
-> (TableRow -> Text -> TableRow)
-> Lens TableRow TableRow Text Text
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 :: ([Cell] -> f [Cell]) -> TableRow -> f TableRow
tableRow_cells = (TableRow -> [Sensitive Cell])
-> (TableRow -> [Sensitive Cell] -> TableRow)
-> Lens TableRow TableRow [Sensitive Cell] [Sensitive Cell]
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) (([Sensitive Cell] -> f [Sensitive Cell])
 -> TableRow -> f TableRow)
-> (([Cell] -> f [Cell]) -> [Sensitive Cell] -> f [Sensitive Cell])
-> ([Cell] -> f [Cell])
-> TableRow
-> f TableRow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Cell] -> f [Cell]) -> [Sensitive Cell] -> f [Sensitive Cell]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable TableRow

instance Prelude.NFData TableRow