{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 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:/ '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
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
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. 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'
      { $sel:clientRequestToken:BatchCreateTableRows' :: Maybe Text
clientRequestToken =
          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 = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced 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 :: Lens' BatchCreateTableRows (Maybe Text)
batchCreateTableRows_clientRequestToken = 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 :: Lens' BatchCreateTableRows Text
batchCreateTableRows_workbookId = 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 :: Lens' BatchCreateTableRows Text
batchCreateTableRows_tableId = 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 :: Lens' BatchCreateTableRows (NonEmpty CreateRowData)
batchCreateTableRows_rowsToCreate = 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) 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 BatchCreateTableRows where
  type
    AWSResponse BatchCreateTableRows =
      BatchCreateTableRowsResponse
  request :: (Service -> Service)
-> BatchCreateTableRows -> Request BatchCreateTableRows
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 BatchCreateTableRows
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchCreateTableRows)))
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
-> Integer
-> HashMap Text Text
-> BatchCreateTableRowsResponse
BatchCreateTableRowsResponse'
            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 a
Data..:> Key
"workbookCursor")
            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
"createdRows" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable BatchCreateTableRows where
  hashWithSalt :: Int -> BatchCreateTableRows -> Int
hashWithSalt Int
_salt 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
..} =
    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` NonEmpty CreateRowData
rowsToCreate

instance Prelude.NFData BatchCreateTableRows where
  rnf :: BatchCreateTableRows -> ()
rnf 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
..} =
    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 NonEmpty CreateRowData
rowsToCreate

instance Data.ToHeaders BatchCreateTableRows where
  toHeaders :: BatchCreateTableRows -> 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 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
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
"rowsToCreate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty CreateRowData
rowsToCreate)
          ]
      )

instance Data.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
..} =
    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/batchcreate"
      ]

instance Data.ToQuery BatchCreateTableRows where
  toQuery :: BatchCreateTableRows -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
      { $sel:failedBatchItems:BatchCreateTableRowsResponse' :: Maybe [FailedBatchItem]
failedBatchItems =
          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 = 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 :: Lens' BatchCreateTableRowsResponse (Maybe [FailedBatchItem])
batchCreateTableRowsResponse_failedBatchItems = 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) 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.
batchCreateTableRowsResponse_httpStatus :: Lens.Lens' BatchCreateTableRowsResponse Prelude.Int
batchCreateTableRowsResponse_httpStatus :: Lens' BatchCreateTableRowsResponse Int
batchCreateTableRowsResponse_httpStatus = 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 :: Lens' BatchCreateTableRowsResponse Integer
batchCreateTableRowsResponse_workbookCursor = 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 :: Lens' BatchCreateTableRowsResponse (HashMap Text Text)
batchCreateTableRowsResponse_createdRows = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData BatchCreateTableRowsResponse where
  rnf :: BatchCreateTableRowsResponse -> ()
rnf BatchCreateTableRowsResponse' {Int
Integer
Maybe [FailedBatchItem]
HashMap Text Text
createdRows :: HashMap Text Text
workbookCursor :: Integer
httpStatus :: Int
failedBatchItems :: Maybe [FailedBatchItem]
$sel:createdRows:BatchCreateTableRowsResponse' :: BatchCreateTableRowsResponse -> HashMap Text Text
$sel:workbookCursor:BatchCreateTableRowsResponse' :: BatchCreateTableRowsResponse -> Integer
$sel:httpStatus:BatchCreateTableRowsResponse' :: BatchCreateTableRowsResponse -> Int
$sel:failedBatchItems:BatchCreateTableRowsResponse' :: BatchCreateTableRowsResponse -> 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 Integer
workbookCursor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Text
createdRows