From 6a16d474d5be201b20a27646e2009c4dfde30452 Mon Sep 17 00:00:00 2001 From: Google APIs Date: Tue, 26 Nov 2019 07:50:39 -0800 Subject: [PATCH] Migrate Datastore to GAPIC v2. Committer: @lukesneeringer PiperOrigin-RevId: 282564329 --- google/datastore/artman_datastore.yaml | 3 +- google/datastore/datastore.yaml | 20 --- google/datastore/v1/datastore.proto | 107 ++++++++------- .../datastore/v1/datastore_gapic.legacy.yaml | 126 ++++++++++++++++++ google/datastore/v1/datastore_gapic.yaml | 108 +-------------- .../v1/datastore_grpc_service_config.json | 51 +++++++ google/datastore/v1/datastore_v1.yaml | 43 ++++++ google/datastore/v1/entity.proto | 10 +- google/datastore/v1/query.proto | 12 +- 9 files changed, 292 insertions(+), 188 deletions(-) delete mode 100644 google/datastore/datastore.yaml create mode 100644 google/datastore/v1/datastore_gapic.legacy.yaml create mode 100755 google/datastore/v1/datastore_grpc_service_config.json create mode 100644 google/datastore/v1/datastore_v1.yaml diff --git a/google/datastore/artman_datastore.yaml b/google/datastore/artman_datastore.yaml index 787c8fd9..9f5629ba 100644 --- a/google/datastore/artman_datastore.yaml +++ b/google/datastore/artman_datastore.yaml @@ -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: diff --git a/google/datastore/datastore.yaml b/google/datastore/datastore.yaml deleted file mode 100644 index 26822278..00000000 --- a/google/datastore/datastore.yaml +++ /dev/null @@ -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 diff --git a/google/datastore/v1/datastore.proto b/google/datastore/v1/datastore.proto index 51d69acb..0df65c44 100644 --- a/google/datastore/v1/datastore.proto +++ b/google/datastore/v1/datastore.proto @@ -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. diff --git a/google/datastore/v1/datastore_gapic.legacy.yaml b/google/datastore/v1/datastore_gapic.legacy.yaml new file mode 100644 index 00000000..bbdf7200 --- /dev/null +++ b/google/datastore/v1/datastore_gapic.legacy.yaml @@ -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 diff --git a/google/datastore/v1/datastore_gapic.yaml b/google/datastore/v1/datastore_gapic.yaml index bbdf7200..b9277e44 100644 --- a/google/datastore/v1/datastore_gapic.yaml +++ b/google/datastore/v1/datastore_gapic.yaml @@ -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 diff --git a/google/datastore/v1/datastore_grpc_service_config.json b/google/datastore/v1/datastore_grpc_service_config.json new file mode 100755 index 00000000..48a210a8 --- /dev/null +++ b/google/datastore/v1/datastore_grpc_service_config.json @@ -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" + } + ] +} diff --git a/google/datastore/v1/datastore_v1.yaml b/google/datastore/v1/datastore_v1.yaml new file mode 100644 index 00000000..bd26ed77 --- /dev/null +++ b/google/datastore/v1/datastore_v1.yaml @@ -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 diff --git a/google/datastore/v1/entity.proto b/google/datastore/v1/entity.proto index 9decd2b5..96d13ecc 100644 --- a/google/datastore/v1/entity.proto +++ b/google/datastore/v1/entity.proto @@ -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. diff --git a/google/datastore/v1/query.proto b/google/datastore/v1/query.proto index 872612c5..ef9f1c65 100644 --- a/google/datastore/v1/query.proto +++ b/google/datastore/v1/query.proto @@ -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.