1// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.area120.tables.v1alpha1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/protobuf/empty.proto";
24import "google/protobuf/field_mask.proto";
25import "google/protobuf/struct.proto";
26
27option go_package = "cloud.google.com/go/area120/tables/apiv1alpha1/tablespb;tablespb";
28option java_multiple_files = true;
29option java_outer_classname = "TablesProto";
30option java_package = "com.google.area120.tables.v1alpha1";
31
32// The Tables Service provides an API for reading and updating tables.
33// It defines the following resource model:
34//
35// - The API has a collection of [Table][google.area120.tables.v1alpha1.Table]
36//   resources, named `tables/*`
37//
38// - Each Table has a collection of [Row][google.area120.tables.v1alpha1.Row]
39//   resources, named `tables/*/rows/*`
40//
41// - The API has a collection of
42//   [Workspace][google.area120.tables.v1alpha1.Workspace]
43//   resources, named `workspaces/*`.
44service TablesService {
45  option (google.api.default_host) = "area120tables.googleapis.com";
46  option (google.api.oauth_scopes) =
47      "https://www.googleapis.com/auth/drive,"
48      "https://www.googleapis.com/auth/drive.file,"
49      "https://www.googleapis.com/auth/drive.readonly,"
50      "https://www.googleapis.com/auth/spreadsheets,"
51      "https://www.googleapis.com/auth/spreadsheets.readonly,"
52      "https://www.googleapis.com/auth/tables";
53
54  // Gets a table. Returns NOT_FOUND if the table does not exist.
55  rpc GetTable(GetTableRequest) returns (Table) {
56    option (google.api.http) = {
57      get: "/v1alpha1/{name=tables/*}"
58    };
59    option (google.api.method_signature) = "name";
60  }
61
62  // Lists tables for the user.
63  rpc ListTables(ListTablesRequest) returns (ListTablesResponse) {
64    option (google.api.http) = {
65      get: "/v1alpha1/tables"
66    };
67  }
68
69  // Gets a workspace. Returns NOT_FOUND if the workspace does not exist.
70  rpc GetWorkspace(GetWorkspaceRequest) returns (Workspace) {
71    option (google.api.http) = {
72      get: "/v1alpha1/{name=workspaces/*}"
73    };
74    option (google.api.method_signature) = "name";
75  }
76
77  // Lists workspaces for the user.
78  rpc ListWorkspaces(ListWorkspacesRequest) returns (ListWorkspacesResponse) {
79    option (google.api.http) = {
80      get: "/v1alpha1/workspaces"
81    };
82  }
83
84  // Gets a row. Returns NOT_FOUND if the row does not exist in the table.
85  rpc GetRow(GetRowRequest) returns (Row) {
86    option (google.api.http) = {
87      get: "/v1alpha1/{name=tables/*/rows/*}"
88    };
89    option (google.api.method_signature) = "name";
90  }
91
92  // Lists rows in a table. Returns NOT_FOUND if the table does not exist.
93  rpc ListRows(ListRowsRequest) returns (ListRowsResponse) {
94    option (google.api.http) = {
95      get: "/v1alpha1/{parent=tables/*}/rows"
96    };
97    option (google.api.method_signature) = "parent";
98  }
99
100  // Creates a row.
101  rpc CreateRow(CreateRowRequest) returns (Row) {
102    option (google.api.http) = {
103      post: "/v1alpha1/{parent=tables/*}/rows"
104      body: "row"
105    };
106    option (google.api.method_signature) = "parent,row";
107  }
108
109  // Creates multiple rows.
110  rpc BatchCreateRows(BatchCreateRowsRequest) returns (BatchCreateRowsResponse) {
111    option (google.api.http) = {
112      post: "/v1alpha1/{parent=tables/*}/rows:batchCreate"
113      body: "*"
114    };
115  }
116
117  // Updates a row.
118  rpc UpdateRow(UpdateRowRequest) returns (Row) {
119    option (google.api.http) = {
120      patch: "/v1alpha1/{row.name=tables/*/rows/*}"
121      body: "row"
122    };
123    option (google.api.method_signature) = "row,update_mask";
124  }
125
126  // Updates multiple rows.
127  rpc BatchUpdateRows(BatchUpdateRowsRequest) returns (BatchUpdateRowsResponse) {
128    option (google.api.http) = {
129      post: "/v1alpha1/{parent=tables/*}/rows:batchUpdate"
130      body: "*"
131    };
132  }
133
134  // Deletes a row.
135  rpc DeleteRow(DeleteRowRequest) returns (google.protobuf.Empty) {
136    option (google.api.http) = {
137      delete: "/v1alpha1/{name=tables/*/rows/*}"
138    };
139    option (google.api.method_signature) = "name";
140  }
141
142  // Deletes multiple rows.
143  rpc BatchDeleteRows(BatchDeleteRowsRequest) returns (google.protobuf.Empty) {
144    option (google.api.http) = {
145      post: "/v1alpha1/{parent=tables/*}/rows:batchDelete"
146      body: "*"
147    };
148  }
149}
150
151// Request message for TablesService.GetTable.
152message GetTableRequest {
153  // Required. The name of the table to retrieve.
154  // Format: tables/{table}
155  string name = 1 [
156    (google.api.field_behavior) = REQUIRED,
157    (google.api.resource_reference) = {
158      type: "area120tables.googleapis.com/Table"
159    }
160  ];
161}
162
163// Request message for TablesService.ListTables.
164message ListTablesRequest {
165  // The maximum number of tables to return. The service may return fewer than
166  // this value.
167  //
168  // If unspecified, at most 20 tables are returned. The maximum value is 100;
169  // values above 100 are coerced to 100.
170  int32 page_size = 1;
171
172  // A page token, received from a previous `ListTables` call.
173  // Provide this to retrieve the subsequent page.
174  //
175  // When paginating, all other parameters provided to `ListTables` must match
176  // the call that provided the page token.
177  string page_token = 2;
178}
179
180// Response message for TablesService.ListTables.
181message ListTablesResponse {
182  // The list of tables.
183  repeated Table tables = 1;
184
185  // A token, which can be sent as `page_token` to retrieve the next page.
186  // If this field is empty, there are no subsequent pages.
187  string next_page_token = 2;
188}
189
190// Request message for TablesService.GetWorkspace.
191message GetWorkspaceRequest {
192  // Required. The name of the workspace to retrieve.
193  // Format: workspaces/{workspace}
194  string name = 1 [
195    (google.api.field_behavior) = REQUIRED,
196    (google.api.resource_reference) = {
197      type: "area120tables.googleapis.com/Workspace"
198    }
199  ];
200}
201
202// Request message for TablesService.ListWorkspaces.
203message ListWorkspacesRequest {
204  // The maximum number of workspaces to return. The service may return fewer
205  // than this value.
206  //
207  // If unspecified, at most 10 workspaces are returned. The maximum value is
208  // 25; values above 25 are coerced to 25.
209  int32 page_size = 1;
210
211  // A page token, received from a previous `ListWorkspaces` call.
212  // Provide this to retrieve the subsequent page.
213  //
214  // When paginating, all other parameters provided to `ListWorkspaces` must
215  // match the call that provided the page token.
216  string page_token = 2;
217}
218
219// Response message for TablesService.ListWorkspaces.
220message ListWorkspacesResponse {
221  // The list of workspaces.
222  repeated Workspace workspaces = 1;
223
224  // A token, which can be sent as `page_token` to retrieve the next page.
225  // If this field is empty, there are no subsequent pages.
226  string next_page_token = 2;
227}
228
229// Request message for TablesService.GetRow.
230message GetRowRequest {
231  // Required. The name of the row to retrieve.
232  // Format: tables/{table}/rows/{row}
233  string name = 1 [
234    (google.api.field_behavior) = REQUIRED,
235    (google.api.resource_reference) = {
236      type: "area120tables.googleapis.com/Row"
237    }
238  ];
239
240  // Optional. Column key to use for values in the row.
241  // Defaults to user entered name.
242  View view = 2 [(google.api.field_behavior) = OPTIONAL];
243}
244
245// Request message for TablesService.ListRows.
246message ListRowsRequest {
247  // Required. The parent table.
248  // Format: tables/{table}
249  string parent = 1 [(google.api.field_behavior) = REQUIRED];
250
251  // The maximum number of rows to return. The service may return fewer than
252  // this value.
253  //
254  // If unspecified, at most 50 rows are returned. The maximum value is 1,000;
255  // values above 1,000 are coerced to 1,000.
256  int32 page_size = 2;
257
258  // A page token, received from a previous `ListRows` call.
259  // Provide this to retrieve the subsequent page.
260  //
261  // When paginating, all other parameters provided to `ListRows` must match
262  // the call that provided the page token.
263  string page_token = 3;
264
265  // Optional. Column key to use for values in the row.
266  // Defaults to user entered name.
267  View view = 4 [(google.api.field_behavior) = OPTIONAL];
268
269  // Optional. Raw text query to search for in rows of the table.
270  // Special characters must be escaped. Logical operators and field specific
271  // filtering not supported.
272  string filter = 5 [(google.api.field_behavior) = OPTIONAL];
273}
274
275// Response message for TablesService.ListRows.
276message ListRowsResponse {
277  // The rows from the specified table.
278  repeated Row rows = 1;
279
280  // A token, which can be sent as `page_token` to retrieve the next page.
281  // If this field is empty, there are no subsequent pages.
282  string next_page_token = 2;
283}
284
285// Request message for TablesService.CreateRow.
286message CreateRowRequest {
287  // Required. The parent table where this row will be created.
288  // Format: tables/{table}
289  string parent = 1 [(google.api.field_behavior) = REQUIRED];
290
291  // Required. The row to create.
292  Row row = 2 [(google.api.field_behavior) = REQUIRED];
293
294  // Optional. Column key to use for values in the row.
295  // Defaults to user entered name.
296  View view = 3 [(google.api.field_behavior) = OPTIONAL];
297}
298
299// Request message for TablesService.BatchCreateRows.
300message BatchCreateRowsRequest {
301  // Required. The parent table where the rows will be created.
302  // Format: tables/{table}
303  string parent = 1 [(google.api.field_behavior) = REQUIRED];
304
305  // Required. The request message specifying the rows to create.
306  //
307  // A maximum of 500 rows can be created in a single batch.
308  repeated CreateRowRequest requests = 2 [(google.api.field_behavior) = REQUIRED];
309}
310
311// Response message for TablesService.BatchCreateRows.
312message BatchCreateRowsResponse {
313  // The created rows.
314  repeated Row rows = 1;
315}
316
317// Request message for TablesService.UpdateRow.
318message UpdateRowRequest {
319  // Required. The row to update.
320  Row row = 1 [(google.api.field_behavior) = REQUIRED];
321
322  // The list of fields to update.
323  google.protobuf.FieldMask update_mask = 2;
324
325  // Optional. Column key to use for values in the row.
326  // Defaults to user entered name.
327  View view = 3 [(google.api.field_behavior) = OPTIONAL];
328}
329
330// Request message for TablesService.BatchUpdateRows.
331message BatchUpdateRowsRequest {
332  // Required. The parent table shared by all rows being updated.
333  // Format: tables/{table}
334  string parent = 1 [(google.api.field_behavior) = REQUIRED];
335
336  // Required. The request messages specifying the rows to update.
337  //
338  // A maximum of 500 rows can be modified in a single batch.
339  repeated UpdateRowRequest requests = 2 [(google.api.field_behavior) = REQUIRED];
340}
341
342// Response message for TablesService.BatchUpdateRows.
343message BatchUpdateRowsResponse {
344  // The updated rows.
345  repeated Row rows = 1;
346}
347
348// Request message for TablesService.DeleteRow
349message DeleteRowRequest {
350  // Required. The name of the row to delete.
351  // Format: tables/{table}/rows/{row}
352  string name = 1 [
353    (google.api.field_behavior) = REQUIRED,
354    (google.api.resource_reference) = {
355      type: "area120tables.googleapis.com/Row"
356    }
357  ];
358}
359
360// Request message for TablesService.BatchDeleteRows
361message BatchDeleteRowsRequest {
362  // Required. The parent table shared by all rows being deleted.
363  // Format: tables/{table}
364  string parent = 1 [
365    (google.api.field_behavior) = REQUIRED,
366    (google.api.resource_reference) = {
367      type: "area120tables.googleapis.com/Table"
368    }
369  ];
370
371  // Required. The names of the rows to delete. All rows must belong to the parent table
372  // or else the entire batch will fail. A maximum of 500 rows can be deleted
373  // in a batch.
374  // Format: tables/{table}/rows/{row}
375  repeated string names = 2 [
376    (google.api.field_behavior) = REQUIRED,
377    (google.api.resource_reference) = {
378      type: "area120tables.googleapis.com/Row"
379    }
380  ];
381}
382
383// A single table.
384message Table {
385  option (google.api.resource) = {
386    type: "area120tables.googleapis.com/Table"
387    pattern: "tables/{table}"
388  };
389
390  // The resource name of the table.
391  // Table names have the form `tables/{table}`.
392  string name = 1;
393
394  // The human readable title of the table.
395  string display_name = 2;
396
397  // List of columns in this table.
398  // Order of columns matches the display order.
399  repeated ColumnDescription columns = 3;
400}
401
402// Details on a column in the table.
403message ColumnDescription {
404  // column name
405  string name = 1;
406
407  // Data type of the column
408  // Supported types are auto_id, boolean, boolean_list, creator,
409  // create_timestamp, date, dropdown, location, integer,
410  // integer_list, number, number_list, person, person_list, tags, check_list,
411  // text, text_list, update_timestamp, updater, relationship,
412  // file_attachment_list.
413  // These types directly map to the column types supported on Tables website.
414  string data_type = 2;
415
416  // Internal id for a column.
417  string id = 3;
418
419  // Optional. Range of labeled values for the column.
420  // Some columns like tags and drop-downs limit the values to a set of
421  // possible values. We return the range of values in such cases to help
422  // clients implement better user data validation.
423  repeated LabeledItem labels = 4 [(google.api.field_behavior) = OPTIONAL];
424
425  // Optional. Additional details about a relationship column. Specified when data_type
426  // is relationship.
427  RelationshipDetails relationship_details = 5 [(google.api.field_behavior) = OPTIONAL];
428
429  // Optional. Indicates that this is a lookup column whose value is derived from the
430  // relationship column specified in the details. Lookup columns can not be
431  // updated directly. To change the value you must update the associated
432  // relationship column.
433  LookupDetails lookup_details = 6 [(google.api.field_behavior) = OPTIONAL];
434}
435
436// A single item in a labeled column.
437message LabeledItem {
438  // Display string as entered by user.
439  string name = 1;
440
441  // Internal id associated with the item.
442  string id = 2;
443}
444
445// Details about a relationship column.
446message RelationshipDetails {
447  // The name of the table this relationship is linked to.
448  string linked_table = 1;
449}
450
451// Details about a lookup column whose value comes from the associated
452// relationship.
453message LookupDetails {
454  // The name of the relationship column associated with the lookup.
455  string relationship_column = 1;
456
457  // The id of the relationship column.
458  string relationship_column_id = 2;
459}
460
461// A single row in a table.
462message Row {
463  option (google.api.resource) = {
464    type: "area120tables.googleapis.com/Row"
465    pattern: "tables/{table}/rows/{row}"
466  };
467
468  // The resource name of the row.
469  // Row names have the form `tables/{table}/rows/{row}`.
470  // The name is ignored when creating a row.
471  string name = 1;
472
473  // The values of the row. This is a map of column key to value.
474  // Key is user entered name(default) or the internal column id based on
475  // the view in the request.
476  map<string, google.protobuf.Value> values = 2;
477}
478
479// A single workspace.
480message Workspace {
481  option (google.api.resource) = {
482    type: "area120tables.googleapis.com/Workspace"
483    pattern: "workspaces/{workspace}"
484  };
485
486  // The resource name of the workspace.
487  // Workspace names have the form `workspaces/{workspace}`.
488  string name = 1;
489
490  // The human readable title of the workspace.
491  string display_name = 2;
492
493  // The list of tables in the workspace.
494  repeated Table tables = 3;
495}
496
497// Column identifier used for the values in the row.
498enum View {
499  // Defaults to user entered text.
500  VIEW_UNSPECIFIED = 0;
501
502  // Uses internally generated column id to identify values.
503  COLUMN_ID_VIEW = 1;
504}
505