Skip to content

Commit c1b543f

Browse files
authored
Merge pull request googleapis#2107 from dhermes/fix-2105
Updating datastore to use v1
2 parents 4a7afe2 + c03c216 commit c1b543f

13 files changed

Lines changed: 521 additions & 439 deletions

Makefile.bigtable_v2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ generate:
1616
[ -d $(GRPCIO_VIRTUALENV) ] || python2.7 -m virtualenv $(GRPCIO_VIRTUALENV)
1717
$(GRPCIO_VIRTUALENV)/bin/pip install --upgrade grpcio grpcio-tools
1818
# Retrieve git repos that have our *.proto files.
19-
[ -d googleapis-pb ] || git clone https://github.com/google/googleapis googleapis-pb --depth=1
19+
[ -d googleapis-pb ] || git clone https://github.com/googleapis/googleapis googleapis-pb --depth=1
2020
cd googleapis-pb && git pull origin master
2121
# Make the directory where our *_pb2.py files will go.
2222
mkdir -p $(GENERATED_DIR)

Makefile.datastore

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ generate:
1515
[ -d $(GRPCIO_VIRTUALENV) ] || python2.7 -m virtualenv $(GRPCIO_VIRTUALENV)
1616
$(GRPCIO_VIRTUALENV)/bin/pip install --upgrade grpcio grpcio-tools
1717
# Retrieve git repos that have our *.proto files.
18-
[ -d googleapis-pb ] || git clone https://github.com/google/googleapis googleapis-pb --depth=1
18+
[ -d googleapis-pb ] || git clone https://github.com/googleapis/googleapis googleapis-pb --depth=1
1919
cd googleapis-pb && git pull origin master
2020
# Make the directory where our *_pb2.py files will go.
2121
mkdir -p $(GENERATED_DIR)
2222
# Generate all *_pb2.py files that do not require gRPC.
2323
$(PROTOC_CMD) \
2424
--proto_path=$(GOOGLEAPIS_PROTOS_DIR) \
2525
--python_out=$(GENERATED_DIR) \
26-
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1beta3/datastore.proto \
27-
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1beta3/entity.proto \
28-
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1beta3/query.proto
26+
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1/datastore.proto \
27+
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1/entity.proto \
28+
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1/query.proto
2929
# Move the newly generated *_pb2.py files into our library.
30-
cp $(GENERATED_DIR)/google/datastore/v1beta3/* $(DATASTORE_DIR)
30+
cp $(GENERATED_DIR)/google/datastore/v1/* $(DATASTORE_DIR)
3131
# Remove all existing *.proto files before we replace
3232
rm -f $(DATASTORE_DIR)/*.proto
3333
# Copy over the *.proto files into our library.
34-
cp $(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1beta3/*.proto $(DATASTORE_DIR)
34+
cp $(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1/*.proto $(DATASTORE_DIR)
3535
# Rename all *.proto files in our library with an
3636
# underscore and remove executable bit.
3737
cd $(DATASTORE_DIR) && \

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ writes, strong consistency for reads and ancestor queries, and eventual
7474
consistency for all other queries.
7575

7676
.. _Cloud Datastore: https://cloud.google.com/datastore/docs
77-
.. _Datastore API docs: https://cloud.google.com/datastore/docs/apis/v1beta3/
77+
.. _Datastore API docs: https://cloud.google.com/datastore/docs/
7878

7979
See the ``gcloud-python`` API `datastore documentation`_ to learn how to
8080
interact with the Cloud Datastore using this Client Library.

gcloud/datastore/_generated/_datastore.proto

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015, Google Inc.
1+
// Copyright 2016 Google Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,15 +14,15 @@
1414

1515
syntax = "proto3";
1616

17-
package google.datastore.v1beta3;
17+
package google.datastore.v1;
1818

1919
import "google/api/annotations.proto";
20-
import "google/datastore/v1beta3/entity.proto";
21-
import "google/datastore/v1beta3/query.proto";
20+
import "google/datastore/v1/entity.proto";
21+
import "google/datastore/v1/query.proto";
2222

2323
option java_multiple_files = true;
2424
option java_outer_classname = "DatastoreProto";
25-
option java_package = "com.google.datastore.v1beta3";
25+
option java_package = "com.google.datastore.v1";
2626

2727

2828
// Each RPC normalizes the partition IDs of the keys in its input entities,
@@ -32,42 +32,41 @@ option java_package = "com.google.datastore.v1beta3";
3232
// input keys sets the project ID (if not already set) to the project ID from
3333
// the request.
3434
//
35-
//
3635
service Datastore {
3736
// Looks up entities by key.
3837
rpc Lookup(LookupRequest) returns (LookupResponse) {
39-
option (google.api.http) = { post: "/v1beta3/projects/{project_id}:lookup" body: "*" };
38+
option (google.api.http) = { post: "/v1/projects/{project_id}:lookup" body: "*" };
4039
}
4140

4241
// Queries for entities.
4342
rpc RunQuery(RunQueryRequest) returns (RunQueryResponse) {
44-
option (google.api.http) = { post: "/v1beta3/projects/{project_id}:runQuery" body: "*" };
43+
option (google.api.http) = { post: "/v1/projects/{project_id}:runQuery" body: "*" };
4544
}
4645

4746
// Begins a new transaction.
4847
rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) {
49-
option (google.api.http) = { post: "/v1beta3/projects/{project_id}:beginTransaction" body: "*" };
48+
option (google.api.http) = { post: "/v1/projects/{project_id}:beginTransaction" body: "*" };
5049
}
5150

5251
// Commits a transaction, optionally creating, deleting or modifying some
5352
// entities.
5453
rpc Commit(CommitRequest) returns (CommitResponse) {
55-
option (google.api.http) = { post: "/v1beta3/projects/{project_id}:commit" body: "*" };
54+
option (google.api.http) = { post: "/v1/projects/{project_id}:commit" body: "*" };
5655
}
5756

5857
// Rolls back a transaction.
5958
rpc Rollback(RollbackRequest) returns (RollbackResponse) {
60-
option (google.api.http) = { post: "/v1beta3/projects/{project_id}:rollback" body: "*" };
59+
option (google.api.http) = { post: "/v1/projects/{project_id}:rollback" body: "*" };
6160
}
6261

6362
// Allocates IDs for the given keys, which is useful for referencing an entity
6463
// before it is inserted.
6564
rpc AllocateIds(AllocateIdsRequest) returns (AllocateIdsResponse) {
66-
option (google.api.http) = { post: "/v1beta3/projects/{project_id}:allocateIds" body: "*" };
65+
option (google.api.http) = { post: "/v1/projects/{project_id}:allocateIds" body: "*" };
6766
}
6867
}
6968

70-
// The request for [google.datastore.v1beta3.Datastore.Lookup][google.datastore.v1beta3.Datastore.Lookup].
69+
// The request for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup].
7170
message LookupRequest {
7271
// The ID of the project against which to make the request.
7372
string project_id = 8;
@@ -79,7 +78,7 @@ message LookupRequest {
7978
repeated Key keys = 3;
8079
}
8180

82-
// The response for [google.datastore.v1beta3.Datastore.Lookup][google.datastore.v1beta3.Datastore.Lookup].
81+
// The response for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup].
8382
message LookupResponse {
8483
// Entities found as `ResultType.FULL` entities. The order of results in this
8584
// field is undefined and has no relation to the order of the keys in the
@@ -97,7 +96,7 @@ message LookupResponse {
9796
repeated Key deferred = 3;
9897
}
9998

100-
// The request for [google.datastore.v1beta3.Datastore.RunQuery][google.datastore.v1beta3.Datastore.RunQuery].
99+
// The request for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
101100
message RunQueryRequest {
102101
// The ID of the project against which to make the request.
103102
string project_id = 8;
@@ -121,7 +120,7 @@ message RunQueryRequest {
121120
}
122121
}
123122

124-
// The response for [google.datastore.v1beta3.Datastore.RunQuery][google.datastore.v1beta3.Datastore.RunQuery].
123+
// The response for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
125124
message RunQueryResponse {
126125
// A batch of query results (always present).
127126
QueryResultBatch batch = 1;
@@ -130,35 +129,35 @@ message RunQueryResponse {
130129
Query query = 2;
131130
}
132131

133-
// The request for [google.datastore.v1beta3.Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
132+
// The request for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
134133
message BeginTransactionRequest {
135134
// The ID of the project against which to make the request.
136135
string project_id = 8;
137136
}
138137

139-
// The response for [google.datastore.v1beta3.Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
138+
// The response for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
140139
message BeginTransactionResponse {
141140
// The transaction identifier (always present).
142141
bytes transaction = 1;
143142
}
144143

145-
// The request for [google.datastore.v1beta3.Datastore.Rollback][google.datastore.v1beta3.Datastore.Rollback].
144+
// The request for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback].
146145
message RollbackRequest {
147146
// The ID of the project against which to make the request.
148147
string project_id = 8;
149148

150149
// The transaction identifier, returned by a call to
151-
// [google.datastore.v1beta3.Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
150+
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
152151
bytes transaction = 1;
153152
}
154153

155-
// The response for [google.datastore.v1beta3.Datastore.Rollback][google.datastore.v1beta3.Datastore.Rollback]
154+
// The response for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback].
156155
// (an empty message).
157156
message RollbackResponse {
158157

159158
}
160159

161-
// The request for [google.datastore.v1beta3.Datastore.Commit][google.datastore.v1beta3.Datastore.Commit].
160+
// The request for [Datastore.Commit][google.datastore.v1.Datastore.Commit].
162161
message CommitRequest {
163162
// The modes available for commits.
164163
enum Mode {
@@ -183,7 +182,7 @@ message CommitRequest {
183182
oneof transaction_selector {
184183
// The identifier of the transaction associated with the commit. A
185184
// transaction identifier is returned by a call to
186-
// [BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
185+
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
187186
bytes transaction = 1;
188187
}
189188

@@ -203,7 +202,7 @@ message CommitRequest {
203202
repeated Mutation mutations = 6;
204203
}
205204

206-
// The response for [google.datastore.v1beta3.Datastore.Commit][google.datastore.v1beta3.Datastore.Commit].
205+
// The response for [Datastore.Commit][google.datastore.v1.Datastore.Commit].
207206
message CommitResponse {
208207
// The result of performing the mutations.
209208
// The i-th mutation result corresponds to the i-th mutation in the request.
@@ -214,7 +213,7 @@ message CommitResponse {
214213
int32 index_updates = 4;
215214
}
216215

217-
// The request for [google.datastore.v1beta3.Datastore.AllocateIds][google.datastore.v1beta3.Datastore.AllocateIds].
216+
// The request for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
218217
message AllocateIdsRequest {
219218
// The ID of the project against which to make the request.
220219
string project_id = 8;
@@ -224,7 +223,7 @@ message AllocateIdsRequest {
224223
repeated Key keys = 1;
225224
}
226225

227-
// The response for [google.datastore.v1beta3.Datastore.AllocateIds][google.datastore.v1beta3.Datastore.AllocateIds].
226+
// The response for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
228227
message AllocateIdsResponse {
229228
// The keys specified in the request (in the same order), each with
230229
// its key path completed with a newly allocated ID.
@@ -258,13 +257,33 @@ message Mutation {
258257
// Must have a complete key path and must not be reserved/read-only.
259258
Key delete = 7;
260259
}
260+
261+
// When set, the server will detect whether or not this mutation conflicts
262+
// with the current version of the entity on the server. Conflicting mutations
263+
// are not applied, and are marked as such in MutationResult.
264+
oneof conflict_detection_strategy {
265+
// The version of the entity that this mutation is being applied to. If this
266+
// does not match the current version on the server, the mutation conflicts.
267+
int64 base_version = 8;
268+
}
261269
}
262270

263271
// The result of applying a mutation.
264272
message MutationResult {
265273
// The automatically allocated key.
266274
// Set only when the mutation allocated a key.
267275
Key key = 3;
276+
277+
// The version of the entity on the server after processing the mutation. If
278+
// the mutation doesn't change anything on the server, then the version will
279+
// be the version of the current entity or, if no entity is present, a version
280+
// that is strictly greater than the version of any previous entity and less
281+
// than the version of any possible future entity.
282+
int64 version = 4;
283+
284+
// Whether a conflict was detected for this mutation. Always false when a
285+
// conflict detection strategy field is not set in the mutation.
286+
bool conflict_detected = 5;
268287
}
269288

270289
// The options shared by read requests.
@@ -289,7 +308,9 @@ message ReadOptions {
289308
// Cannot be set to `STRONG` for global queries.
290309
ReadConsistency read_consistency = 1;
291310

292-
// The transaction in which to read.
311+
// The identifier of the transaction in which to read. A
312+
// transaction identifier is returned by a call to
313+
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
293314
bytes transaction = 2;
294315
}
295316
}

gcloud/datastore/_generated/_entity.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015, Google Inc.
1+
// Copyright 2016 Google Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414

1515
syntax = "proto3";
1616

17-
package google.datastore.v1beta3;
17+
package google.datastore.v1;
1818

1919
import "google/api/annotations.proto";
2020
import "google/protobuf/struct.proto";
@@ -23,7 +23,7 @@ import "google/type/latlng.proto";
2323

2424
option java_multiple_files = true;
2525
option java_outer_classname = "EntityProto";
26-
option java_package = "com.google.datastore.v1beta3";
26+
option java_package = "com.google.datastore.v1";
2727

2828

2929
// A partition ID identifies a grouping of entities. The grouping is always

0 commit comments

Comments
 (0)