-
Notifications
You must be signed in to change notification settings - Fork 877
/
Copy pathservice.rb
778 lines (754 loc) · 51 KB
/
service.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'google/apis/core/base_service'
require 'google/apis/core/json_representation'
require 'google/apis/core/hashable'
require 'google/apis/errors'
module Google
module Apis
module SheetsV4
# Google Sheets API
#
# Reads and writes Google Sheets.
#
# @example
# require 'google/apis/sheets_v4'
#
# Sheets = Google::Apis::SheetsV4 # Alias the module
# service = Sheets::SheetsService.new
#
# @see https://developers.google.com/workspace/sheets/
class SheetsService < Google::Apis::Core::BaseService
DEFAULT_ENDPOINT_TEMPLATE = "https://sheets.$UNIVERSE_DOMAIN$/"
# @return [String]
# API key. Your API key identifies your project and provides you with API access,
# quota, and reports. Required unless you provide an OAuth 2.0 token.
attr_accessor :key
# @return [String]
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
attr_accessor :quota_user
def initialize
super(DEFAULT_ENDPOINT_TEMPLATE, '',
client_name: 'google-apis-sheets_v4',
client_version: Google::Apis::SheetsV4::GEM_VERSION)
@batch_path = 'batch'
end
# Applies one or more updates to the spreadsheet. Each request is validated
# before being applied. If any request is not valid then the entire request will
# fail and nothing will be applied. Some requests have replies to give you some
# information about how they are applied. The replies will mirror the requests.
# For example, if you applied 4 updates and the 3rd one had a reply, then the
# response will have 2 empty replies, the actual reply, and another empty reply,
# in that order. Due to the collaborative nature of spreadsheets, it is not
# guaranteed that the spreadsheet will reflect exactly your changes after this
# completes, however it is guaranteed that the updates in the request will be
# applied together atomically. Your changes may be altered with respect to
# collaborator changes. If there are no collaborators, the spreadsheet should
# reflect your changes.
# @param [String] spreadsheet_id
# The spreadsheet to apply the updates to.
# @param [Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest] batch_update_spreadsheet_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::BatchUpdateSpreadsheetResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::BatchUpdateSpreadsheetResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def batch_update_spreadsheet(spreadsheet_id, batch_update_spreadsheet_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}:batchUpdate', options)
command.request_representation = Google::Apis::SheetsV4::BatchUpdateSpreadsheetRequest::Representation
command.request_object = batch_update_spreadsheet_request_object
command.response_representation = Google::Apis::SheetsV4::BatchUpdateSpreadsheetResponse::Representation
command.response_class = Google::Apis::SheetsV4::BatchUpdateSpreadsheetResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a spreadsheet, returning the newly created spreadsheet.
# @param [Google::Apis::SheetsV4::Spreadsheet] spreadsheet_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::Spreadsheet] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::Spreadsheet]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def create_spreadsheet(spreadsheet_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets', options)
command.request_representation = Google::Apis::SheetsV4::Spreadsheet::Representation
command.request_object = spreadsheet_object
command.response_representation = Google::Apis::SheetsV4::Spreadsheet::Representation
command.response_class = Google::Apis::SheetsV4::Spreadsheet
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns the spreadsheet at the given ID. The caller must specify the
# spreadsheet ID. By default, data within grids is not returned. You can include
# grid data in one of 2 ways: * Specify a [field mask](https://developers.google.
# com/workspace/sheets/api/guides/field-masks) listing your desired fields using
# the `fields` URL parameter in HTTP * Set the includeGridData URL parameter to
# true. If a field mask is set, the `includeGridData` parameter is ignored For
# large spreadsheets, as a best practice, retrieve only the specific spreadsheet
# fields that you want. To retrieve only subsets of spreadsheet data, use the
# ranges URL parameter. Ranges are specified using [A1 notation](https://
# developers.google.com/workspace/sheets/api/guides/concepts#cell). You can
# define a single cell (for example, `A1`) or multiple cells (for example, `A1:
# D5`). You can also get cells from other sheets within the same spreadsheet (
# for example, `Sheet2!A1:C4`) or retrieve multiple ranges at once (for example,
# `?ranges=A1:D5&ranges=Sheet2!A1:C4`). Limiting the range returns only the
# portions of the spreadsheet that intersect the requested ranges.
# @param [String] spreadsheet_id
# The spreadsheet to request.
# @param [Boolean] include_grid_data
# True if grid data should be returned. This parameter is ignored if a field
# mask was set in the request.
# @param [Array<String>, String] ranges
# The ranges to retrieve from the spreadsheet.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::Spreadsheet] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::Spreadsheet]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_spreadsheet(spreadsheet_id, include_grid_data: nil, ranges: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v4/spreadsheets/{spreadsheetId}', options)
command.response_representation = Google::Apis::SheetsV4::Spreadsheet::Representation
command.response_class = Google::Apis::SheetsV4::Spreadsheet
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['includeGridData'] = include_grid_data unless include_grid_data.nil?
command.query['ranges'] = ranges unless ranges.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns the spreadsheet at the given ID. The caller must specify the
# spreadsheet ID. This method differs from GetSpreadsheet in that it allows
# selecting which subsets of spreadsheet data to return by specifying a
# dataFilters parameter. Multiple DataFilters can be specified. Specifying one
# or more data filters returns the portions of the spreadsheet that intersect
# ranges matched by any of the filters. By default, data within grids is not
# returned. You can include grid data one of 2 ways: * Specify a [field mask](
# https://developers.google.com/workspace/sheets/api/guides/field-masks) listing
# your desired fields using the `fields` URL parameter in HTTP * Set the
# includeGridData parameter to true. If a field mask is set, the `
# includeGridData` parameter is ignored For large spreadsheets, as a best
# practice, retrieve only the specific spreadsheet fields that you want.
# @param [String] spreadsheet_id
# The spreadsheet to request.
# @param [Google::Apis::SheetsV4::GetSpreadsheetByDataFilterRequest] get_spreadsheet_by_data_filter_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::Spreadsheet] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::Spreadsheet]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_spreadsheet_by_data_filter(spreadsheet_id, get_spreadsheet_by_data_filter_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}:getByDataFilter', options)
command.request_representation = Google::Apis::SheetsV4::GetSpreadsheetByDataFilterRequest::Representation
command.request_object = get_spreadsheet_by_data_filter_request_object
command.response_representation = Google::Apis::SheetsV4::Spreadsheet::Representation
command.response_class = Google::Apis::SheetsV4::Spreadsheet
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns the developer metadata with the specified ID. The caller must specify
# the spreadsheet ID and the developer metadata's unique metadataId.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to retrieve metadata from.
# @param [Fixnum] metadata_id
# The ID of the developer metadata to retrieve.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::DeveloperMetadata] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::DeveloperMetadata]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_spreadsheet_developer_metadatum(spreadsheet_id, metadata_id, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v4/spreadsheets/{spreadsheetId}/developerMetadata/{metadataId}', options)
command.response_representation = Google::Apis::SheetsV4::DeveloperMetadata::Representation
command.response_class = Google::Apis::SheetsV4::DeveloperMetadata
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.params['metadataId'] = metadata_id unless metadata_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns all developer metadata matching the specified DataFilter. If the
# provided DataFilter represents a DeveloperMetadataLookup object, this will
# return all DeveloperMetadata entries selected by it. If the DataFilter
# represents a location in a spreadsheet, this will return all developer
# metadata associated with locations intersecting that region.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to retrieve metadata from.
# @param [Google::Apis::SheetsV4::SearchDeveloperMetadataRequest] search_developer_metadata_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::SearchDeveloperMetadataResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::SearchDeveloperMetadataResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def search_developer_metadatum_developer_metadata(spreadsheet_id, search_developer_metadata_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}/developerMetadata:search', options)
command.request_representation = Google::Apis::SheetsV4::SearchDeveloperMetadataRequest::Representation
command.request_object = search_developer_metadata_request_object
command.response_representation = Google::Apis::SheetsV4::SearchDeveloperMetadataResponse::Representation
command.response_class = Google::Apis::SheetsV4::SearchDeveloperMetadataResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Copies a single sheet from a spreadsheet to another spreadsheet. Returns the
# properties of the newly created sheet.
# @param [String] spreadsheet_id
# The ID of the spreadsheet containing the sheet to copy.
# @param [Fixnum] sheet_id
# The ID of the sheet to copy.
# @param [Google::Apis::SheetsV4::CopySheetToAnotherSpreadsheetRequest] copy_sheet_to_another_spreadsheet_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::SheetProperties] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::SheetProperties]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def copy_spreadsheet(spreadsheet_id, sheet_id, copy_sheet_to_another_spreadsheet_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}/sheets/{sheetId}:copyTo', options)
command.request_representation = Google::Apis::SheetsV4::CopySheetToAnotherSpreadsheetRequest::Representation
command.request_object = copy_sheet_to_another_spreadsheet_request_object
command.response_representation = Google::Apis::SheetsV4::SheetProperties::Representation
command.response_class = Google::Apis::SheetsV4::SheetProperties
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.params['sheetId'] = sheet_id unless sheet_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Appends values to a spreadsheet. The input range is used to search for
# existing data and find a "table" within that range. Values will be appended to
# the next row of the table, starting with the first column of the table. See
# the [guide](https://developers.google.com/workspace/sheets/api/guides/values#
# appending_values) and [sample code](https://developers.google.com/workspace/
# sheets/api/samples/writing#append_values) for specific details of how tables
# are detected and data is appended. The caller must specify the spreadsheet ID,
# range, and a valueInputOption. The `valueInputOption` only controls how the
# input data will be added to the sheet (column-wise or row-wise), it does not
# influence what cell the data starts being written to.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to update.
# @param [String] range
# The [A1 notation](https://developers.google.com/workspace/sheets/api/guides/
# concepts#cell) of a range to search for a logical table of data. Values are
# appended after the last row of the table.
# @param [Google::Apis::SheetsV4::ValueRange] value_range_object
# @param [Boolean] include_values_in_response
# Determines if the update response should include the values of the cells that
# were appended. By default, responses do not include the updated values.
# @param [String] insert_data_option
# How the input data should be inserted.
# @param [String] response_date_time_render_option
# Determines how dates, times, and durations in the response should be rendered.
# This is ignored if response_value_render_option is FORMATTED_VALUE. The
# default dateTime render option is SERIAL_NUMBER.
# @param [String] response_value_render_option
# Determines how values in the response should be rendered. The default render
# option is FORMATTED_VALUE.
# @param [String] value_input_option
# How the input data should be interpreted.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::AppendValuesResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::AppendValuesResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def append_spreadsheet_value(spreadsheet_id, range, value_range_object = nil, include_values_in_response: nil, insert_data_option: nil, response_date_time_render_option: nil, response_value_render_option: nil, value_input_option: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}/values/{range}:append', options)
command.request_representation = Google::Apis::SheetsV4::ValueRange::Representation
command.request_object = value_range_object
command.response_representation = Google::Apis::SheetsV4::AppendValuesResponse::Representation
command.response_class = Google::Apis::SheetsV4::AppendValuesResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.params['range'] = range unless range.nil?
command.query['includeValuesInResponse'] = include_values_in_response unless include_values_in_response.nil?
command.query['insertDataOption'] = insert_data_option unless insert_data_option.nil?
command.query['responseDateTimeRenderOption'] = response_date_time_render_option unless response_date_time_render_option.nil?
command.query['responseValueRenderOption'] = response_value_render_option unless response_value_render_option.nil?
command.query['valueInputOption'] = value_input_option unless value_input_option.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Clears one or more ranges of values from a spreadsheet. The caller must
# specify the spreadsheet ID and one or more ranges. Only values are cleared --
# all other properties of the cell (such as formatting and data validation) are
# kept.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to update.
# @param [Google::Apis::SheetsV4::BatchClearValuesRequest] batch_clear_values_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::BatchClearValuesResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::BatchClearValuesResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def batch_clear_values(spreadsheet_id, batch_clear_values_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}/values:batchClear', options)
command.request_representation = Google::Apis::SheetsV4::BatchClearValuesRequest::Representation
command.request_object = batch_clear_values_request_object
command.response_representation = Google::Apis::SheetsV4::BatchClearValuesResponse::Representation
command.response_class = Google::Apis::SheetsV4::BatchClearValuesResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Clears one or more ranges of values from a spreadsheet. The caller must
# specify the spreadsheet ID and one or more DataFilters. Ranges matching any of
# the specified data filters will be cleared. Only values are cleared -- all
# other properties of the cell (such as formatting, data validation, etc..) are
# kept.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to update.
# @param [Google::Apis::SheetsV4::BatchClearValuesByDataFilterRequest] batch_clear_values_by_data_filter_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::BatchClearValuesByDataFilterResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::BatchClearValuesByDataFilterResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def batch_spreadsheet_value_clear_by_data_filter(spreadsheet_id, batch_clear_values_by_data_filter_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}/values:batchClearByDataFilter', options)
command.request_representation = Google::Apis::SheetsV4::BatchClearValuesByDataFilterRequest::Representation
command.request_object = batch_clear_values_by_data_filter_request_object
command.response_representation = Google::Apis::SheetsV4::BatchClearValuesByDataFilterResponse::Representation
command.response_class = Google::Apis::SheetsV4::BatchClearValuesByDataFilterResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns one or more ranges of values from a spreadsheet. The caller must
# specify the spreadsheet ID and one or more ranges.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to retrieve data from.
# @param [String] date_time_render_option
# How dates, times, and durations should be represented in the output. This is
# ignored if value_render_option is FORMATTED_VALUE. The default dateTime render
# option is SERIAL_NUMBER.
# @param [String] major_dimension
# The major dimension that results should use. For example, if the spreadsheet
# data is: `A1=1,B1=2,A2=3,B2=4`, then requesting `ranges=["A1:B2"],
# majorDimension=ROWS` returns `[[1,2],[3,4]]`, whereas requesting `ranges=["A1:
# B2"],majorDimension=COLUMNS` returns `[[1,3],[2,4]]`.
# @param [Array<String>, String] ranges
# The [A1 notation or R1C1 notation](https://developers.google.com/workspace/
# sheets/api/guides/concepts#cell) of the range to retrieve values from.
# @param [String] value_render_option
# How values should be represented in the output. The default render option is
# ValueRenderOption.FORMATTED_VALUE.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::BatchGetValuesResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::BatchGetValuesResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def batch_get_spreadsheet_values(spreadsheet_id, date_time_render_option: nil, major_dimension: nil, ranges: nil, value_render_option: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v4/spreadsheets/{spreadsheetId}/values:batchGet', options)
command.response_representation = Google::Apis::SheetsV4::BatchGetValuesResponse::Representation
command.response_class = Google::Apis::SheetsV4::BatchGetValuesResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['dateTimeRenderOption'] = date_time_render_option unless date_time_render_option.nil?
command.query['majorDimension'] = major_dimension unless major_dimension.nil?
command.query['ranges'] = ranges unless ranges.nil?
command.query['valueRenderOption'] = value_render_option unless value_render_option.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns one or more ranges of values that match the specified data filters.
# The caller must specify the spreadsheet ID and one or more DataFilters. Ranges
# that match any of the data filters in the request will be returned.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to retrieve data from.
# @param [Google::Apis::SheetsV4::BatchGetValuesByDataFilterRequest] batch_get_values_by_data_filter_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::BatchGetValuesByDataFilterResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::BatchGetValuesByDataFilterResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def batch_spreadsheet_value_get_by_data_filter(spreadsheet_id, batch_get_values_by_data_filter_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}/values:batchGetByDataFilter', options)
command.request_representation = Google::Apis::SheetsV4::BatchGetValuesByDataFilterRequest::Representation
command.request_object = batch_get_values_by_data_filter_request_object
command.response_representation = Google::Apis::SheetsV4::BatchGetValuesByDataFilterResponse::Representation
command.response_class = Google::Apis::SheetsV4::BatchGetValuesByDataFilterResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Sets values in one or more ranges of a spreadsheet. The caller must specify
# the spreadsheet ID, a valueInputOption, and one or more ValueRanges.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to update.
# @param [Google::Apis::SheetsV4::BatchUpdateValuesRequest] batch_update_values_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::BatchUpdateValuesResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::BatchUpdateValuesResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def batch_update_values(spreadsheet_id, batch_update_values_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}/values:batchUpdate', options)
command.request_representation = Google::Apis::SheetsV4::BatchUpdateValuesRequest::Representation
command.request_object = batch_update_values_request_object
command.response_representation = Google::Apis::SheetsV4::BatchUpdateValuesResponse::Representation
command.response_class = Google::Apis::SheetsV4::BatchUpdateValuesResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Sets values in one or more ranges of a spreadsheet. The caller must specify
# the spreadsheet ID, a valueInputOption, and one or more DataFilterValueRanges.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to update.
# @param [Google::Apis::SheetsV4::BatchUpdateValuesByDataFilterRequest] batch_update_values_by_data_filter_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::BatchUpdateValuesByDataFilterResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::BatchUpdateValuesByDataFilterResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def batch_spreadsheet_value_update_by_data_filter(spreadsheet_id, batch_update_values_by_data_filter_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}/values:batchUpdateByDataFilter', options)
command.request_representation = Google::Apis::SheetsV4::BatchUpdateValuesByDataFilterRequest::Representation
command.request_object = batch_update_values_by_data_filter_request_object
command.response_representation = Google::Apis::SheetsV4::BatchUpdateValuesByDataFilterResponse::Representation
command.response_class = Google::Apis::SheetsV4::BatchUpdateValuesByDataFilterResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Clears values from a spreadsheet. The caller must specify the spreadsheet ID
# and range. Only values are cleared -- all other properties of the cell (such
# as formatting, data validation, etc..) are kept.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to update.
# @param [String] range
# The [A1 notation or R1C1 notation](https://developers.google.com/workspace/
# sheets/api/guides/concepts#cell) of the values to clear.
# @param [Google::Apis::SheetsV4::ClearValuesRequest] clear_values_request_object
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::ClearValuesResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::ClearValuesResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def clear_values(spreadsheet_id, range, clear_values_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v4/spreadsheets/{spreadsheetId}/values/{range}:clear', options)
command.request_representation = Google::Apis::SheetsV4::ClearValuesRequest::Representation
command.request_object = clear_values_request_object
command.response_representation = Google::Apis::SheetsV4::ClearValuesResponse::Representation
command.response_class = Google::Apis::SheetsV4::ClearValuesResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.params['range'] = range unless range.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns a range of values from a spreadsheet. The caller must specify the
# spreadsheet ID and a range.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to retrieve data from.
# @param [String] range
# The [A1 notation or R1C1 notation](https://developers.google.com/workspace/
# sheets/api/guides/concepts#cell) of the range to retrieve values from.
# @param [String] date_time_render_option
# How dates, times, and durations should be represented in the output. This is
# ignored if value_render_option is FORMATTED_VALUE. The default dateTime render
# option is SERIAL_NUMBER.
# @param [String] major_dimension
# The major dimension that results should use. For example, if the spreadsheet
# data in Sheet1 is: `A1=1,B1=2,A2=3,B2=4`, then requesting `range=Sheet1!A1:B2?
# majorDimension=ROWS` returns `[[1,2],[3,4]]`, whereas requesting `range=Sheet1!
# A1:B2?majorDimension=COLUMNS` returns `[[1,3],[2,4]]`.
# @param [String] value_render_option
# How values should be represented in the output. The default render option is
# FORMATTED_VALUE.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::ValueRange] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::ValueRange]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_spreadsheet_values(spreadsheet_id, range, date_time_render_option: nil, major_dimension: nil, value_render_option: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v4/spreadsheets/{spreadsheetId}/values/{range}', options)
command.response_representation = Google::Apis::SheetsV4::ValueRange::Representation
command.response_class = Google::Apis::SheetsV4::ValueRange
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.params['range'] = range unless range.nil?
command.query['dateTimeRenderOption'] = date_time_render_option unless date_time_render_option.nil?
command.query['majorDimension'] = major_dimension unless major_dimension.nil?
command.query['valueRenderOption'] = value_render_option unless value_render_option.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Sets values in a range of a spreadsheet. The caller must specify the
# spreadsheet ID, range, and a valueInputOption.
# @param [String] spreadsheet_id
# The ID of the spreadsheet to update.
# @param [String] range
# The [A1 notation](https://developers.google.com/workspace/sheets/api/guides/
# concepts#cell) of the values to update.
# @param [Google::Apis::SheetsV4::ValueRange] value_range_object
# @param [Boolean] include_values_in_response
# Determines if the update response should include the values of the cells that
# were updated. By default, responses do not include the updated values. If the
# range to write was larger than the range actually written, the response
# includes all values in the requested range (excluding trailing empty rows and
# columns).
# @param [String] response_date_time_render_option
# Determines how dates, times, and durations in the response should be rendered.
# This is ignored if response_value_render_option is FORMATTED_VALUE. The
# default dateTime render option is SERIAL_NUMBER.
# @param [String] response_value_render_option
# Determines how values in the response should be rendered. The default render
# option is FORMATTED_VALUE.
# @param [String] value_input_option
# How the input data should be interpreted.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::SheetsV4::UpdateValuesResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::SheetsV4::UpdateValuesResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def update_spreadsheet_value(spreadsheet_id, range, value_range_object = nil, include_values_in_response: nil, response_date_time_render_option: nil, response_value_render_option: nil, value_input_option: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:put, 'v4/spreadsheets/{spreadsheetId}/values/{range}', options)
command.request_representation = Google::Apis::SheetsV4::ValueRange::Representation
command.request_object = value_range_object
command.response_representation = Google::Apis::SheetsV4::UpdateValuesResponse::Representation
command.response_class = Google::Apis::SheetsV4::UpdateValuesResponse
command.params['spreadsheetId'] = spreadsheet_id unless spreadsheet_id.nil?
command.params['range'] = range unless range.nil?
command.query['includeValuesInResponse'] = include_values_in_response unless include_values_in_response.nil?
command.query['responseDateTimeRenderOption'] = response_date_time_render_option unless response_date_time_render_option.nil?
command.query['responseValueRenderOption'] = response_value_render_option unless response_value_render_option.nil?
command.query['valueInputOption'] = value_input_option unless value_input_option.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
protected
def apply_command_defaults(command)
command.query['key'] = key unless key.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
end
end
end
end
end