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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing the properties of a table in a workbook.
--
-- /See:/ 'newTable' smart constructor.
data Table = Table'
  { -- | The id of the table.
    Table -> Maybe Text
tableId :: Prelude.Maybe Prelude.Text,
    -- | The name of the table.
    Table -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text
  }
  deriving (Table -> Table -> Bool
(Table -> Table -> Bool) -> (Table -> Table -> Bool) -> Eq Table
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Table -> Table -> Bool
$c/= :: Table -> Table -> Bool
== :: Table -> Table -> Bool
$c== :: Table -> Table -> Bool
Prelude.Eq, ReadPrec [Table]
ReadPrec Table
Int -> ReadS Table
ReadS [Table]
(Int -> ReadS Table)
-> ReadS [Table]
-> ReadPrec Table
-> ReadPrec [Table]
-> Read Table
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Table]
$creadListPrec :: ReadPrec [Table]
readPrec :: ReadPrec Table
$creadPrec :: ReadPrec Table
readList :: ReadS [Table]
$creadList :: ReadS [Table]
readsPrec :: Int -> ReadS Table
$creadsPrec :: Int -> ReadS Table
Prelude.Read, Int -> Table -> ShowS
[Table] -> ShowS
Table -> String
(Int -> Table -> ShowS)
-> (Table -> String) -> ([Table] -> ShowS) -> Show Table
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Table] -> ShowS
$cshowList :: [Table] -> ShowS
show :: Table -> String
$cshow :: Table -> String
showsPrec :: Int -> Table -> ShowS
$cshowsPrec :: Int -> Table -> ShowS
Prelude.Show, (forall x. Table -> Rep Table x)
-> (forall x. Rep Table x -> Table) -> Generic Table
forall x. Rep Table x -> Table
forall x. Table -> Rep Table x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Table x -> Table
$cfrom :: forall x. Table -> Rep Table x
Prelude.Generic)

-- |
-- Create a value of 'Table' 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:
--
-- 'tableId', 'table_tableId' - The id of the table.
--
-- 'tableName', 'table_tableName' - The name of the table.
newTable ::
  Table
newTable :: Table
newTable =
  Table' :: Maybe Text -> Maybe Text -> Table
Table'
    { $sel:tableId:Table' :: Maybe Text
tableId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:Table' :: Maybe Text
tableName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The id of the table.
table_tableId :: Lens.Lens' Table (Prelude.Maybe Prelude.Text)
table_tableId :: (Maybe Text -> f (Maybe Text)) -> Table -> f Table
table_tableId = (Table -> Maybe Text)
-> (Table -> Maybe Text -> Table)
-> Lens Table Table (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe Text
tableId :: Maybe Text
$sel:tableId:Table' :: Table -> Maybe Text
tableId} -> Maybe Text
tableId) (\s :: Table
s@Table' {} Maybe Text
a -> Table
s {$sel:tableId:Table' :: Maybe Text
tableId = Maybe Text
a} :: Table)

-- | The name of the table.
table_tableName :: Lens.Lens' Table (Prelude.Maybe Prelude.Text)
table_tableName :: (Maybe Text -> f (Maybe Text)) -> Table -> f Table
table_tableName = (Table -> Maybe Text)
-> (Table -> Maybe Text -> Table)
-> Lens Table Table (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Table' {Maybe Text
tableName :: Maybe Text
$sel:tableName:Table' :: Table -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: Table
s@Table' {} Maybe Text
a -> Table
s {$sel:tableName:Table' :: Maybe Text
tableName = Maybe Text
a} :: Table)

instance Core.FromJSON Table where
  parseJSON :: Value -> Parser Table
parseJSON =
    String -> (Object -> Parser Table) -> Value -> Parser Table
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Table"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Table
Table'
            (Maybe Text -> Maybe Text -> Table)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Table)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tableId")
            Parser (Maybe Text -> Table) -> Parser (Maybe Text) -> Parser Table
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tableName")
      )

instance Prelude.Hashable Table

instance Prelude.NFData Table