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

-- | Data needed to create a single row in a table as part of the
-- BatchCreateTableRows request.
--
-- /See:/ 'newCreateRowData' smart constructor.
data CreateRowData = CreateRowData'
  { -- | An external identifier that represents the single row that is being
    -- created as part of the BatchCreateTableRows request. This can be any
    -- string that you can use to identify the row in the request. The
    -- BatchCreateTableRows API puts the batch item id in the results to allow
    -- you to link data in the request to data in the results.
    CreateRowData -> Text
batchItemId :: Prelude.Text,
    -- | A map representing the cells to create in the new row. The key is the
    -- column id of the cell and the value is the CellInput object that
    -- represents the data to set in that cell.
    CreateRowData -> HashMap Text CellInput
cellsToCreate :: Prelude.HashMap Prelude.Text CellInput
  }
  deriving (CreateRowData -> CreateRowData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRowData -> CreateRowData -> Bool
$c/= :: CreateRowData -> CreateRowData -> Bool
== :: CreateRowData -> CreateRowData -> Bool
$c== :: CreateRowData -> CreateRowData -> Bool
Prelude.Eq, Int -> CreateRowData -> ShowS
[CreateRowData] -> ShowS
CreateRowData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRowData] -> ShowS
$cshowList :: [CreateRowData] -> ShowS
show :: CreateRowData -> String
$cshow :: CreateRowData -> String
showsPrec :: Int -> CreateRowData -> ShowS
$cshowsPrec :: Int -> CreateRowData -> ShowS
Prelude.Show, forall x. Rep CreateRowData x -> CreateRowData
forall x. CreateRowData -> Rep CreateRowData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRowData x -> CreateRowData
$cfrom :: forall x. CreateRowData -> Rep CreateRowData x
Prelude.Generic)

-- |
-- Create a value of 'CreateRowData' 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:
--
-- 'batchItemId', 'createRowData_batchItemId' - An external identifier that represents the single row that is being
-- created as part of the BatchCreateTableRows request. This can be any
-- string that you can use to identify the row in the request. The
-- BatchCreateTableRows API puts the batch item id in the results to allow
-- you to link data in the request to data in the results.
--
-- 'cellsToCreate', 'createRowData_cellsToCreate' - A map representing the cells to create in the new row. The key is the
-- column id of the cell and the value is the CellInput object that
-- represents the data to set in that cell.
newCreateRowData ::
  -- | 'batchItemId'
  Prelude.Text ->
  CreateRowData
newCreateRowData :: Text -> CreateRowData
newCreateRowData Text
pBatchItemId_ =
  CreateRowData'
    { $sel:batchItemId:CreateRowData' :: Text
batchItemId = Text
pBatchItemId_,
      $sel:cellsToCreate:CreateRowData' :: HashMap Text CellInput
cellsToCreate = forall a. Monoid a => a
Prelude.mempty
    }

-- | An external identifier that represents the single row that is being
-- created as part of the BatchCreateTableRows request. This can be any
-- string that you can use to identify the row in the request. The
-- BatchCreateTableRows API puts the batch item id in the results to allow
-- you to link data in the request to data in the results.
createRowData_batchItemId :: Lens.Lens' CreateRowData Prelude.Text
createRowData_batchItemId :: Lens' CreateRowData Text
createRowData_batchItemId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRowData' {Text
batchItemId :: Text
$sel:batchItemId:CreateRowData' :: CreateRowData -> Text
batchItemId} -> Text
batchItemId) (\s :: CreateRowData
s@CreateRowData' {} Text
a -> CreateRowData
s {$sel:batchItemId:CreateRowData' :: Text
batchItemId = Text
a} :: CreateRowData)

-- | A map representing the cells to create in the new row. The key is the
-- column id of the cell and the value is the CellInput object that
-- represents the data to set in that cell.
createRowData_cellsToCreate :: Lens.Lens' CreateRowData (Prelude.HashMap Prelude.Text CellInput)
createRowData_cellsToCreate :: Lens' CreateRowData (HashMap Text CellInput)
createRowData_cellsToCreate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRowData' {HashMap Text CellInput
cellsToCreate :: HashMap Text CellInput
$sel:cellsToCreate:CreateRowData' :: CreateRowData -> HashMap Text CellInput
cellsToCreate} -> HashMap Text CellInput
cellsToCreate) (\s :: CreateRowData
s@CreateRowData' {} HashMap Text CellInput
a -> CreateRowData
s {$sel:cellsToCreate:CreateRowData' :: HashMap Text CellInput
cellsToCreate = HashMap Text CellInput
a} :: CreateRowData) 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 Prelude.Hashable CreateRowData where
  hashWithSalt :: Int -> CreateRowData -> Int
hashWithSalt Int
_salt CreateRowData' {Text
HashMap Text CellInput
cellsToCreate :: HashMap Text CellInput
batchItemId :: Text
$sel:cellsToCreate:CreateRowData' :: CreateRowData -> HashMap Text CellInput
$sel:batchItemId:CreateRowData' :: CreateRowData -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
batchItemId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text CellInput
cellsToCreate

instance Prelude.NFData CreateRowData where
  rnf :: CreateRowData -> ()
rnf CreateRowData' {Text
HashMap Text CellInput
cellsToCreate :: HashMap Text CellInput
batchItemId :: Text
$sel:cellsToCreate:CreateRowData' :: CreateRowData -> HashMap Text CellInput
$sel:batchItemId:CreateRowData' :: CreateRowData -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
batchItemId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text CellInput
cellsToCreate

instance Data.ToJSON CreateRowData where
  toJSON :: CreateRowData -> Value
toJSON CreateRowData' {Text
HashMap Text CellInput
cellsToCreate :: HashMap Text CellInput
batchItemId :: Text
$sel:cellsToCreate:CreateRowData' :: CreateRowData -> HashMap Text CellInput
$sel:batchItemId:CreateRowData' :: CreateRowData -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"batchItemId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
batchItemId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"cellsToCreate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HashMap Text CellInput
cellsToCreate)
          ]
      )