Skip to content

Commit

Permalink
Merge pull request #2107 from dhermes/fix-2105
Browse files Browse the repository at this point in the history
Updating datastore to use v1
  • Loading branch information
dhermes authored Aug 17, 2016
2 parents 4a7afe2 + c03c216 commit c1b543f
Show file tree
Hide file tree
Showing 13 changed files with 521 additions and 439 deletions.
2 changes: 1 addition & 1 deletion Makefile.bigtable_v2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ generate:
[ -d $(GRPCIO_VIRTUALENV) ] || python2.7 -m virtualenv $(GRPCIO_VIRTUALENV)
$(GRPCIO_VIRTUALENV)/bin/pip install --upgrade grpcio grpcio-tools
# Retrieve git repos that have our *.proto files.
[ -d googleapis-pb ] || git clone https://github.com/google/googleapis googleapis-pb --depth=1
[ -d googleapis-pb ] || git clone https://github.com/googleapis/googleapis googleapis-pb --depth=1
cd googleapis-pb && git pull origin master
# Make the directory where our *_pb2.py files will go.
mkdir -p $(GENERATED_DIR)
Expand Down
12 changes: 6 additions & 6 deletions Makefile.datastore
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ generate:
[ -d $(GRPCIO_VIRTUALENV) ] || python2.7 -m virtualenv $(GRPCIO_VIRTUALENV)
$(GRPCIO_VIRTUALENV)/bin/pip install --upgrade grpcio grpcio-tools
# Retrieve git repos that have our *.proto files.
[ -d googleapis-pb ] || git clone https://github.com/google/googleapis googleapis-pb --depth=1
[ -d googleapis-pb ] || git clone https://github.com/googleapis/googleapis googleapis-pb --depth=1
cd googleapis-pb && git pull origin master
# Make the directory where our *_pb2.py files will go.
mkdir -p $(GENERATED_DIR)
# Generate all *_pb2.py files that do not require gRPC.
$(PROTOC_CMD) \
--proto_path=$(GOOGLEAPIS_PROTOS_DIR) \
--python_out=$(GENERATED_DIR) \
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1beta3/datastore.proto \
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1beta3/entity.proto \
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1beta3/query.proto
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1/datastore.proto \
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1/entity.proto \
$(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1/query.proto
# Move the newly generated *_pb2.py files into our library.
cp $(GENERATED_DIR)/google/datastore/v1beta3/* $(DATASTORE_DIR)
cp $(GENERATED_DIR)/google/datastore/v1/* $(DATASTORE_DIR)
# Remove all existing *.proto files before we replace
rm -f $(DATASTORE_DIR)/*.proto
# Copy over the *.proto files into our library.
cp $(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1beta3/*.proto $(DATASTORE_DIR)
cp $(GOOGLEAPIS_PROTOS_DIR)/google/datastore/v1/*.proto $(DATASTORE_DIR)
# Rename all *.proto files in our library with an
# underscore and remove executable bit.
cd $(DATASTORE_DIR) && \
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ writes, strong consistency for reads and ancestor queries, and eventual
consistency for all other queries.

.. _Cloud Datastore: https://cloud.google.com/datastore/docs
.. _Datastore API docs: https://cloud.google.com/datastore/docs/apis/v1beta3/
.. _Datastore API docs: https://cloud.google.com/datastore/docs/

See the ``gcloud-python`` API `datastore documentation`_ to learn how to
interact with the Cloud Datastore using this Client Library.
Expand Down
75 changes: 48 additions & 27 deletions gcloud/datastore/_generated/_datastore.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015, Google Inc.
// Copyright 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,15 +14,15 @@

syntax = "proto3";

package google.datastore.v1beta3;
package google.datastore.v1;

import "google/api/annotations.proto";
import "google/datastore/v1beta3/entity.proto";
import "google/datastore/v1beta3/query.proto";
import "google/datastore/v1/entity.proto";
import "google/datastore/v1/query.proto";

option java_multiple_files = true;
option java_outer_classname = "DatastoreProto";
option java_package = "com.google.datastore.v1beta3";
option java_package = "com.google.datastore.v1";


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

// Queries for entities.
rpc RunQuery(RunQueryRequest) returns (RunQueryResponse) {
option (google.api.http) = { post: "/v1beta3/projects/{project_id}:runQuery" body: "*" };
option (google.api.http) = { post: "/v1/projects/{project_id}:runQuery" body: "*" };
}

// Begins a new transaction.
rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) {
option (google.api.http) = { post: "/v1beta3/projects/{project_id}:beginTransaction" body: "*" };
option (google.api.http) = { post: "/v1/projects/{project_id}:beginTransaction" body: "*" };
}

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

// Rolls back a transaction.
rpc Rollback(RollbackRequest) returns (RollbackResponse) {
option (google.api.http) = { post: "/v1beta3/projects/{project_id}:rollback" body: "*" };
option (google.api.http) = { post: "/v1/projects/{project_id}:rollback" body: "*" };
}

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

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

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

// The request for [google.datastore.v1beta3.Datastore.RunQuery][google.datastore.v1beta3.Datastore.RunQuery].
// The request for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
message RunQueryRequest {
// The ID of the project against which to make the request.
string project_id = 8;
Expand All @@ -121,7 +120,7 @@ message RunQueryRequest {
}
}

// The response for [google.datastore.v1beta3.Datastore.RunQuery][google.datastore.v1beta3.Datastore.RunQuery].
// The response for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
message RunQueryResponse {
// A batch of query results (always present).
QueryResultBatch batch = 1;
Expand All @@ -130,35 +129,35 @@ message RunQueryResponse {
Query query = 2;
}

// The request for [google.datastore.v1beta3.Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
// The request for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
message BeginTransactionRequest {
// The ID of the project against which to make the request.
string project_id = 8;
}

// The response for [google.datastore.v1beta3.Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
// The response for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
message BeginTransactionResponse {
// The transaction identifier (always present).
bytes transaction = 1;
}

// The request for [google.datastore.v1beta3.Datastore.Rollback][google.datastore.v1beta3.Datastore.Rollback].
// The request for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback].
message RollbackRequest {
// The ID of the project against which to make the request.
string project_id = 8;

// The transaction identifier, returned by a call to
// [google.datastore.v1beta3.Datastore.BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
bytes transaction = 1;
}

// The response for [google.datastore.v1beta3.Datastore.Rollback][google.datastore.v1beta3.Datastore.Rollback]
// The response for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback].
// (an empty message).
message RollbackResponse {

}

// The request for [google.datastore.v1beta3.Datastore.Commit][google.datastore.v1beta3.Datastore.Commit].
// The request for [Datastore.Commit][google.datastore.v1.Datastore.Commit].
message CommitRequest {
// The modes available for commits.
enum Mode {
Expand All @@ -183,7 +182,7 @@ message CommitRequest {
oneof transaction_selector {
// The identifier of the transaction associated with the commit. A
// transaction identifier is returned by a call to
// [BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction].
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
bytes transaction = 1;
}

Expand All @@ -203,7 +202,7 @@ message CommitRequest {
repeated Mutation mutations = 6;
}

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

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

// The response for [google.datastore.v1beta3.Datastore.AllocateIds][google.datastore.v1beta3.Datastore.AllocateIds].
// The response for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
message AllocateIdsResponse {
// The keys specified in the request (in the same order), each with
// its key path completed with a newly allocated ID.
Expand Down Expand Up @@ -258,13 +257,33 @@ message Mutation {
// Must have a complete key path and must not be reserved/read-only.
Key delete = 7;
}

// When set, the server will detect whether or not this mutation conflicts
// with the current version of the entity on the server. Conflicting mutations
// are not applied, and are marked as such in MutationResult.
oneof conflict_detection_strategy {
// The version of the entity that this mutation is being applied to. If this
// does not match the current version on the server, the mutation conflicts.
int64 base_version = 8;
}
}

// The result of applying a mutation.
message MutationResult {
// The automatically allocated key.
// Set only when the mutation allocated a key.
Key key = 3;

// The version of the entity on the server after processing the mutation. If
// the mutation doesn't change anything on the server, then the version will
// be the version of the current entity or, if no entity is present, a version
// that is strictly greater than the version of any previous entity and less
// than the version of any possible future entity.
int64 version = 4;

// Whether a conflict was detected for this mutation. Always false when a
// conflict detection strategy field is not set in the mutation.
bool conflict_detected = 5;
}

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

// The transaction in which to read.
// The identifier of the transaction in which to read. A
// transaction identifier is returned by a call to
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
bytes transaction = 2;
}
}
6 changes: 3 additions & 3 deletions gcloud/datastore/_generated/_entity.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015, Google Inc.
// Copyright 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@

syntax = "proto3";

package google.datastore.v1beta3;
package google.datastore.v1;

import "google/api/annotations.proto";
import "google/protobuf/struct.proto";
Expand All @@ -23,7 +23,7 @@ import "google/type/latlng.proto";

option java_multiple_files = true;
option java_outer_classname = "EntityProto";
option java_package = "com.google.datastore.v1beta3";
option java_package = "com.google.datastore.v1";


// A partition ID identifies a grouping of entities. The grouping is always
Expand Down
Loading

0 comments on commit c1b543f

Please sign in to comment.