Migrate Datastore to GAPIC v2.

Committer: @lukesneeringer
PiperOrigin-RevId: 282564329
This commit is contained in:
Google APIs 2019-11-26 07:50:39 -08:00 committed by Copybara-Service
parent 74bd9b95ac
commit 6a16d474d5
9 changed files with 292 additions and 188 deletions

View File

@ -2,8 +2,9 @@ common:
api_name: datastore
api_version: v1
organization_name: google-cloud
service_yaml: datastore.yaml
service_yaml: v1/datastore_v1.yaml
gapic_yaml: v1/datastore_gapic.yaml
proto_package: google.datastore.v1
src_proto_paths:
- v1
proto_deps:

View File

@ -1,20 +0,0 @@
type: google.api.Service
config_version: 3
name: datastore.googleapis.com
title: Google Cloud Datastore API
apis:
- name: google.datastore.v1.Datastore
documentation:
summary: |-
Accesses the schemaless NoSQL database to provide fully managed, robust,
scalable storage for your application.
authentication:
rules:
- selector: '*'
oauth:
canonical_scopes: |-
https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/datastore

View File

@ -1,4 +1,4 @@
// Copyright 2018 Google Inc.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -17,6 +17,8 @@ syntax = "proto3";
package google.datastore.v1;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/datastore/v1/entity.proto";
import "google/datastore/v1/query.proto";
@ -35,12 +37,18 @@ option php_namespace = "Google\\Cloud\\Datastore\\V1";
// the request.
//
service Datastore {
option (google.api.default_host) = "datastore.googleapis.com";
option (google.api.oauth_scopes) =
"https://www.googleapis.com/auth/cloud-platform,"
"https://www.googleapis.com/auth/datastore";
// Looks up entities by key.
rpc Lookup(LookupRequest) returns (LookupResponse) {
option (google.api.http) = {
post: "/v1/projects/{project_id}:lookup"
body: "*"
};
option (google.api.method_signature) = "project_id,read_options,keys";
}
// Queries for entities.
@ -52,12 +60,12 @@ service Datastore {
}
// Begins a new transaction.
rpc BeginTransaction(BeginTransactionRequest)
returns (BeginTransactionResponse) {
rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) {
option (google.api.http) = {
post: "/v1/projects/{project_id}:beginTransaction"
body: "*"
};
option (google.api.method_signature) = "project_id";
}
// Commits a transaction, optionally creating, deleting or modifying some
@ -67,6 +75,8 @@ service Datastore {
post: "/v1/projects/{project_id}:commit"
body: "*"
};
option (google.api.method_signature) = "project_id,mode,transaction,mutations";
option (google.api.method_signature) = "project_id,mode,mutations";
}
// Rolls back a transaction.
@ -75,6 +85,7 @@ service Datastore {
post: "/v1/projects/{project_id}:rollback"
body: "*"
};
option (google.api.method_signature) = "project_id,transaction";
}
// Allocates IDs for the given keys, which is useful for referencing an entity
@ -84,6 +95,7 @@ service Datastore {
post: "/v1/projects/{project_id}:allocateIds"
body: "*"
};
option (google.api.method_signature) = "project_id,keys";
}
// Prevents the supplied keys' IDs from being auto-allocated by Cloud
@ -93,19 +105,20 @@ service Datastore {
post: "/v1/projects/{project_id}:reserveIds"
body: "*"
};
option (google.api.method_signature) = "project_id,keys";
}
}
// 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;
// Required. The ID of the project against which to make the request.
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
// The options for this lookup request.
ReadOptions read_options = 1;
// Keys of entities to look up.
repeated Key keys = 3;
// Required. Keys of entities to look up.
repeated Key keys = 3 [(google.api.field_behavior) = REQUIRED];
}
// The response for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup].
@ -128,8 +141,8 @@ message LookupResponse {
// 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;
// Required. The ID of the project against which to make the request.
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
// Entities are partitioned into subsets, identified by a partition ID.
// Queries are scoped to a single partition.
@ -150,8 +163,7 @@ message RunQueryRequest {
}
}
// The response for
// [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
// The response for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
message RunQueryResponse {
// A batch of query results (always present).
QueryResultBatch batch = 1;
@ -160,18 +172,16 @@ message RunQueryResponse {
Query query = 2;
}
// The request for
// [Datastore.BeginTransaction][google.datastore.v1.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;
// Required. The ID of the project against which to make the request.
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
// Options for a new transaction.
TransactionOptions transaction_options = 10;
}
// The response for
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
// The response for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
message BeginTransactionResponse {
// The transaction identifier (always present).
bytes transaction = 1;
@ -179,18 +189,19 @@ message BeginTransactionResponse {
// 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;
// Required. The ID of the project against which to make the request.
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
// The transaction identifier, returned by a call to
// Required. The transaction identifier, returned by a call to
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
bytes transaction = 1;
bytes transaction = 1 [(google.api.field_behavior) = REQUIRED];
}
// The response for
// [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. (an empty
// message).
message RollbackResponse {}
// The response for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback].
// (an empty message).
message RollbackResponse {
}
// The request for [Datastore.Commit][google.datastore.v1.Datastore.Commit].
message CommitRequest {
@ -208,8 +219,8 @@ message CommitRequest {
NON_TRANSACTIONAL = 2;
}
// The ID of the project against which to make the request.
string project_id = 8;
// Required. The ID of the project against which to make the request.
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
// The type of commit to perform. Defaults to `TRANSACTIONAL`.
Mode mode = 5;
@ -249,42 +260,40 @@ message CommitResponse {
int32 index_updates = 4;
}
// The request for
// [Datastore.AllocateIds][google.datastore.v1.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;
// Required. The ID of the project against which to make the request.
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
// A list of keys with incomplete key paths for which to allocate IDs.
// Required. A list of keys with incomplete key paths for which to allocate IDs.
// No key may be reserved/read-only.
repeated Key keys = 1;
repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED];
}
// The response for
// [Datastore.AllocateIds][google.datastore.v1.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.
repeated Key keys = 1;
}
// The request for
// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
// The request for [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
message ReserveIdsRequest {
// The ID of the project against which to make the request.
string project_id = 8;
// Required. The ID of the project against which to make the request.
string project_id = 8 [(google.api.field_behavior) = REQUIRED];
// If not empty, the ID of the database against which to make the request.
string database_id = 9;
// A list of keys with complete key paths whose numeric IDs should not be
// Required. A list of keys with complete key paths whose numeric IDs should not be
// auto-allocated.
repeated Key keys = 1;
repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED];
}
// The response for
// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
message ReserveIdsResponse {}
// The response for [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
message ReserveIdsResponse {
}
// A mutation to apply to an entity.
message Mutation {
@ -374,10 +383,8 @@ message ReadOptions {
// Options for beginning a new transaction.
//
// Transactions can be created explicitly with calls to
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]
// or implicitly by setting
// [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
// in read requests.
// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction] or implicitly by setting
// [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] in read requests.
message TransactionOptions {
// Options specific to read / write transactions.
message ReadWrite {
@ -386,7 +393,9 @@ message TransactionOptions {
}
// Options specific to read-only transactions.
message ReadOnly {}
message ReadOnly {
}
// The `mode` of the transaction, indicating whether write operations are
// supported.

View File

@ -0,0 +1,126 @@
type: com.google.api.codegen.ConfigProto
config_schema_version: 1.0.0
language_settings:
java:
package_name: com.google.cloud.datastore.v1
python:
package_name: google.cloud.datastore_v1.gapic
go:
package_name: cloud.google.com/go/datastore/apiv1
csharp:
package_name: Google.Cloud.Datastore.V1
release_level: GA
ruby:
package_name: Google::Cloud::Datastore::V1
release_level: GA
php:
package_name: Google\Cloud\Datastore\V1
nodejs:
package_name: datastore.v1
domain_layer_location: google-cloud
interfaces:
- name: google.datastore.v1.Datastore
collections: []
retry_codes_def:
- name: idempotent
retry_codes:
- UNAVAILABLE
- DEADLINE_EXCEEDED
- name: non_idempotent
retry_codes: []
retry_params_def:
- name: default
initial_retry_delay_millis: 100
retry_delay_multiplier: 1.3
max_retry_delay_millis: 60000
initial_rpc_timeout_millis: 60000
rpc_timeout_multiplier: 1
max_rpc_timeout_millis: 60000
total_timeout_millis: 600000
methods:
- name: Lookup
flattening:
groups:
- parameters:
- project_id
- read_options
- keys
required_fields:
- project_id
- keys
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000
- name: RunQuery
# NOTE: Add flattening with oneof when oneofs implemented
required_fields:
- project_id
- partition_id
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000
- name: BeginTransaction
flattening:
groups:
- parameters:
- project_id
required_fields:
- project_id
retry_codes_name: non_idempotent
retry_params_name: default
timeout_millis: 60000
- name: Commit
flattening:
groups:
- parameters:
- project_id
- mode
- transaction
- mutations
- parameters:
- project_id
- mode
- mutations
required_fields:
- project_id
- mode
- mutations
retry_codes_name: non_idempotent
retry_params_name: default
timeout_millis: 60000
- name: Rollback
flattening:
groups:
- parameters:
- project_id
- transaction
required_fields:
- project_id
- transaction
retry_codes_name: non_idempotent
retry_params_name: default
timeout_millis: 60000
- name: AllocateIds
flattening:
groups:
- parameters:
- project_id
- keys
required_fields:
- project_id
- keys
retry_codes_name: non_idempotent
retry_params_name: default
timeout_millis: 60000
- name: ReserveIds
flattening:
groups:
- parameters:
- project_id
- keys
required_fields:
- project_id
- keys
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000

View File

@ -1,5 +1,5 @@
type: com.google.api.codegen.ConfigProto
config_schema_version: 1.0.0
config_schema_version: 2.0.0
language_settings:
java:
package_name: com.google.cloud.datastore.v1
@ -18,109 +18,3 @@ language_settings:
nodejs:
package_name: datastore.v1
domain_layer_location: google-cloud
interfaces:
- name: google.datastore.v1.Datastore
collections: []
retry_codes_def:
- name: idempotent
retry_codes:
- UNAVAILABLE
- DEADLINE_EXCEEDED
- name: non_idempotent
retry_codes: []
retry_params_def:
- name: default
initial_retry_delay_millis: 100
retry_delay_multiplier: 1.3
max_retry_delay_millis: 60000
initial_rpc_timeout_millis: 60000
rpc_timeout_multiplier: 1
max_rpc_timeout_millis: 60000
total_timeout_millis: 600000
methods:
- name: Lookup
flattening:
groups:
- parameters:
- project_id
- read_options
- keys
required_fields:
- project_id
- keys
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000
- name: RunQuery
# NOTE: Add flattening with oneof when oneofs implemented
required_fields:
- project_id
- partition_id
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000
- name: BeginTransaction
flattening:
groups:
- parameters:
- project_id
required_fields:
- project_id
retry_codes_name: non_idempotent
retry_params_name: default
timeout_millis: 60000
- name: Commit
flattening:
groups:
- parameters:
- project_id
- mode
- transaction
- mutations
- parameters:
- project_id
- mode
- mutations
required_fields:
- project_id
- mode
- mutations
retry_codes_name: non_idempotent
retry_params_name: default
timeout_millis: 60000
- name: Rollback
flattening:
groups:
- parameters:
- project_id
- transaction
required_fields:
- project_id
- transaction
retry_codes_name: non_idempotent
retry_params_name: default
timeout_millis: 60000
- name: AllocateIds
flattening:
groups:
- parameters:
- project_id
- keys
required_fields:
- project_id
- keys
retry_codes_name: non_idempotent
retry_params_name: default
timeout_millis: 60000
- name: ReserveIds
flattening:
groups:
- parameters:
- project_id
- keys
required_fields:
- project_id
- keys
retry_codes_name: idempotent
retry_params_name: default
timeout_millis: 60000

View File

@ -0,0 +1,51 @@
{
"methodConfig": [
{
"name": [
{
"service": "google.datastore.v1.Datastore",
"method": "Lookup"
},
{
"service": "google.datastore.v1.Datastore",
"method": "RunQuery"
},
{
"service": "google.datastore.v1.Datastore",
"method": "ReserveIds"
}
],
"timeout": "60s",
"retryPolicy": {
"initialBackoff": "0.100s",
"maxBackoff": "60s",
"backoffMultiplier": 1.3,
"retryableStatusCodes": [
"UNAVAILABLE",
"DEADLINE_EXCEEDED"
]
}
},
{
"name": [
{
"service": "google.datastore.v1.Datastore",
"method": "BeginTransaction"
},
{
"service": "google.datastore.v1.Datastore",
"method": "Commit"
},
{
"service": "google.datastore.v1.Datastore",
"method": "Rollback"
},
{
"service": "google.datastore.v1.Datastore",
"method": "AllocateIds"
}
],
"timeout": "60s"
}
]
}

View File

@ -0,0 +1,43 @@
type: google.api.Service
config_version: 3
name: datastore.googleapis.com
title: Cloud Datastore API
apis:
- name: google.datastore.v1.Datastore
documentation:
summary: |-
Accesses the schemaless NoSQL database to provide fully managed, robust,
scalable storage for your application.
backend:
rules:
- selector: 'google.datastore.v1.Datastore.*'
deadline: 295.0
- selector: 'google.longrunning.Operations.*'
deadline: 295.0
http:
rules:
- selector: google.longrunning.Operations.CancelOperation
post: '/v1/{name=projects/*/operations/*}:cancel'
- selector: google.longrunning.Operations.DeleteOperation
delete: '/v1/{name=projects/*/operations/*}'
- selector: google.longrunning.Operations.GetOperation
get: '/v1/{name=projects/*/operations/*}'
- selector: google.longrunning.Operations.ListOperations
get: '/v1/{name=projects/*}/operations'
authentication:
rules:
- selector: 'google.datastore.v1.Datastore.*'
oauth:
canonical_scopes: |-
https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/datastore
- selector: 'google.longrunning.Operations.*'
oauth:
canonical_scopes: |-
https://www.googleapis.com/auth/cloud-platform,
https://www.googleapis.com/auth/datastore

View File

@ -1,4 +1,4 @@
// Copyright 2018 Google Inc.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -114,8 +114,8 @@ message Key {
// An array value.
message ArrayValue {
// Values in the array.
// The order of this array may not be preserved if it contains a mix of
// indexed and unindexed values.
// The order of values in an array is preserved as long as all values have
// identical settings for 'exclude_from_indexes'.
repeated Value values = 1;
}
@ -145,8 +145,8 @@ message Value {
Key key_value = 5;
// A UTF-8 encoded string value.
// When `exclude_from_indexes` is false (it is indexed) , may have at most
// 1500 bytes. Otherwise, may be set to at least 1,000,000 bytes.
// When `exclude_from_indexes` is false (it is indexed) , may have at most 1500 bytes.
// Otherwise, may be set to at least 1,000,000 bytes.
string string_value = 17;
// A blob value.

View File

@ -1,4 +1,4 @@
// Copyright 2018 Google Inc.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -55,12 +55,12 @@ message EntityResult {
// The version of the entity, a strictly positive number that monotonically
// increases with changes to the entity.
//
// This field is set for
// [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
// This field is set for [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity
// results.
//
// For [missing][google.datastore.v1.LookupResponse.missing] entities in
// `LookupResponse`, this is the version of the snapshot that was used to look
// up the entity, and it is always set except for eventually consistent reads.
// For [missing][google.datastore.v1.LookupResponse.missing] entities in `LookupResponse`, this
// is the version of the snapshot that was used to look up the entity, and it
// is always set except for eventually consistent reads.
int64 version = 4;
// A cursor that points to the position after the result entity.