{-# 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.BatchCreateTableRows
-- 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 BatchCreateTableRows API allows you to create one or more rows at
-- the end of a table in a workbook. The API allows you to specify the
-- values to set in some or all of the columns in the new rows.
--
-- If a column is not explicitly set in a specific row, then the column
-- level formula specified in the table will be applied to the new row. If
-- there is no column level formula but the last row of the table has a
-- formula, then that formula will be copied down to the new row. If there
-- is no column level formula and no formula in the last row of the table,
-- then that column will be left blank for the new rows.
module Amazonka.HoneyCode.BatchCreateTableRows
  ( -- * Creating a Request
    BatchCreateTableRows (..),
    newBatchCreateTableRows,

    -- * Request Lenses
    batchCreateTableRows_clientRequestToken,
    batchCreateTableRows_workbookId,
    batchCreateTableRows_tableId,
    batchCreateTableRows_rowsToCreate,

    -- * Destructuring the Response
    BatchCreateTableRowsResponse (..),
    newBatchCreateTableRowsResponse,

    -- * Response Lenses
    batchCreateTableRowsResponse_failedBatchItems,
    batchCreateTableRowsResponse_httpStatus,
    batchCreateTableRowsResponse_workbookCursor,
    batchCreateTableRowsResponse_createdRows,
  )
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:/ 'newBatchCreateTableRows' smart constructor.
data BatchCreateTableRows = BatchCreateTableRows'
  { -- | The request token for performing the batch create operation. 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 operation again.
    --
    -- Note that request tokens are valid only for a few minutes. You cannot
    -- use request tokens to dedupe requests spanning hours or days.
    BatchCreateTableRows -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
    -- | The ID of the workbook where the new rows are being added.
    --
    -- If a workbook with the specified ID could not be found, this API throws
    -- ResourceNotFoundException.
    BatchCreateTableRows -> Text
workbookId :: Prelude.Text,
    -- | The ID of the table where the new rows are being added.
    --
    -- If a table with the specified ID could not be found, this API throws
    -- ResourceNotFoundException.
    BatchCreateTableRows -> Text
tableId :: Prelude.Text,
    -- | The list of rows to create at the end of the table. Each item in this
    -- list needs to have a batch item id to uniquely identify the element in
    -- the request and the cells to create for that row. You need to specify at
    -- least one item in this list.
    --
    -- Note that if one of the column ids in any of the rows in the request
    -- does not exist in the table, then the request fails and no updates are
    -- made to the table.
    BatchCreateTableRows -> NonEmpty CreateRowData
rowsToCreate :: Prelude.NonEmpty CreateRowData
  }
  deriving (BatchCreateTableRows -> BatchCreateTableRows -> Bool
(BatchCreateTableRows -> BatchCreateTableRows -> Bool)
-> (BatchCreateTableRows -> BatchCreateTableRows -> Bool)
-> Eq BatchCreateTableRows
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreateTableRows -> BatchCreateTableRows -> Bool
$c/= :: BatchCreateTableRows -> BatchCreateTableRows -> Bool
== :: BatchCreateTableRows -> BatchCreateTableRows -> Bool
$c== :: BatchCreateTableRows -> BatchCreateTableRows -> Bool
Prelude.Eq, Int -> BatchCreateTableRows -> ShowS
[BatchCreateTableRows] -> ShowS
BatchCreateTableRows -> String
(Int -> BatchCreateTableRows -> ShowS)
-> (BatchCreateTableRows -> String)
-> ([BatchCreateTableRows] -> ShowS)
-> Show BatchCreateTableRows
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreateTableRows] -> ShowS
$cshowList :: [BatchCreateTableRows] -> ShowS
show :: BatchCreateTableRows -> String
$cshow :: BatchCreateTableRows -> String
showsPrec :: Int -> BatchCreateTableRows -> ShowS
$cshowsPrec :: Int -> BatchCreateTableRows -> ShowS
Prelude.Show, (forall x. BatchCreateTableRows -> Rep BatchCreateTableRows x)
-> (forall x. Rep BatchCreateTableRows x -> BatchCreateTableRows)
-> Generic BatchCreateTableRows
forall x. Rep BatchCreateTableRows x -> BatchCreateTableRows
forall x. BatchCreateTableRows -> Rep BatchCreateTableRows x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchCreateTableRows x -> BatchCreateTableRows
$cfrom :: forall x. BatchCreateTableRows -> Rep BatchCreateTableRows x
Prelude.Generic)

-- |
-- Create a value of 'BatchCreateTableRows' 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', 'batchCreateTableRows_clientRequestToken' - The request token for performing the batch create operation. 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 operation 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', 'batchCreateTableRows_workbookId' - The ID of the workbook where the new rows are being added.
--
-- If a workbook with the specified ID could not be found, this API throws
-- ResourceNotFoundException.
--
-- 'tableId', 'batchCreateTableRows_tableId' - The ID of the table where the new rows are being added.
--
-- If a table with the specified ID could not be found, this API throws
-- ResourceNotFoundException.
--
-- 'rowsToCreate', 'batchCreateTableRows_rowsToCreate' - The list of rows to create at the end of the table. Each item in this
-- list needs to have a batch item id to uniquely identify the element in
-- the request and the cells to create for that row. You need to specify at
-- least one item in this list.
--
-- Note that if one of the column ids in any of the rows in the request
-- does not exist in the table, then the request fails and no updates are
-- made to the table.
newBatchCreateTableRows ::
  -- | 'workbookId'
  Prelude.Text ->
  -- | 'tableId'
  Prelude.Text ->
  -- | 'rowsToCreate'
  Prelude.NonEmpty CreateRowData ->
  BatchCreateTableRows
newBatchCreateTableRows :: Text -> Text -> NonEmpty CreateRowData -> BatchCreateTableRows
newBatchCreateTableRows
  Text
pWorkbookId_
  Text
pTableId_
  NonEmpty CreateRowData
pRowsToCreate_ =
    BatchCreateTableRows' :: Maybe Text
-> Text -> Text -> NonEmpty CreateRowData -> BatchCreateTableRows
BatchCreateTableRows'
      { $sel:clientRequestToken:BatchCreateTableRows' :: Maybe Text
clientRequestToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:workbookId:BatchCreateTableRows' :: Text
workbookId = Text
pWorkbookId_,
        $sel:tableId:BatchCreateTableRows' :: Text
tableId = Text
pTableId_,
        $sel:rowsToCreate:BatchCreateTableRows' :: NonEmpty CreateRowData
rowsToCreate = Tagged (NonEmpty CreateRowData) (Identity (NonEmpty CreateRowData))
-> Tagged
     (NonEmpty CreateRowData) (Identity (NonEmpty CreateRowData))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty CreateRowData) (Identity (NonEmpty CreateRowData))
 -> Tagged
      (NonEmpty CreateRowData) (Identity (NonEmpty CreateRowData)))
-> NonEmpty CreateRowData -> NonEmpty CreateRowData
forall t b. AReview t b -> b -> t
Lens.# NonEmpty CreateRowData
pRowsToCreate_
      }

-- | The request token for performing the batch create operation. 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 operation again.
--
-- Note that request tokens are valid only for a few minutes. You cannot
-- use request tokens to dedupe requests spanning hours or days.
batchCreateTableRows_clientRequestToken :: Lens.Lens' BatchCreateTableRows (Prelude.Maybe Prelude.Text)
batchCreateTableRows_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> BatchCreateTableRows -> f BatchCreateTableRows
batchCreateTableRows_clientRequestToken = (BatchCreateTableRows -> Maybe Text)
-> (BatchCreateTableRows -> Maybe Text -> BatchCreateTableRows)
-> Lens
     BatchCreateTableRows BatchCreateTableRows (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateTableRows' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:BatchCreateTableRows' :: BatchCreateTableRows -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: BatchCreateTableRows
s@BatchCreateTableRows' {} Maybe Text
a -> BatchCreateTableRows
s {$sel:clientRequestToken:BatchCreateTableRows' :: Maybe Text
clientRequestToken = Maybe Text
a} :: BatchCreateTableRows)

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

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

-- | The list of rows to create at the end of the table. Each item in this
-- list needs to have a batch item id to uniquely identify the element in
-- the request and the cells to create for that row. You need to specify at
-- least one item in this list.
--
-- Note that if one of the column ids in any of the rows in the request
-- does not exist in the table, then the request fails and no updates are
-- made to the table.
batchCreateTableRows_rowsToCreate :: Lens.Lens' BatchCreateTableRows (Prelude.NonEmpty CreateRowData)
batchCreateTableRows_rowsToCreate :: (NonEmpty CreateRowData -> f (NonEmpty CreateRowData))
-> BatchCreateTableRows -> f BatchCreateTableRows
batchCreateTableRows_rowsToCreate = (BatchCreateTableRows -> NonEmpty CreateRowData)
-> (BatchCreateTableRows
    -> NonEmpty CreateRowData -> BatchCreateTableRows)
-> Lens
     BatchCreateTableRows
     BatchCreateTableRows
     (NonEmpty CreateRowData)
     (NonEmpty CreateRowData)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateTableRows' {NonEmpty CreateRowData
rowsToCreate :: NonEmpty CreateRowData
$sel:rowsToCreate:BatchCreateTableRows' :: BatchCreateTableRows -> NonEmpty CreateRowData
rowsToCreate} -> NonEmpty CreateRowData
rowsToCreate) (\s :: BatchCreateTableRows
s@BatchCreateTableRows' {} NonEmpty CreateRowData
a -> BatchCreateTableRows
s {$sel:rowsToCreate:BatchCreateTableRows' :: NonEmpty CreateRowData
rowsToCreate = NonEmpty CreateRowData
a} :: BatchCreateTableRows) ((NonEmpty CreateRowData -> f (NonEmpty CreateRowData))
 -> BatchCreateTableRows -> f BatchCreateTableRows)
-> ((NonEmpty CreateRowData -> f (NonEmpty CreateRowData))
    -> NonEmpty CreateRowData -> f (NonEmpty CreateRowData))
-> (NonEmpty CreateRowData -> f (NonEmpty CreateRowData))
-> BatchCreateTableRows
-> f BatchCreateTableRows
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty CreateRowData -> f (NonEmpty CreateRowData))
-> NonEmpty CreateRowData -> f (NonEmpty CreateRowData)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchCreateTableRows where
  type
    AWSResponse BatchCreateTableRows =
      BatchCreateTableRowsResponse
  request :: BatchCreateTableRows -> Request BatchCreateTableRows
request = Service -> BatchCreateTableRows -> Request BatchCreateTableRows
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchCreateTableRows
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchCreateTableRows)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchCreateTableRows))
-> Logger
-> Service
-> Proxy BatchCreateTableRows
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchCreateTableRows)))
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
-> Integer
-> HashMap Text Text
-> BatchCreateTableRowsResponse
BatchCreateTableRowsResponse'
            (Maybe [FailedBatchItem]
 -> Int
 -> Integer
 -> HashMap Text Text
 -> BatchCreateTableRowsResponse)
-> Either String (Maybe [FailedBatchItem])
-> Either
     String
     (Int
      -> Integer -> HashMap Text Text -> BatchCreateTableRowsResponse)
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
   -> Integer -> HashMap Text Text -> BatchCreateTableRowsResponse)
-> Either String Int
-> Either
     String
     (Integer -> HashMap Text Text -> BatchCreateTableRowsResponse)
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
  (Integer -> HashMap Text Text -> BatchCreateTableRowsResponse)
-> Either String Integer
-> Either
     String (HashMap Text Text -> BatchCreateTableRowsResponse)
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")
            Either String (HashMap Text Text -> BatchCreateTableRowsResponse)
-> Either String (HashMap Text Text)
-> Either String BatchCreateTableRowsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (HashMap Text Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"createdRows" Either String (Maybe (HashMap Text Text))
-> HashMap Text Text -> Either String (HashMap Text Text)
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ HashMap Text Text
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable BatchCreateTableRows

instance Prelude.NFData BatchCreateTableRows

instance Core.ToHeaders BatchCreateTableRows where
  toHeaders :: BatchCreateTableRows -> ResponseHeaders
toHeaders =
    ResponseHeaders -> BatchCreateTableRows -> 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 BatchCreateTableRows where
  toJSON :: BatchCreateTableRows -> Value
toJSON BatchCreateTableRows' {Maybe Text
NonEmpty CreateRowData
Text
rowsToCreate :: NonEmpty CreateRowData
tableId :: Text
workbookId :: Text
clientRequestToken :: Maybe Text
$sel:rowsToCreate:BatchCreateTableRows' :: BatchCreateTableRows -> NonEmpty CreateRowData
$sel:tableId:BatchCreateTableRows' :: BatchCreateTableRows -> Text
$sel:workbookId:BatchCreateTableRows' :: BatchCreateTableRows -> Text
$sel:clientRequestToken:BatchCreateTableRows' :: BatchCreateTableRows -> 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
"rowsToCreate" Text -> NonEmpty CreateRowData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty CreateRowData
rowsToCreate)
          ]
      )

instance Core.ToPath BatchCreateTableRows where
  toPath :: BatchCreateTableRows -> ByteString
toPath BatchCreateTableRows' {Maybe Text
NonEmpty CreateRowData
Text
rowsToCreate :: NonEmpty CreateRowData
tableId :: Text
workbookId :: Text
clientRequestToken :: Maybe Text
$sel:rowsToCreate:BatchCreateTableRows' :: BatchCreateTableRows -> NonEmpty CreateRowData
$sel:tableId:BatchCreateTableRows' :: BatchCreateTableRows -> Text
$sel:workbookId:BatchCreateTableRows' :: BatchCreateTableRows -> Text
$sel:clientRequestToken:BatchCreateTableRows' :: BatchCreateTableRows -> 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/batchcreate"
      ]

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

-- | /See:/ 'newBatchCreateTableRowsResponse' smart constructor.
data BatchCreateTableRowsResponse = BatchCreateTableRowsResponse'
  { -- | The list of batch items in the request that could not be added to the
    -- table. Each element in this list contains one item from the request that
    -- could not be added to the table along with the reason why that item
    -- could not be added.
    BatchCreateTableRowsResponse -> Maybe [FailedBatchItem]
failedBatchItems :: Prelude.Maybe [FailedBatchItem],
    -- | The response's http status code.
    BatchCreateTableRowsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The updated workbook cursor after adding the new rows at the end of the
    -- table.
    BatchCreateTableRowsResponse -> Integer
workbookCursor :: Prelude.Integer,
    -- | The map of batch item id to the row id that was created for that item.
    BatchCreateTableRowsResponse -> HashMap Text Text
createdRows :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (BatchCreateTableRowsResponse
-> BatchCreateTableRowsResponse -> Bool
(BatchCreateTableRowsResponse
 -> BatchCreateTableRowsResponse -> Bool)
-> (BatchCreateTableRowsResponse
    -> BatchCreateTableRowsResponse -> Bool)
-> Eq BatchCreateTableRowsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreateTableRowsResponse
-> BatchCreateTableRowsResponse -> Bool
$c/= :: BatchCreateTableRowsResponse
-> BatchCreateTableRowsResponse -> Bool
== :: BatchCreateTableRowsResponse
-> BatchCreateTableRowsResponse -> Bool
$c== :: BatchCreateTableRowsResponse
-> BatchCreateTableRowsResponse -> Bool
Prelude.Eq, ReadPrec [BatchCreateTableRowsResponse]
ReadPrec BatchCreateTableRowsResponse
Int -> ReadS BatchCreateTableRowsResponse
ReadS [BatchCreateTableRowsResponse]
(Int -> ReadS BatchCreateTableRowsResponse)
-> ReadS [BatchCreateTableRowsResponse]
-> ReadPrec BatchCreateTableRowsResponse
-> ReadPrec [BatchCreateTableRowsResponse]
-> Read BatchCreateTableRowsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchCreateTableRowsResponse]
$creadListPrec :: ReadPrec [BatchCreateTableRowsResponse]
readPrec :: ReadPrec BatchCreateTableRowsResponse
$creadPrec :: ReadPrec BatchCreateTableRowsResponse
readList :: ReadS [BatchCreateTableRowsResponse]
$creadList :: ReadS [BatchCreateTableRowsResponse]
readsPrec :: Int -> ReadS BatchCreateTableRowsResponse
$creadsPrec :: Int -> ReadS BatchCreateTableRowsResponse
Prelude.Read, Int -> BatchCreateTableRowsResponse -> ShowS
[BatchCreateTableRowsResponse] -> ShowS
BatchCreateTableRowsResponse -> String
(Int -> BatchCreateTableRowsResponse -> ShowS)
-> (BatchCreateTableRowsResponse -> String)
-> ([BatchCreateTableRowsResponse] -> ShowS)
-> Show BatchCreateTableRowsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreateTableRowsResponse] -> ShowS
$cshowList :: [BatchCreateTableRowsResponse] -> ShowS
show :: BatchCreateTableRowsResponse -> String
$cshow :: BatchCreateTableRowsResponse -> String
showsPrec :: Int -> BatchCreateTableRowsResponse -> ShowS
$cshowsPrec :: Int -> BatchCreateTableRowsResponse -> ShowS
Prelude.Show, (forall x.
 BatchCreateTableRowsResponse -> Rep BatchCreateTableRowsResponse x)
-> (forall x.
    Rep BatchCreateTableRowsResponse x -> BatchCreateTableRowsResponse)
-> Generic BatchCreateTableRowsResponse
forall x.
Rep BatchCreateTableRowsResponse x -> BatchCreateTableRowsResponse
forall x.
BatchCreateTableRowsResponse -> Rep BatchCreateTableRowsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchCreateTableRowsResponse x -> BatchCreateTableRowsResponse
$cfrom :: forall x.
BatchCreateTableRowsResponse -> Rep BatchCreateTableRowsResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchCreateTableRowsResponse' 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', 'batchCreateTableRowsResponse_failedBatchItems' - The list of batch items in the request that could not be added to the
-- table. Each element in this list contains one item from the request that
-- could not be added to the table along with the reason why that item
-- could not be added.
--
-- 'httpStatus', 'batchCreateTableRowsResponse_httpStatus' - The response's http status code.
--
-- 'workbookCursor', 'batchCreateTableRowsResponse_workbookCursor' - The updated workbook cursor after adding the new rows at the end of the
-- table.
--
-- 'createdRows', 'batchCreateTableRowsResponse_createdRows' - The map of batch item id to the row id that was created for that item.
newBatchCreateTableRowsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'workbookCursor'
  Prelude.Integer ->
  BatchCreateTableRowsResponse
newBatchCreateTableRowsResponse :: Int -> Integer -> BatchCreateTableRowsResponse
newBatchCreateTableRowsResponse
  Int
pHttpStatus_
  Integer
pWorkbookCursor_ =
    BatchCreateTableRowsResponse' :: Maybe [FailedBatchItem]
-> Int
-> Integer
-> HashMap Text Text
-> BatchCreateTableRowsResponse
BatchCreateTableRowsResponse'
      { $sel:failedBatchItems:BatchCreateTableRowsResponse' :: Maybe [FailedBatchItem]
failedBatchItems =
          Maybe [FailedBatchItem]
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:BatchCreateTableRowsResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:workbookCursor:BatchCreateTableRowsResponse' :: Integer
workbookCursor = Integer
pWorkbookCursor_,
        $sel:createdRows:BatchCreateTableRowsResponse' :: HashMap Text Text
createdRows = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
      }

-- | The list of batch items in the request that could not be added to the
-- table. Each element in this list contains one item from the request that
-- could not be added to the table along with the reason why that item
-- could not be added.
batchCreateTableRowsResponse_failedBatchItems :: Lens.Lens' BatchCreateTableRowsResponse (Prelude.Maybe [FailedBatchItem])
batchCreateTableRowsResponse_failedBatchItems :: (Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
-> BatchCreateTableRowsResponse -> f BatchCreateTableRowsResponse
batchCreateTableRowsResponse_failedBatchItems = (BatchCreateTableRowsResponse -> Maybe [FailedBatchItem])
-> (BatchCreateTableRowsResponse
    -> Maybe [FailedBatchItem] -> BatchCreateTableRowsResponse)
-> Lens
     BatchCreateTableRowsResponse
     BatchCreateTableRowsResponse
     (Maybe [FailedBatchItem])
     (Maybe [FailedBatchItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateTableRowsResponse' {Maybe [FailedBatchItem]
failedBatchItems :: Maybe [FailedBatchItem]
$sel:failedBatchItems:BatchCreateTableRowsResponse' :: BatchCreateTableRowsResponse -> Maybe [FailedBatchItem]
failedBatchItems} -> Maybe [FailedBatchItem]
failedBatchItems) (\s :: BatchCreateTableRowsResponse
s@BatchCreateTableRowsResponse' {} Maybe [FailedBatchItem]
a -> BatchCreateTableRowsResponse
s {$sel:failedBatchItems:BatchCreateTableRowsResponse' :: Maybe [FailedBatchItem]
failedBatchItems = Maybe [FailedBatchItem]
a} :: BatchCreateTableRowsResponse) ((Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
 -> BatchCreateTableRowsResponse -> f BatchCreateTableRowsResponse)
-> ((Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
    -> Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
-> (Maybe [FailedBatchItem] -> f (Maybe [FailedBatchItem]))
-> BatchCreateTableRowsResponse
-> f BatchCreateTableRowsResponse
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.
batchCreateTableRowsResponse_httpStatus :: Lens.Lens' BatchCreateTableRowsResponse Prelude.Int
batchCreateTableRowsResponse_httpStatus :: (Int -> f Int)
-> BatchCreateTableRowsResponse -> f BatchCreateTableRowsResponse
batchCreateTableRowsResponse_httpStatus = (BatchCreateTableRowsResponse -> Int)
-> (BatchCreateTableRowsResponse
    -> Int -> BatchCreateTableRowsResponse)
-> Lens
     BatchCreateTableRowsResponse BatchCreateTableRowsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateTableRowsResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchCreateTableRowsResponse' :: BatchCreateTableRowsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchCreateTableRowsResponse
s@BatchCreateTableRowsResponse' {} Int
a -> BatchCreateTableRowsResponse
s {$sel:httpStatus:BatchCreateTableRowsResponse' :: Int
httpStatus = Int
a} :: BatchCreateTableRowsResponse)

-- | The updated workbook cursor after adding the new rows at the end of the
-- table.
batchCreateTableRowsResponse_workbookCursor :: Lens.Lens' BatchCreateTableRowsResponse Prelude.Integer
batchCreateTableRowsResponse_workbookCursor :: (Integer -> f Integer)
-> BatchCreateTableRowsResponse -> f BatchCreateTableRowsResponse
batchCreateTableRowsResponse_workbookCursor = (BatchCreateTableRowsResponse -> Integer)
-> (BatchCreateTableRowsResponse
    -> Integer -> BatchCreateTableRowsResponse)
-> Lens
     BatchCreateTableRowsResponse
     BatchCreateTableRowsResponse
     Integer
     Integer
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateTableRowsResponse' {Integer
workbookCursor :: Integer
$sel:workbookCursor:BatchCreateTableRowsResponse' :: BatchCreateTableRowsResponse -> Integer
workbookCursor} -> Integer
workbookCursor) (\s :: BatchCreateTableRowsResponse
s@BatchCreateTableRowsResponse' {} Integer
a -> BatchCreateTableRowsResponse
s {$sel:workbookCursor:BatchCreateTableRowsResponse' :: Integer
workbookCursor = Integer
a} :: BatchCreateTableRowsResponse)

-- | The map of batch item id to the row id that was created for that item.
batchCreateTableRowsResponse_createdRows :: Lens.Lens' BatchCreateTableRowsResponse (Prelude.HashMap Prelude.Text Prelude.Text)
batchCreateTableRowsResponse_createdRows :: (HashMap Text Text -> f (HashMap Text Text))
-> BatchCreateTableRowsResponse -> f BatchCreateTableRowsResponse
batchCreateTableRowsResponse_createdRows = (BatchCreateTableRowsResponse -> HashMap Text Text)
-> (BatchCreateTableRowsResponse
    -> HashMap Text Text -> BatchCreateTableRowsResponse)
-> Lens
     BatchCreateTableRowsResponse
     BatchCreateTableRowsResponse
     (HashMap Text Text)
     (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateTableRowsResponse' {HashMap Text Text
createdRows :: HashMap Text Text
$sel:createdRows:BatchCreateTableRowsResponse' :: BatchCreateTableRowsResponse -> HashMap Text Text
createdRows} -> HashMap Text Text
createdRows) (\s :: BatchCreateTableRowsResponse
s@BatchCreateTableRowsResponse' {} HashMap Text Text
a -> BatchCreateTableRowsResponse
s {$sel:createdRows:BatchCreateTableRowsResponse' :: HashMap Text Text
createdRows = HashMap Text Text
a} :: BatchCreateTableRowsResponse) ((HashMap Text Text -> f (HashMap Text Text))
 -> BatchCreateTableRowsResponse -> f BatchCreateTableRowsResponse)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> BatchCreateTableRowsResponse
-> f BatchCreateTableRowsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData BatchCreateTableRowsResponse