Skip to content

Commit c4ebfff

Browse files
Google APIscopybara-github
authored andcommitted
feat: add dynamic routing header annotation to DatastoreV1
PiperOrigin-RevId: 501591105
1 parent cc58aa3 commit c4ebfff

2 files changed

Lines changed: 71 additions & 26 deletions

File tree

google/datastore/v1/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ proto_library(
3030
"//google/api:annotations_proto",
3131
"//google/api:client_proto",
3232
"//google/api:field_behavior_proto",
33+
"//google/api:routing_proto",
3334
"//google/type:latlng_proto",
3435
"@com_google_protobuf//:struct_proto",
3536
"@com_google_protobuf//:timestamp_proto",

google/datastore/v1/datastore.proto

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package google.datastore.v1;
1919
import "google/api/annotations.proto";
2020
import "google/api/client.proto";
2121
import "google/api/field_behavior.proto";
22+
import "google/api/routing.proto";
2223
import "google/datastore/v1/aggregation_result.proto";
2324
import "google/datastore/v1/entity.proto";
2425
import "google/datastore/v1/query.proto";
@@ -51,6 +52,10 @@ service Datastore {
5152
post: "/v1/projects/{project_id}:lookup"
5253
body: "*"
5354
};
55+
option (google.api.routing) = {
56+
routing_parameters { field: "project_id" }
57+
routing_parameters { field: "database_id" }
58+
};
5459
option (google.api.method_signature) = "project_id,read_options,keys";
5560
}
5661

@@ -60,22 +65,36 @@ service Datastore {
6065
post: "/v1/projects/{project_id}:runQuery"
6166
body: "*"
6267
};
68+
option (google.api.routing) = {
69+
routing_parameters { field: "project_id" }
70+
routing_parameters { field: "database_id" }
71+
};
6372
}
6473

6574
// Runs an aggregation query.
66-
rpc RunAggregationQuery(RunAggregationQueryRequest) returns (RunAggregationQueryResponse) {
75+
rpc RunAggregationQuery(RunAggregationQueryRequest)
76+
returns (RunAggregationQueryResponse) {
6777
option (google.api.http) = {
6878
post: "/v1/projects/{project_id}:runAggregationQuery"
6979
body: "*"
7080
};
81+
option (google.api.routing) = {
82+
routing_parameters { field: "project_id" }
83+
routing_parameters { field: "database_id" }
84+
};
7185
}
7286

7387
// Begins a new transaction.
74-
rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) {
88+
rpc BeginTransaction(BeginTransactionRequest)
89+
returns (BeginTransactionResponse) {
7590
option (google.api.http) = {
7691
post: "/v1/projects/{project_id}:beginTransaction"
7792
body: "*"
7893
};
94+
option (google.api.routing) = {
95+
routing_parameters { field: "project_id" }
96+
routing_parameters { field: "database_id" }
97+
};
7998
option (google.api.method_signature) = "project_id";
8099
}
81100

@@ -86,7 +105,12 @@ service Datastore {
86105
post: "/v1/projects/{project_id}:commit"
87106
body: "*"
88107
};
89-
option (google.api.method_signature) = "project_id,mode,transaction,mutations";
108+
option (google.api.routing) = {
109+
routing_parameters { field: "project_id" }
110+
routing_parameters { field: "database_id" }
111+
};
112+
option (google.api.method_signature) =
113+
"project_id,mode,transaction,mutations";
90114
option (google.api.method_signature) = "project_id,mode,mutations";
91115
}
92116

@@ -96,6 +120,10 @@ service Datastore {
96120
post: "/v1/projects/{project_id}:rollback"
97121
body: "*"
98122
};
123+
option (google.api.routing) = {
124+
routing_parameters { field: "project_id" }
125+
routing_parameters { field: "database_id" }
126+
};
99127
option (google.api.method_signature) = "project_id,transaction";
100128
}
101129

@@ -106,6 +134,10 @@ service Datastore {
106134
post: "/v1/projects/{project_id}:allocateIds"
107135
body: "*"
108136
};
137+
option (google.api.routing) = {
138+
routing_parameters { field: "project_id" }
139+
routing_parameters { field: "database_id" }
140+
};
109141
option (google.api.method_signature) = "project_id,keys";
110142
}
111143

@@ -116,6 +148,10 @@ service Datastore {
116148
post: "/v1/projects/{project_id}:reserveIds"
117149
body: "*"
118150
};
151+
option (google.api.routing) = {
152+
routing_parameters { field: "project_id" }
153+
routing_parameters { field: "database_id" }
154+
};
119155
option (google.api.method_signature) = "project_id,keys";
120156
}
121157
}
@@ -189,7 +225,8 @@ message RunQueryRequest {
189225
}
190226
}
191227

192-
// The response for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
228+
// The response for
229+
// [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
193230
message RunQueryResponse {
194231
// A batch of query results (always present).
195232
QueryResultBatch batch = 1;
@@ -198,7 +235,8 @@ message RunQueryResponse {
198235
Query query = 2;
199236
}
200237

201-
// The request for [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery].
238+
// The request for
239+
// [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery].
202240
message RunAggregationQueryRequest {
203241
// Required. The ID of the project against which to make the request.
204242
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
@@ -228,7 +266,8 @@ message RunAggregationQueryRequest {
228266
}
229267
}
230268

231-
// The response for [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery].
269+
// The response for
270+
// [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery].
232271
message RunAggregationQueryResponse {
233272
// A batch of aggregation results. Always present.
234273
AggregationResultBatch batch = 1;
@@ -237,7 +276,8 @@ message RunAggregationQueryResponse {
237276
AggregationQuery query = 2;
238277
}
239278

240-
// The request for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
279+
// The request for
280+
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
241281
message BeginTransactionRequest {
242282
// Required. The ID of the project against which to make the request.
243283
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
@@ -252,7 +292,8 @@ message BeginTransactionRequest {
252292
TransactionOptions transaction_options = 10;
253293
}
254294

255-
// The response for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
295+
// The response for
296+
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
256297
message BeginTransactionResponse {
257298
// The transaction identifier (always present).
258299
bytes transaction = 1;
@@ -274,11 +315,10 @@ message RollbackRequest {
274315
bytes transaction = 1 [(google.api.field_behavior) = REQUIRED];
275316
}
276317

277-
// The response for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback].
278-
// (an empty message).
279-
message RollbackResponse {
280-
281-
}
318+
// The response for
319+
// [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. (an empty
320+
// message).
321+
message RollbackResponse {}
282322

283323
// The request for [Datastore.Commit][google.datastore.v1.Datastore.Commit].
284324
message CommitRequest {
@@ -346,7 +386,8 @@ message CommitResponse {
346386
google.protobuf.Timestamp commit_time = 8;
347387
}
348388

349-
// The request for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
389+
// The request for
390+
// [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
350391
message AllocateIdsRequest {
351392
// Required. The ID of the project against which to make the request.
352393
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
@@ -357,19 +398,21 @@ message AllocateIdsRequest {
357398
// database.
358399
string database_id = 9;
359400

360-
// Required. A list of keys with incomplete key paths for which to allocate IDs.
361-
// No key may be reserved/read-only.
401+
// Required. A list of keys with incomplete key paths for which to allocate
402+
// IDs. No key may be reserved/read-only.
362403
repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED];
363404
}
364405

365-
// The response for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
406+
// The response for
407+
// [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
366408
message AllocateIdsResponse {
367409
// The keys specified in the request (in the same order), each with
368410
// its key path completed with a newly allocated ID.
369411
repeated Key keys = 1;
370412
}
371413

372-
// The request for [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
414+
// The request for
415+
// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
373416
message ReserveIdsRequest {
374417
// Required. The ID of the project against which to make the request.
375418
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
@@ -380,15 +423,14 @@ message ReserveIdsRequest {
380423
// database.
381424
string database_id = 9;
382425

383-
// Required. A list of keys with complete key paths whose numeric IDs should not be
384-
// auto-allocated.
426+
// Required. A list of keys with complete key paths whose numeric IDs should
427+
// not be auto-allocated.
385428
repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED];
386429
}
387430

388-
// The response for [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
389-
message ReserveIdsResponse {
390-
391-
}
431+
// The response for
432+
// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
433+
message ReserveIdsResponse {}
392434

393435
// A mutation to apply to an entity.
394436
message Mutation {
@@ -501,8 +543,10 @@ message ReadOptions {
501543
// Options for beginning a new transaction.
502544
//
503545
// Transactions can be created explicitly with calls to
504-
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction] or implicitly by setting
505-
// [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] in read requests.
546+
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]
547+
// or implicitly by setting
548+
// [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
549+
// in read requests.
506550
message TransactionOptions {
507551
// Options specific to read / write transactions.
508552
message ReadWrite {

0 commit comments

Comments
 (0)