Search in sources :

Example 1 with BatchUpdateSpreadsheetResponse

use of com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetResponse in project OpenRefine by OpenRefine.

the class SpreadsheetSerializer method sendBatch.

private void sendBatch(List<RowData> rows) {
    List<Request> requests = prepareBatch(rows);
    // FIXME: We have a 10MB cap on the request size, but I'm not sure we've got a good
    // way to quickly tell how big our request is. Just reduce row count for now.
    BatchUpdateSpreadsheetRequest requestBody = new BatchUpdateSpreadsheetRequest();
    requestBody.setIncludeSpreadsheetInResponse(false);
    requestBody.setRequests(requests);
    Sheets.Spreadsheets.BatchUpdate request;
    try {
        logger.debug("spreadsheetId: " + spreadsheetId);
        // logger.debug("requestBody:" + requestBody.toString());
        request = service.spreadsheets().batchUpdate(spreadsheetId, requestBody);
        BatchUpdateSpreadsheetResponse response = request.execute();
        logger.debug("response:" + response.toPrettyString());
    } catch (IOException e) {
        exceptions.add(e);
    } finally {
        requestBody.clear();
        requests.clear();
        rows.clear();
    }
}
Also used : BatchUpdateSpreadsheetRequest(com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest) BatchUpdateSpreadsheetRequest(com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest) Request(com.google.api.services.sheets.v4.model.Request) AppendDimensionRequest(com.google.api.services.sheets.v4.model.AppendDimensionRequest) AppendCellsRequest(com.google.api.services.sheets.v4.model.AppendCellsRequest) IOException(java.io.IOException) BatchUpdateSpreadsheetResponse(com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetResponse)

Aggregations

AppendCellsRequest (com.google.api.services.sheets.v4.model.AppendCellsRequest)1 AppendDimensionRequest (com.google.api.services.sheets.v4.model.AppendDimensionRequest)1 BatchUpdateSpreadsheetRequest (com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest)1 BatchUpdateSpreadsheetResponse (com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetResponse)1 Request (com.google.api.services.sheets.v4.model.Request)1 IOException (java.io.IOException)1