{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.BatchUpsertTableRows
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- The BatchUpsertTableRows API allows you to upsert one or more rows in a
-- table. The upsert operation takes a filter expression as input and
-- evaluates it to find matching rows on the destination table. If matching
-- rows are found, it will update the cells in the matching rows to new
-- values specified in the request. If no matching rows are found, a new
-- row is added at the end of the table and the cells in that row are set
-- to the new values specified in the request.
--
-- You can specify the values to set in some or all of the columns in the
-- table for the matching or newly appended rows. If a column is not
-- explicitly specified for a particular row, then that column will not be
-- updated for that row. To clear out the data in a specific cell, you need
-- to set the value as an empty string (\"\").
module Amazonka.HoneyCode.BatchUpsertTableRows
  ( -- * Creating a Request
    BatchUpsertTableRows (..),
    newBatchUpsertTableRows,

    -- * Request Lenses
    batchUpsertTableRows_clientRequestToken,
    batchUpsertTableRows_workbookId,
    batchUpsertTableRows_tableId,
    batchUpsertTableRows_rowsToUpsert,

    -- * Destructuring the Response
    BatchUpsertTableRowsResponse (..),
    newBatchUpsertTableRowsResponse,

    -- * Response Lenses
    batchUpsertTableRowsResponse_failedBatchItems,
    batchUpsertTableRowsResponse_httpStatus,
    batchUpsertTableRowsResponse_rows,
    batchUpsertTableRowsResponse_workbookCursor,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newBatchUpsertTableRows' smart constructor.
data BatchUpsertTableRows = BatchUpsertTableRows'
  { -- | The request token for performing the update action. Request tokens help
    -- to identify duplicate requests. If a call times out or fails due to a
    -- transient error like a failed network connection, you can retry the call
    -- with the same request token. The service ensures that if the first call
    -- using that request token is successfully performed, the second call will
    -- not perform the action again.
    --
    -- Note that request tokens are valid only for a few minutes. You cannot
    -- use request tokens to dedupe requests spanning hours or days.
    BatchUpsertTableRows -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The ID of the workbook where the rows are being upserted.
    --
    -- If a workbook with the specified id could not be found, this API throws
    -- ResourceNotFoundException.
    BatchUpsertTableRows -> Text
workbookId :: Prelude.Text,
    -- | The ID of the table where the rows are being upserted.
    --
    -- If a table with the specified id could not be found, this API throws
    -- ResourceNotFoundException.
    BatchUpsertTableRows -> Text
tableId :: Prelude.Text,
    -- | The list of rows to upsert in the table. Each item in this list needs to
    -- have a batch item id to uniquely identify the element in the request, a
    -- filter expression to find the rows to update for that element and the
    -- cell values to set for each column in the upserted rows. You need to
    -- specify at least one item in this list.
    --
    -- Note that if one of the filter formulas in the request fails to evaluate
    -- because of an error or one of the column ids in any of the rows does not
    -- exist in the table, then the request fails and no updates are made to
    -- the table.
    BatchUpsertTableRows -> [UpsertRowData]
rowsToUpsert :: [UpsertRowData]
  }
  deriving (BatchUpsertTableRows -> BatchUpsertTableRows -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchUpsertTableRows -> BatchUpsertTableRows -> Bool
$c/= :: BatchUpsertTableRows -> BatchUpsertTableRows -> Bool
== :: BatchUpsertTableRows -> BatchUpsertTableRows -> Bool
$c== :: BatchUpsertTableRows -> BatchUpsertTableRows -> Bool
Prelude.Eq, Int -> BatchUpsertTableRows -> ShowS
[BatchUpsertTableRows] -> ShowS
BatchUpsertTableRows -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchUpsertTableRows] -> ShowS
$cshowList :: [BatchUpsertTableRows] -> ShowS
show :: BatchUpsertTableRows -> String
$cshow :: BatchUpsertTableRows -> String
showsPrec :: Int -> BatchUpsertTableRows -> ShowS
$cshowsPrec :: Int -> BatchUpsertTableRows -> ShowS
Prelude.Show, forall x. Rep BatchUpsertTableRows x -> BatchUpsertTableRows
forall x. BatchUpsertTableRows -> Rep BatchUpsertTableRows x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchUpsertTableRows x -> BatchUpsertTableRows
$cfrom :: forall x. BatchUpsertTableRows -> Rep BatchUpsertTableRows x
Prelude.Generic)

-- |
-- Create a value of 'BatchUpsertTableRows' 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:
--
-- 'clientRequestToken', 'batchUpsertTableRows_clientRequestToken' - The request token for performing the update action. Request tokens help
-- to identify duplicate requests. If a call times out or fails due to a
-- transient error like a failed network connection, you can retry the call
-- with the same request token. The service ensures that if the first call
-- using that request token is successfully performed, the second call will
-- not perform the action again.
--
-- Note that request tokens are valid only for a few minutes. You cannot
-- use request tokens to dedupe requests spanning hours or days.
--
-- 'workbookId', 'batchUpsertTableRows_workbookId' - The ID of the workbook where the rows are being upserted.
--
-- If a workbook with the specified id could not be found, this API throws
-- ResourceNotFoundException.
--
-- 'tableId', 'batchUpsertTableRows_tableId' - The ID of the table where the rows are being upserted.
--
-- If a table with the specified id could not be found, this API throws
-- ResourceNotFoundException.
--
-- 'rowsToUpsert', 'batchUpsertTableRows_rowsToUpsert' - The list of rows to upsert in the table. Each item in this list needs to
-- have a batch item id to uniquely identify the element in the request, a
-- filter expression to find the rows to update for that element and the
-- cell values to set for each column in the upserted rows. You need to
-- specify at least one item in this list.
--
-- Note that if one of the filter formulas in the request fails to evaluate
-- because of an error or one of the column ids in any of the rows does not
-- exist in the table, then the request fails and no updates are made to
-- the table.
newBatchUpsertTableRows ::
  -- | 'workbookId'
  Prelude.Text ->
  -- | 'tableId'
  Prelude.Text ->
  BatchUpsertTableRows
newBatchUpsertTableRows :: Text -> Text -> BatchUpsertTableRows
newBatchUpsertTableRows Text
pWorkbookId_ Text
pTableId_ =
  BatchUpsertTableRows'
    { $sel:clientRequestToken:BatchUpsertTableRows' :: Maybe Text
clientRequestToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:workbookId:BatchUpsertTableRows' :: Text
workbookId = Text
pWorkbookId_,
      $sel:tableId:BatchUpsertTableRows' :: Text
tableId = Text
pTableId_,
      $sel:rowsToUpsert:BatchUpsertTableRows' :: [UpsertRowData]
rowsToUpsert = forall a. Monoid a => a
Prelude.mempty
    }

-- | The request token for performing the update action. Request tokens help
-- to identify duplicate requests. If a call times out or fails due to a
-- transient error like a failed network connection, you can retry the call
-- with the same request token. The service ensures that if the first call
-- using that request token is successfully performed, the second call will
-- not perform the action again.
--
-- Note that request tokens are valid only for a few minutes. You cannot
-- use request tokens to dedupe requests spanning hours or days.
batchUpsertTableRows_clientRequestToken :: Lens.Lens' BatchUpsertTableRows (Prelude.Maybe Prelude.Text)
batchUpsertTableRows_clientRequestToken :: Lens' BatchUpsertTableRows (Maybe Text)
batchUpsertTableRows_clientRequestToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpsertTableRows' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:BatchUpsertTableRows' :: BatchUpsertTableRows -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: BatchUpsertTableRows
s@BatchUpsertTableRows' {} Maybe Text
a -> BatchUpsertTableRows
s {$sel:clientRequestToken:BatchUpsertTableRows' :: Maybe Text
clientRequestToken = Maybe Text
a} :: BatchUpsertTableRows)

-- | The ID of the workbook where the rows are being upserted.
--
-- If a workbook with the specified id could not be found, this API throws
-- ResourceNotFoundException.
batchUpsertTableRows_workbookId :: Lens.Lens' BatchUpsertTableRows Prelude.Text
batchUpsertTableRows_workbookId :: Lens' BatchUpsertTableRows Text
batchUpsertTableRows_workbookId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpsertTableRows' {Text
workbookId :: Text
$sel:workbookId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
workbookId} -> Text
workbookId) (\s :: BatchUpsertTableRows
s@BatchUpsertTableRows' {} Text
a -> BatchUpsertTableRows
s {$sel:workbookId:BatchUpsertTableRows' :: Text
workbookId = Text
a} :: BatchUpsertTableRows)

-- | The ID of the table where the rows are being upserted.
--
-- If a table with the specified id could not be found, this API throws
-- ResourceNotFoundException.
batchUpsertTableRows_tableId :: Lens.Lens' BatchUpsertTableRows Prelude.Text
batchUpsertTableRows_tableId :: Lens' BatchUpsertTableRows Text
batchUpsertTableRows_tableId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpsertTableRows' {Text
tableId :: Text
$sel:tableId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
tableId} -> Text
tableId) (\s :: BatchUpsertTableRows
s@BatchUpsertTableRows' {} Text
a -> BatchUpsertTableRows
s {$sel:tableId:BatchUpsertTableRows' :: Text
tableId = Text
a} :: BatchUpsertTableRows)

-- | The list of rows to upsert in the table. Each item in this list needs to
-- have a batch item id to uniquely identify the element in the request, a
-- filter expression to find the rows to update for that element and the
-- cell values to set for each column in the upserted rows. You need to
-- specify at least one item in this list.
--
-- Note that if one of the filter formulas in the request fails to evaluate
-- because of an error or one of the column ids in any of the rows does not
-- exist in the table, then the request fails and no updates are made to
-- the table.
batchUpsertTableRows_rowsToUpsert :: Lens.Lens' BatchUpsertTableRows [UpsertRowData]
batchUpsertTableRows_rowsToUpsert :: Lens' BatchUpsertTableRows [UpsertRowData]
batchUpsertTableRows_rowsToUpsert = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpsertTableRows' {[UpsertRowData]
rowsToUpsert :: [UpsertRowData]
$sel:rowsToUpsert:BatchUpsertTableRows' :: BatchUpsertTableRows -> [UpsertRowData]
rowsToUpsert} -> [UpsertRowData]
rowsToUpsert) (\s :: BatchUpsertTableRows
s@BatchUpsertTableRows' {} [UpsertRowData]
a -> BatchUpsertTableRows
s {$sel:rowsToUpsert:BatchUpsertTableRows' :: [UpsertRowData]
rowsToUpsert = [UpsertRowData]
a} :: BatchUpsertTableRows) 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 Core.AWSRequest BatchUpsertTableRows where
  type
    AWSResponse BatchUpsertTableRows =
      BatchUpsertTableRowsResponse
  request :: (Service -> Service)
-> BatchUpsertTableRows -> Request BatchUpsertTableRows
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy BatchUpsertTableRows
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchUpsertTableRows)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [FailedBatchItem]
-> Int
-> HashMap Text UpsertRowsResult
-> Integer
-> BatchUpsertTableRowsResponse
BatchUpsertTableRowsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"failedBatchItems"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"rows" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"workbookCursor")
      )

instance Prelude.Hashable BatchUpsertTableRows where
  hashWithSalt :: Int -> BatchUpsertTableRows -> Int
hashWithSalt Int
_salt BatchUpsertTableRows' {[UpsertRowData]
Maybe Text
Text
rowsToUpsert :: [UpsertRowData]
tableId :: Text
workbookId :: Text
clientRequestToken :: Maybe Text
$sel:rowsToUpsert:BatchUpsertTableRows' :: BatchUpsertTableRows -> [UpsertRowData]
$sel:tableId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
$sel:workbookId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
$sel:clientRequestToken:BatchUpsertTableRows' :: BatchUpsertTableRows -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientRequestToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
workbookId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [UpsertRowData]
rowsToUpsert

instance Prelude.NFData BatchUpsertTableRows where
  rnf :: BatchUpsertTableRows -> ()
rnf BatchUpsertTableRows' {[UpsertRowData]
Maybe Text
Text
rowsToUpsert :: [UpsertRowData]
tableId :: Text
workbookId :: Text
clientRequestToken :: Maybe Text
$sel:rowsToUpsert:BatchUpsertTableRows' :: BatchUpsertTableRows -> [UpsertRowData]
$sel:tableId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
$sel:workbookId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
$sel:clientRequestToken:BatchUpsertTableRows' :: BatchUpsertTableRows -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientRequestToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
workbookId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tableId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [UpsertRowData]
rowsToUpsert

instance Data.ToHeaders BatchUpsertTableRows where
  toHeaders :: BatchUpsertTableRows -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON BatchUpsertTableRows where
  toJSON :: BatchUpsertTableRows -> Value
toJSON BatchUpsertTableRows' {[UpsertRowData]
Maybe Text
Text
rowsToUpsert :: [UpsertRowData]
tableId :: Text
workbookId :: Text
clientRequestToken :: Maybe Text
$sel:rowsToUpsert:BatchUpsertTableRows' :: BatchUpsertTableRows -> [UpsertRowData]
$sel:tableId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
$sel:workbookId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
$sel:clientRequestToken:BatchUpsertTableRows' :: BatchUpsertTableRows -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientRequestToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientRequestToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"rowsToUpsert" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [UpsertRowData]
rowsToUpsert)
          ]
      )

instance Data.ToPath BatchUpsertTableRows where
  toPath :: BatchUpsertTableRows -> ByteString
toPath BatchUpsertTableRows' {[UpsertRowData]
Maybe Text
Text
rowsToUpsert :: [UpsertRowData]
tableId :: Text
workbookId :: Text
clientRequestToken :: Maybe Text
$sel:rowsToUpsert:BatchUpsertTableRows' :: BatchUpsertTableRows -> [UpsertRowData]
$sel:tableId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
$sel:workbookId:BatchUpsertTableRows' :: BatchUpsertTableRows -> Text
$sel:clientRequestToken:BatchUpsertTableRows' :: BatchUpsertTableRows -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/workbooks/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
workbookId,
        ByteString
"/tables/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
tableId,
        ByteString
"/rows/batchupsert"
      ]

instance Data.ToQuery BatchUpsertTableRows where
  toQuery :: BatchUpsertTableRows -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newBatchUpsertTableRowsResponse' smart constructor.
data BatchUpsertTableRowsResponse = BatchUpsertTableRowsResponse'
  { -- | The list of batch items in the request that could not be updated or
    -- appended in the table. Each element in this list contains one item from
    -- the request that could not be updated in the table along with the reason
    -- why that item could not be updated or appended.
    BatchUpsertTableRowsResponse -> Maybe [FailedBatchItem]
failedBatchItems :: Prelude.Maybe [FailedBatchItem],
    -- | The response's http status code.
    BatchUpsertTableRowsResponse -> Int
httpStatus :: Prelude.Int,
    -- | A map with the batch item id as the key and the result of the upsert
    -- operation as the value. The result of the upsert operation specifies
    -- whether existing rows were updated or a new row was appended, along with
    -- the list of row ids that were affected.
    BatchUpsertTableRowsResponse -> HashMap Text UpsertRowsResult
rows :: Prelude.HashMap Prelude.Text UpsertRowsResult,
    -- | The updated workbook cursor after updating or appending rows in the
    -- table.
    BatchUpsertTableRowsResponse -> Integer
workbookCursor :: Prelude.Integer
  }
  deriving (BatchUpsertTableRowsResponse
-> BatchUpsertTableRowsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchUpsertTableRowsResponse
-> BatchUpsertTableRowsResponse -> Bool
$c/= :: BatchUpsertTableRowsResponse
-> BatchUpsertTableRowsResponse -> Bool
== :: BatchUpsertTableRowsResponse
-> BatchUpsertTableRowsResponse -> Bool
$c== :: BatchUpsertTableRowsResponse
-> BatchUpsertTableRowsResponse -> Bool
Prelude.Eq, ReadPrec [BatchUpsertTableRowsResponse]
ReadPrec BatchUpsertTableRowsResponse
Int -> ReadS BatchUpsertTableRowsResponse
ReadS [BatchUpsertTableRowsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchUpsertTableRowsResponse]
$creadListPrec :: ReadPrec [BatchUpsertTableRowsResponse]
readPrec :: ReadPrec BatchUpsertTableRowsResponse
$creadPrec :: ReadPrec BatchUpsertTableRowsResponse
readList :: ReadS [BatchUpsertTableRowsResponse]
$creadList :: ReadS [BatchUpsertTableRowsResponse]
readsPrec :: Int -> ReadS BatchUpsertTableRowsResponse
$creadsPrec :: Int -> ReadS BatchUpsertTableRowsResponse
Prelude.Read, Int -> BatchUpsertTableRowsResponse -> ShowS
[BatchUpsertTableRowsResponse] -> ShowS
BatchUpsertTableRowsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchUpsertTableRowsResponse] -> ShowS
$cshowList :: [BatchUpsertTableRowsResponse] -> ShowS
show :: BatchUpsertTableRowsResponse -> String
$cshow :: BatchUpsertTableRowsResponse -> String
showsPrec :: Int -> BatchUpsertTableRowsResponse -> ShowS
$cshowsPrec :: Int -> BatchUpsertTableRowsResponse -> ShowS
Prelude.Show, forall x.
Rep BatchUpsertTableRowsResponse x -> BatchUpsertTableRowsResponse
forall x.
BatchUpsertTableRowsResponse -> Rep BatchUpsertTableRowsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchUpsertTableRowsResponse x -> BatchUpsertTableRowsResponse
$cfrom :: forall x.
BatchUpsertTableRowsResponse -> Rep BatchUpsertTableRowsResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchUpsertTableRowsResponse' 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:
--
-- 'failedBatchItems', 'batchUpsertTableRowsResponse_failedBatchItems' - The list of batch items in the request that could not be updated or
-- appended in the table. Each element in this list contains one item from
-- the request that could not be updated in the table along with the reason
-- why that item could not be updated or appended.
--
-- 'httpStatus', 'batchUpsertTableRowsResponse_httpStatus' - The response's http status code.
--
-- 'rows', 'batchUpsertTableRowsResponse_rows' - A map with the batch item id as the key and the result of the upsert
-- operation as the value. The result of the upsert operation specifies
-- whether existing rows were updated or a new row was appended, along with
-- the list of row ids that were affected.
--
-- 'workbookCursor', 'batchUpsertTableRowsResponse_workbookCursor' - The updated workbook cursor after updating or appending rows in the
-- table.
newBatchUpsertTableRowsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'workbookCursor'
  Prelude.Integer ->
  BatchUpsertTableRowsResponse
newBatchUpsertTableRowsResponse :: Int -> Integer -> BatchUpsertTableRowsResponse
newBatchUpsertTableRowsResponse
  Int
pHttpStatus_
  Integer
pWorkbookCursor_ =
    BatchUpsertTableRowsResponse'
      { $sel:failedBatchItems:BatchUpsertTableRowsResponse' :: Maybe [FailedBatchItem]
failedBatchItems =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:BatchUpsertTableRowsResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:rows:BatchUpsertTableRowsResponse' :: HashMap Text UpsertRowsResult
rows = forall a. Monoid a => a
Prelude.mempty,
        $sel:workbookCursor:BatchUpsertTableRowsResponse' :: Integer
workbookCursor = Integer
pWorkbookCursor_
      }

-- | The list of batch items in the request that could not be updated or
-- appended in the table. Each element in this list contains one item from
-- the request that could not be updated in the table along with the reason
-- why that item could not be updated or appended.
batchUpsertTableRowsResponse_failedBatchItems :: Lens.Lens' BatchUpsertTableRowsResponse (Prelude.Maybe [FailedBatchItem])
batchUpsertTableRowsResponse_failedBatchItems :: Lens' BatchUpsertTableRowsResponse (Maybe [FailedBatchItem])
batchUpsertTableRowsResponse_failedBatchItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpsertTableRowsResponse' {Maybe [FailedBatchItem]
failedBatchItems :: Maybe [FailedBatchItem]
$sel:failedBatchItems:BatchUpsertTableRowsResponse' :: BatchUpsertTableRowsResponse -> Maybe [FailedBatchItem]
failedBatchItems} -> Maybe [FailedBatchItem]
failedBatchItems) (\s :: BatchUpsertTableRowsResponse
s@BatchUpsertTableRowsResponse' {} Maybe [FailedBatchItem]
a -> BatchUpsertTableRowsResponse
s {$sel:failedBatchItems:BatchUpsertTableRowsResponse' :: Maybe [FailedBatchItem]
failedBatchItems = Maybe [FailedBatchItem]
a} :: BatchUpsertTableRowsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
batchUpsertTableRowsResponse_httpStatus :: Lens.Lens' BatchUpsertTableRowsResponse Prelude.Int
batchUpsertTableRowsResponse_httpStatus :: Lens' BatchUpsertTableRowsResponse Int
batchUpsertTableRowsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpsertTableRowsResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchUpsertTableRowsResponse' :: BatchUpsertTableRowsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchUpsertTableRowsResponse
s@BatchUpsertTableRowsResponse' {} Int
a -> BatchUpsertTableRowsResponse
s {$sel:httpStatus:BatchUpsertTableRowsResponse' :: Int
httpStatus = Int
a} :: BatchUpsertTableRowsResponse)

-- | A map with the batch item id as the key and the result of the upsert
-- operation as the value. The result of the upsert operation specifies
-- whether existing rows were updated or a new row was appended, along with
-- the list of row ids that were affected.
batchUpsertTableRowsResponse_rows :: Lens.Lens' BatchUpsertTableRowsResponse (Prelude.HashMap Prelude.Text UpsertRowsResult)
batchUpsertTableRowsResponse_rows :: Lens' BatchUpsertTableRowsResponse (HashMap Text UpsertRowsResult)
batchUpsertTableRowsResponse_rows = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpsertTableRowsResponse' {HashMap Text UpsertRowsResult
rows :: HashMap Text UpsertRowsResult
$sel:rows:BatchUpsertTableRowsResponse' :: BatchUpsertTableRowsResponse -> HashMap Text UpsertRowsResult
rows} -> HashMap Text UpsertRowsResult
rows) (\s :: BatchUpsertTableRowsResponse
s@BatchUpsertTableRowsResponse' {} HashMap Text UpsertRowsResult
a -> BatchUpsertTableRowsResponse
s {$sel:rows:BatchUpsertTableRowsResponse' :: HashMap Text UpsertRowsResult
rows = HashMap Text UpsertRowsResult
a} :: BatchUpsertTableRowsResponse) 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

-- | The updated workbook cursor after updating or appending rows in the
-- table.
batchUpsertTableRowsResponse_workbookCursor :: Lens.Lens' BatchUpsertTableRowsResponse Prelude.Integer
batchUpsertTableRowsResponse_workbookCursor :: Lens' BatchUpsertTableRowsResponse Integer
batchUpsertTableRowsResponse_workbookCursor = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpsertTableRowsResponse' {Integer
workbookCursor :: Integer
$sel:workbookCursor:BatchUpsertTableRowsResponse' :: BatchUpsertTableRowsResponse -> Integer
workbookCursor} -> Integer
workbookCursor) (\s :: BatchUpsertTableRowsResponse
s@BatchUpsertTableRowsResponse' {} Integer
a -> BatchUpsertTableRowsResponse
s {$sel:workbookCursor:BatchUpsertTableRowsResponse' :: Integer
workbookCursor = Integer
a} :: BatchUpsertTableRowsResponse)

instance Prelude.NFData BatchUpsertTableRowsResponse where
  rnf :: BatchUpsertTableRowsResponse -> ()
rnf BatchUpsertTableRowsResponse' {Int
Integer
Maybe [FailedBatchItem]
HashMap Text UpsertRowsResult
workbookCursor :: Integer
rows :: HashMap Text UpsertRowsResult
httpStatus :: Int
failedBatchItems :: Maybe [FailedBatchItem]
$sel:workbookCursor:BatchUpsertTableRowsResponse' :: BatchUpsertTableRowsResponse -> Integer
$sel:rows:BatchUpsertTableRowsResponse' :: BatchUpsertTableRowsResponse -> HashMap Text UpsertRowsResult
$sel:httpStatus:BatchUpsertTableRowsResponse' :: BatchUpsertTableRowsResponse -> Int
$sel:failedBatchItems:BatchUpsertTableRowsResponse' :: BatchUpsertTableRowsResponse -> Maybe [FailedBatchItem]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FailedBatchItem]
failedBatchItems
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text UpsertRowsResult
rows
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
workbookCursor