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

import qualified Amazonka.Core as Core
import Amazonka.HoneyCode.Types.CellInput
import qualified Amazonka.Lens as Lens
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
(CreateRowData -> CreateRowData -> Bool)
-> (CreateRowData -> CreateRowData -> Bool) -> Eq CreateRowData
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
(Int -> CreateRowData -> ShowS)
-> (CreateRowData -> String)
-> ([CreateRowData] -> ShowS)
-> Show CreateRowData
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. CreateRowData -> Rep CreateRowData x)
-> (forall x. Rep CreateRowData x -> CreateRowData)
-> Generic CreateRowData
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' :: Text -> HashMap Text CellInput -> CreateRowData
CreateRowData'
    { $sel:batchItemId:CreateRowData' :: Text
batchItemId = Text
pBatchItemId_,
      $sel:cellsToCreate:CreateRowData' :: HashMap Text CellInput
cellsToCreate = HashMap Text CellInput
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 :: (Text -> f Text) -> CreateRowData -> f CreateRowData
createRowData_batchItemId = (CreateRowData -> Text)
-> (CreateRowData -> Text -> CreateRowData)
-> Lens CreateRowData CreateRowData Text Text
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 :: (HashMap Text CellInput -> f (HashMap Text CellInput))
-> CreateRowData -> f CreateRowData
createRowData_cellsToCreate = (CreateRowData -> HashMap Text CellInput)
-> (CreateRowData -> HashMap Text CellInput -> CreateRowData)
-> Lens
     CreateRowData
     CreateRowData
     (HashMap Text CellInput)
     (HashMap Text CellInput)
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) ((HashMap Text CellInput -> f (HashMap Text CellInput))
 -> CreateRowData -> f CreateRowData)
-> ((HashMap Text CellInput -> f (HashMap Text CellInput))
    -> HashMap Text CellInput -> f (HashMap Text CellInput))
-> (HashMap Text CellInput -> f (HashMap Text CellInput))
-> CreateRowData
-> f CreateRowData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text CellInput -> f (HashMap Text CellInput))
-> HashMap Text CellInput -> f (HashMap Text CellInput)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable CreateRowData

instance Prelude.NFData CreateRowData

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"batchItemId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
batchItemId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"cellsToCreate" Text -> HashMap Text CellInput -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text CellInput
cellsToCreate)
          ]
      )