{-# 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-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)
--
-- 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 Amazonka.HoneyCode.Types
import qualified Amazonka.Lens as Lens
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
(BatchUpsertTableRows -> BatchUpsertTableRows -> Bool)
-> (BatchUpsertTableRows -> BatchUpsertTableRows -> Bool)
-> Eq BatchUpsertTableRows
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
(Int -> BatchUpsertTableRows -> ShowS)
-> (BatchUpsertTableRows -> String)
-> ([BatchUpsertTableRows] -> ShowS)
-> Show BatchUpsertTableRows
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. BatchUpsertTableRows -> Rep BatchUpsertTableRows x)
-> (forall x. Rep BatchUpsertTableRows x -> BatchUpsertTableRows)
-> Generic BatchUpsertTableRows
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' :: Maybe Text
-> Text -> Text -> [UpsertRowData] -> BatchUpsertTableRows
BatchUpsertTableRows'
    { $sel:clientRequestToken:BatchUpsertTableRows' :: Maybe Text
clientRequestToken =
        Maybe Text
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 = [UpsertRowData]
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 :: (Maybe Text -> f (Maybe Text))
-> BatchUpsertTableRows -> f BatchUpsertTableRows
batchUpsertTableRows_clientRequestToken = (BatchUpsertTableRows -> Maybe Text)
-> (BatchUpsertTableRows -> Maybe Text -> BatchUpsertTableRows)
-> Lens
     BatchUpsertTableRows BatchUpsertTableRows (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> BatchUpsertTableRows -> f BatchUpsertTableRows
batchUpsertTableRows_workbookId = (BatchUpsertTableRows -> Text)
-> (BatchUpsertTableRows -> Text -> BatchUpsertTableRows)
-> Lens BatchUpsertTableRows BatchUpsertTableRows Text Text
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 :: (Text -> f Text) -> BatchUpsertTableRows -> f BatchUpsertTableRows
batchUpsertTableRows_tableId = (BatchUpsertTableRows -> Text)
-> (BatchUpsertTableRows -> Text -> BatchUpsertTableRows)
-> Lens BatchUpsertTableRows BatchUpsertTableRows Text Text
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 :: ([UpsertRowData] -> f [UpsertRowData])
-> BatchUpsertTableRows -> f BatchUpsertTableRows
batchUpsertTableRows_rowsToUpsert = (BatchUpsertTableRows -> [UpsertRowData])
-> (BatchUpsertTableRows
    -> [UpsertRowData] -> BatchUpsertTableRows)
-> Lens
     BatchUpsertTableRows
     BatchUpsertTableRows
     [UpsertRowData]
     [UpsertRowData]
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) (([UpsertRowData] -> f [UpsertRowData])
 -> BatchUpsertTableRows -> f BatchUpsertTableRows)
-> (([UpsertRowData] -> f [UpsertRowData])
    -> [UpsertRowData] -> f [UpsertRowData])
-> ([UpsertRowData] -> f [UpsertRowData])
-> BatchUpsertTableRows
-> f BatchUpsertTableRows
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UpsertRowData] -> f [UpsertRowData])
-> [UpsertRowData] -> f [UpsertRowData]
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 :: BatchUpsertTableRows -> Request BatchUpsertTableRows
request = Service -> BatchUpsertTableRows -> Request BatchUpsertTableRows
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchUpsertTableRows
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchUpsertTableRows)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchUpsertTableRows))
-> Logger
-> Service
-> Proxy BatchUpsertTableRows
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchUpsertTableRows)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe [FailedBatchItem]
 -> Int
 -> HashMap Text UpsertRowsResult
 -> Integer
 -> BatchUpsertTableRowsResponse)
-> Either String (Maybe [FailedBatchItem])
-> Either
     String
     (Int
      -> HashMap Text UpsertRowsResult
      -> Integer
      -> BatchUpsertTableRowsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [FailedBatchItem]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"failedBatchItems"
                            Either String (Maybe (Maybe [FailedBatchItem]))
-> Maybe [FailedBatchItem]
-> Either String (Maybe [FailedBatchItem])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [FailedBatchItem]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String
  (Int
   -> HashMap Text UpsertRowsResult
   -> Integer
   -> BatchUpsertTableRowsResponse)
-> Either String Int
-> Either
     String
     (HashMap Text UpsertRowsResult
      -> Integer -> BatchUpsertTableRowsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String
  (HashMap Text UpsertRowsResult
   -> Integer -> BatchUpsertTableRowsResponse)
-> Either String (HashMap Text UpsertRowsResult)
-> Either String (Integer -> BatchUpsertTableRowsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe (HashMap Text UpsertRowsResult))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"rows" Either String (Maybe (HashMap Text UpsertRowsResult))
-> HashMap Text UpsertRowsResult
-> Either String (HashMap Text UpsertRowsResult)
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ HashMap Text UpsertRowsResult
forall a. Monoid a => a
Prelude.mempty)
            Either String (Integer -> BatchUpsertTableRowsResponse)
-> Either String Integer
-> Either String BatchUpsertTableRowsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Integer
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"workbookCursor")
      )

instance Prelude.Hashable BatchUpsertTableRows

instance Prelude.NFData BatchUpsertTableRows

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"clientRequestToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientRequestToken,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"rowsToUpsert" Text -> [UpsertRowData] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [UpsertRowData]
rowsToUpsert)
          ]
      )

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/workbooks/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
workbookId,
        ByteString
"/tables/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
tableId,
        ByteString
"/rows/batchupsert"
      ]

instance Core.ToQuery BatchUpsertTableRows where
  toQuery :: BatchUpsertTableRows -> QueryString
toQuery = QueryString -> BatchUpsertTableRows -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(BatchUpsertTableRowsResponse
 -> BatchUpsertTableRowsResponse -> Bool)
-> (BatchUpsertTableRowsResponse
    -> BatchUpsertTableRowsResponse -> Bool)
-> Eq BatchUpsertTableRowsResponse
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]
(Int -> ReadS BatchUpsertTableRowsResponse)
-> ReadS [BatchUpsertTableRowsResponse]
-> ReadPrec BatchUpsertTableRowsResponse
-> ReadPrec [BatchUpsertTableRowsResponse]
-> Read 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
(Int -> BatchUpsertTableRowsResponse -> ShowS)
-> (BatchUpsertTableRowsResponse -> String)
-> ([BatchUpsertTableRowsResponse] -> ShowS)
-> Show BatchUpsertTableRowsResponse
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.
 BatchUpsertTableRowsResponse -> Rep BatchUpsertTableRowsResponse x)
-> (forall x.
    Rep BatchUpsertTableRowsResponse x -> BatchUpsertTableRowsResponse)
-> Generic BatchUpsertTableRowsResponse
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' :: Maybe [FailedBatchItem]
-> Int
-> HashMap Text UpsertRowsResult
-> Integer
-> BatchUpsertTableRowsResponse
BatchUpsertTableRowsResponse'
      { $sel:failedBatchItems:BatchUpsertTableRowsResponse' :: Maybe [FailedBatchItem]
failedBatchItems =
          Maybe [FailedBatchItem]
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:BatchUpsertTableRowsResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:rows:BatchUpsertTableRowsResponse' :: HashMap Text UpsertRowsResult
rows = HashMap Text UpsertRowsResult
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 :: (Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
-> BatchUpsertTableRowsResponse -> f BatchUpsertTableRowsResponse
batchUpsertTableRowsResponse_failedBatchItems = (BatchUpsertTableRowsResponse -> Maybe [FailedBatchItem])
-> (BatchUpsertTableRowsResponse
    -> Maybe [FailedBatchItem] -> BatchUpsertTableRowsResponse)
-> Lens
     BatchUpsertTableRowsResponse
     BatchUpsertTableRowsResponse
     (Maybe [FailedBatchItem])
     (Maybe [FailedBatchItem])
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) ((Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
 -> BatchUpsertTableRowsResponse -> f BatchUpsertTableRowsResponse)
-> ((Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
    -> Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
-> (Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
-> BatchUpsertTableRowsResponse
-> f BatchUpsertTableRowsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [FailedBatchItem]
  [FailedBatchItem]
  [FailedBatchItem]
  [FailedBatchItem]
-> Iso
     (Maybe [FailedBatchItem])
     (Maybe [FailedBatchItem])
     (Maybe [FailedBatchItem])
     (Maybe [FailedBatchItem])
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 AnIso
  [FailedBatchItem]
  [FailedBatchItem]
  [FailedBatchItem]
  [FailedBatchItem]
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 :: (Int -> f Int)
-> BatchUpsertTableRowsResponse -> f BatchUpsertTableRowsResponse
batchUpsertTableRowsResponse_httpStatus = (BatchUpsertTableRowsResponse -> Int)
-> (BatchUpsertTableRowsResponse
    -> Int -> BatchUpsertTableRowsResponse)
-> Lens
     BatchUpsertTableRowsResponse BatchUpsertTableRowsResponse Int Int
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 :: (HashMap Text UpsertRowsResult
 -> f (HashMap Text UpsertRowsResult))
-> BatchUpsertTableRowsResponse -> f BatchUpsertTableRowsResponse
batchUpsertTableRowsResponse_rows = (BatchUpsertTableRowsResponse -> HashMap Text UpsertRowsResult)
-> (BatchUpsertTableRowsResponse
    -> HashMap Text UpsertRowsResult -> BatchUpsertTableRowsResponse)
-> Lens
     BatchUpsertTableRowsResponse
     BatchUpsertTableRowsResponse
     (HashMap Text UpsertRowsResult)
     (HashMap Text UpsertRowsResult)
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) ((HashMap Text UpsertRowsResult
  -> f (HashMap Text UpsertRowsResult))
 -> BatchUpsertTableRowsResponse -> f BatchUpsertTableRowsResponse)
-> ((HashMap Text UpsertRowsResult
     -> f (HashMap Text UpsertRowsResult))
    -> HashMap Text UpsertRowsResult
    -> f (HashMap Text UpsertRowsResult))
-> (HashMap Text UpsertRowsResult
    -> f (HashMap Text UpsertRowsResult))
-> BatchUpsertTableRowsResponse
-> f BatchUpsertTableRowsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text UpsertRowsResult
 -> f (HashMap Text UpsertRowsResult))
-> HashMap Text UpsertRowsResult
-> f (HashMap Text UpsertRowsResult)
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 :: (Integer -> f Integer)
-> BatchUpsertTableRowsResponse -> f BatchUpsertTableRowsResponse
batchUpsertTableRowsResponse_workbookCursor = (BatchUpsertTableRowsResponse -> Integer)
-> (BatchUpsertTableRowsResponse
    -> Integer -> BatchUpsertTableRowsResponse)
-> Lens
     BatchUpsertTableRowsResponse
     BatchUpsertTableRowsResponse
     Integer
     Integer
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