{-# 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.UpdateRowData
-- 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.UpdateRowData 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:/ 'newUpdateRowData' smart constructor.
data UpdateRowData = UpdateRowData'
  { -- | The id of the row that needs to be updated.
    UpdateRowData -> Text
rowId :: Prelude.Text,
    -- | A map representing the cells to update in the given 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.
    UpdateRowData -> HashMap Text CellInput
cellsToUpdate :: Prelude.HashMap Prelude.Text CellInput
  }
  deriving (UpdateRowData -> UpdateRowData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRowData -> UpdateRowData -> Bool
$c/= :: UpdateRowData -> UpdateRowData -> Bool
== :: UpdateRowData -> UpdateRowData -> Bool
$c== :: UpdateRowData -> UpdateRowData -> Bool
Prelude.Eq, Int -> UpdateRowData -> ShowS
[UpdateRowData] -> ShowS
UpdateRowData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRowData] -> ShowS
$cshowList :: [UpdateRowData] -> ShowS
show :: UpdateRowData -> String
$cshow :: UpdateRowData -> String
showsPrec :: Int -> UpdateRowData -> ShowS
$cshowsPrec :: Int -> UpdateRowData -> ShowS
Prelude.Show, forall x. Rep UpdateRowData x -> UpdateRowData
forall x. UpdateRowData -> Rep UpdateRowData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRowData x -> UpdateRowData
$cfrom :: forall x. UpdateRowData -> Rep UpdateRowData x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRowData' 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', 'updateRowData_rowId' - The id of the row that needs to be updated.
--
-- 'cellsToUpdate', 'updateRowData_cellsToUpdate' - A map representing the cells to update in the given 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.
newUpdateRowData ::
  -- | 'rowId'
  Prelude.Text ->
  UpdateRowData
newUpdateRowData :: Text -> UpdateRowData
newUpdateRowData Text
pRowId_ =
  UpdateRowData'
    { $sel:rowId:UpdateRowData' :: Text
rowId = Text
pRowId_,
      $sel:cellsToUpdate:UpdateRowData' :: HashMap Text CellInput
cellsToUpdate = forall a. Monoid a => a
Prelude.mempty
    }

-- | The id of the row that needs to be updated.
updateRowData_rowId :: Lens.Lens' UpdateRowData Prelude.Text
updateRowData_rowId :: Lens' UpdateRowData Text
updateRowData_rowId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRowData' {Text
rowId :: Text
$sel:rowId:UpdateRowData' :: UpdateRowData -> Text
rowId} -> Text
rowId) (\s :: UpdateRowData
s@UpdateRowData' {} Text
a -> UpdateRowData
s {$sel:rowId:UpdateRowData' :: Text
rowId = Text
a} :: UpdateRowData)

-- | A map representing the cells to update in the given 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.
updateRowData_cellsToUpdate :: Lens.Lens' UpdateRowData (Prelude.HashMap Prelude.Text CellInput)
updateRowData_cellsToUpdate :: Lens' UpdateRowData (HashMap Text CellInput)
updateRowData_cellsToUpdate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRowData' {HashMap Text CellInput
cellsToUpdate :: HashMap Text CellInput
$sel:cellsToUpdate:UpdateRowData' :: UpdateRowData -> HashMap Text CellInput
cellsToUpdate} -> HashMap Text CellInput
cellsToUpdate) (\s :: UpdateRowData
s@UpdateRowData' {} HashMap Text CellInput
a -> UpdateRowData
s {$sel:cellsToUpdate:UpdateRowData' :: HashMap Text CellInput
cellsToUpdate = HashMap Text CellInput
a} :: UpdateRowData) 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 UpdateRowData where
  hashWithSalt :: Int -> UpdateRowData -> Int
hashWithSalt Int
_salt UpdateRowData' {Text
HashMap Text CellInput
cellsToUpdate :: HashMap Text CellInput
rowId :: Text
$sel:cellsToUpdate:UpdateRowData' :: UpdateRowData -> HashMap Text CellInput
$sel:rowId:UpdateRowData' :: UpdateRowData -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
rowId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text CellInput
cellsToUpdate

instance Prelude.NFData UpdateRowData where
  rnf :: UpdateRowData -> ()
rnf UpdateRowData' {Text
HashMap Text CellInput
cellsToUpdate :: HashMap Text CellInput
rowId :: Text
$sel:cellsToUpdate:UpdateRowData' :: UpdateRowData -> HashMap Text CellInput
$sel:rowId:UpdateRowData' :: UpdateRowData -> 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 HashMap Text CellInput
cellsToUpdate

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