From d77bf4b472e78bd9f46ec055792f2484ffc77873 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 24 Jun 2022 10:41:59 +0000 Subject: [PATCH 1/2] feat: support regapic LRO Use gapic-generator-typescript v2.15.1. PiperOrigin-RevId: 456946341 Source-Link: https://github.com/googleapis/googleapis/commit/88fd18d9d3b872b3d06a3d9392879f50b5bf3ce5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/accfa371f667439313335c64042b063c1c53102e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWNjZmEzNzFmNjY3NDM5MzEzMzM1YzY0MDQyYjA2M2MxYzUzMTAyZSJ9 --- owl-bot-staging/admin/v1/.eslintignore | 7 + owl-bot-staging/admin/v1/.eslintrc.json | 3 + owl-bot-staging/admin/v1/.gitignore | 14 + owl-bot-staging/admin/v1/.jsdoc.js | 55 + owl-bot-staging/admin/v1/.mocharc.js | 33 + owl-bot-staging/admin/v1/.prettierrc.js | 22 + owl-bot-staging/admin/v1/README.md | 1 + .../admin/v1/linkinator.config.json | 16 + owl-bot-staging/admin/v1/package.json | 64 + .../datastore/admin/v1/datastore_admin.proto | 511 +++++++ .../google/datastore/admin/v1/index.proto | 115 ++ .../google/datastore/admin/v1/migration.proto | 124 ++ .../v1/datastore_admin.create_index.js | 63 + .../v1/datastore_admin.delete_index.js | 62 + .../v1/datastore_admin.export_entities.js | 86 ++ .../generated/v1/datastore_admin.get_index.js | 61 + .../v1/datastore_admin.import_entities.js | 86 ++ .../v1/datastore_admin.list_indexes.js | 71 + ...et_metadata.google.datastore.admin.v1.json | 303 ++++ owl-bot-staging/admin/v1/src/index.ts | 25 + .../admin/v1/src/v1/datastore_admin_client.ts | 1295 ++++++++++++++++ .../src/v1/datastore_admin_client_config.json | 56 + .../v1/src/v1/datastore_admin_proto_list.json | 5 + .../admin/v1/src/v1/gapic_metadata.json | 87 ++ owl-bot-staging/admin/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + .../admin/v1/system-test/install.ts | 49 + .../admin/v1/test/gapic_datastore_admin_v1.ts | 1357 +++++++++++++++++ owl-bot-staging/admin/v1/tsconfig.json | 19 + owl-bot-staging/admin/v1/webpack.config.js | 64 + owl-bot-staging/v1/.eslintignore | 7 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 16 + owl-bot-staging/v1/package.json | 64 + .../google/datastore/v1/datastore.proto | 443 ++++++ .../protos/google/datastore/v1/entity.proto | 214 +++ .../v1/protos/google/datastore/v1/query.proto | 375 +++++ .../generated/v1/datastore.allocate_ids.js | 64 + .../v1/datastore.begin_transaction.js | 62 + .../samples/generated/v1/datastore.commit.js | 81 + .../samples/generated/v1/datastore.lookup.js | 67 + .../generated/v1/datastore.reserve_ids.js | 68 + .../generated/v1/datastore.rollback.js | 64 + .../generated/v1/datastore.run_query.js | 77 + .../snippet_metadata.google.datastore.v1.json | 351 +++++ owl-bot-staging/v1/src/index.ts | 25 + owl-bot-staging/v1/src/v1/datastore_client.ts | 847 ++++++++++ .../v1/src/v1/datastore_client_config.json | 61 + .../v1/src/v1/datastore_proto_list.json | 5 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 93 ++ owl-bot-staging/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + owl-bot-staging/v1/system-test/install.ts | 49 + owl-bot-staging/v1/test/gapic_datastore_v1.ts | 814 ++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + 63 files changed, 8868 insertions(+) create mode 100644 owl-bot-staging/admin/v1/.eslintignore create mode 100644 owl-bot-staging/admin/v1/.eslintrc.json create mode 100644 owl-bot-staging/admin/v1/.gitignore create mode 100644 owl-bot-staging/admin/v1/.jsdoc.js create mode 100644 owl-bot-staging/admin/v1/.mocharc.js create mode 100644 owl-bot-staging/admin/v1/.prettierrc.js create mode 100644 owl-bot-staging/admin/v1/README.md create mode 100644 owl-bot-staging/admin/v1/linkinator.config.json create mode 100644 owl-bot-staging/admin/v1/package.json create mode 100644 owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/datastore_admin.proto create mode 100644 owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/index.proto create mode 100644 owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/migration.proto create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.create_index.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.delete_index.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.export_entities.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.get_index.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.import_entities.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.list_indexes.js create mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json create mode 100644 owl-bot-staging/admin/v1/src/index.ts create mode 100644 owl-bot-staging/admin/v1/src/v1/datastore_admin_client.ts create mode 100644 owl-bot-staging/admin/v1/src/v1/datastore_admin_client_config.json create mode 100644 owl-bot-staging/admin/v1/src/v1/datastore_admin_proto_list.json create mode 100644 owl-bot-staging/admin/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/admin/v1/src/v1/index.ts create mode 100644 owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/admin/v1/system-test/install.ts create mode 100644 owl-bot-staging/admin/v1/test/gapic_datastore_admin_v1.ts create mode 100644 owl-bot-staging/admin/v1/tsconfig.json create mode 100644 owl-bot-staging/admin/v1/webpack.config.js create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/datastore/v1/datastore.proto create mode 100644 owl-bot-staging/v1/protos/google/datastore/v1/entity.proto create mode 100644 owl-bot-staging/v1/protos/google/datastore/v1/query.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.allocate_ids.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.begin_transaction.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.commit.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.lookup.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.reserve_ids.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.rollback.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.run_query.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.datastore.v1.json create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/datastore_client.ts create mode 100644 owl-bot-staging/v1/src/v1/datastore_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/datastore_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_datastore_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js diff --git a/owl-bot-staging/admin/v1/.eslintignore b/owl-bot-staging/admin/v1/.eslintignore new file mode 100644 index 000000000..cfc348ec4 --- /dev/null +++ b/owl-bot-staging/admin/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/admin/v1/.eslintrc.json b/owl-bot-staging/admin/v1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/admin/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/admin/v1/.gitignore b/owl-bot-staging/admin/v1/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/owl-bot-staging/admin/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/admin/v1/.jsdoc.js b/owl-bot-staging/admin/v1/.jsdoc.js new file mode 100644 index 000000000..702ded023 --- /dev/null +++ b/owl-bot-staging/admin/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/datastore-admin', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/admin/v1/.mocharc.js b/owl-bot-staging/admin/v1/.mocharc.js new file mode 100644 index 000000000..481c522b0 --- /dev/null +++ b/owl-bot-staging/admin/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/admin/v1/.prettierrc.js b/owl-bot-staging/admin/v1/.prettierrc.js new file mode 100644 index 000000000..494e14786 --- /dev/null +++ b/owl-bot-staging/admin/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/admin/v1/README.md b/owl-bot-staging/admin/v1/README.md new file mode 100644 index 000000000..5d45b74ed --- /dev/null +++ b/owl-bot-staging/admin/v1/README.md @@ -0,0 +1 @@ +Admin: Nodejs Client diff --git a/owl-bot-staging/admin/v1/linkinator.config.json b/owl-bot-staging/admin/v1/linkinator.config.json new file mode 100644 index 000000000..befd23c86 --- /dev/null +++ b/owl-bot-staging/admin/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/admin/v1/package.json b/owl-bot-staging/admin/v1/package.json new file mode 100644 index 000000000..6d499920d --- /dev/null +++ b/owl-bot-staging/admin/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/datastore-admin", + "version": "0.1.0", + "description": "Admin client for Node.js", + "repository": "googleapis/nodejs-admin", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google admin", + "admin", + "datastore admin" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.1.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/datastore_admin.proto b/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/datastore_admin.proto new file mode 100644 index 000000000..0d624956e --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/datastore_admin.proto @@ -0,0 +1,511 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.datastore.admin.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/datastore/admin/v1/index.proto"; +import "google/datastore/admin/v1/migration.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; +option go_package = "google.golang.org/genproto/googleapis/datastore/admin/v1;admin"; +option java_multiple_files = true; +option java_outer_classname = "DatastoreAdminProto"; +option java_package = "com.google.datastore.admin.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Datastore::Admin::V1"; + +// Google Cloud Datastore Admin API +// +// +// The Datastore Admin API provides several admin services for Cloud Datastore. +// +// ----------------------------------------------------------------------------- +// ## Concepts +// +// Project, namespace, kind, and entity as defined in the Google Cloud Datastore +// API. +// +// Operation: An Operation represents work being performed in the background. +// +// EntityFilter: Allows specifying a subset of entities in a project. This is +// specified as a combination of kinds and namespaces (either or both of which +// may be all). +// +// ----------------------------------------------------------------------------- +// ## Services +// +// # Export/Import +// +// The Export/Import service provides the ability to copy all or a subset of +// entities to/from Google Cloud Storage. +// +// Exported data may be imported into Cloud Datastore for any Google Cloud +// Platform project. It is not restricted to the export source project. It is +// possible to export from one project and then import into another. +// +// Exported data can also be loaded into Google BigQuery for analysis. +// +// Exports and imports are performed asynchronously. An Operation resource is +// created for each export/import. The state (including any errors encountered) +// of the export/import may be queried via the Operation resource. +// +// # Index +// +// The index service manages Cloud Datastore composite indexes. +// +// Index creation and deletion are performed asynchronously. +// An Operation resource is created for each such asynchronous operation. +// The state of the operation (including any errors encountered) +// may be queried via the Operation resource. +// +// # Operation +// +// The Operations collection provides a record of actions performed for the +// specified project (including any operations in progress). Operations are not +// created directly but through calls on other collections or resources. +// +// An operation that is not yet done may be cancelled. The request to cancel is +// asynchronous and the operation may continue to run for some time after the +// request to cancel is made. +// +// An operation that is done may be deleted so that it is no longer listed as +// part of the Operation collection. +// +// ListOperations returns all pending operations, but not completed operations. +// +// Operations are created by service DatastoreAdmin, +// but are accessed via service google.longrunning.Operations. +service DatastoreAdmin { + 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"; + + // Exports a copy of all or a subset of entities from Google Cloud Datastore + // to another storage system, such as Google Cloud Storage. Recent updates to + // entities may not be reflected in the export. The export occurs in the + // background and its progress can be monitored and managed via the + // Operation resource that is created. The output of an export may only be + // used once the associated operation is done. If an export operation is + // cancelled before completion it may leave partial data behind in Google + // Cloud Storage. + rpc ExportEntities(ExportEntitiesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:export" + body: "*" + }; + option (google.api.method_signature) = "project_id,labels,entity_filter,output_url_prefix"; + option (google.longrunning.operation_info) = { + response_type: "ExportEntitiesResponse" + metadata_type: "ExportEntitiesMetadata" + }; + } + + // Imports entities into Google Cloud Datastore. Existing entities with the + // same key are overwritten. The import occurs in the background and its + // progress can be monitored and managed via the Operation resource that is + // created. If an ImportEntities operation is cancelled, it is possible + // that a subset of the data has already been imported to Cloud Datastore. + rpc ImportEntities(ImportEntitiesRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:import" + body: "*" + }; + option (google.api.method_signature) = "project_id,labels,input_url,entity_filter"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "ImportEntitiesMetadata" + }; + } + + // Creates the specified index. + // A newly created index's initial state is `CREATING`. On completion of the + // returned [google.longrunning.Operation][google.longrunning.Operation], the state will be `READY`. + // If the index already exists, the call will return an `ALREADY_EXISTS` + // status. + // + // During index creation, the process could result in an error, in which + // case the index will move to the `ERROR` state. The process can be recovered + // by fixing the data that caused the error, removing the index with + // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then + // re-creating the index with [create] + // [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + // + // Indexes with a single property cannot be created. + rpc CreateIndex(CreateIndexRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/projects/{project_id}/indexes" + body: "index" + }; + option (google.longrunning.operation_info) = { + response_type: "Index" + metadata_type: "IndexOperationMetadata" + }; + } + + // Deletes an existing index. + // An index can only be deleted if it is in a `READY` or `ERROR` state. On + // successful execution of the request, the index will be in a `DELETING` + // [state][google.datastore.admin.v1.Index.State]. And on completion of the + // returned [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. + // + // During index deletion, the process could result in an error, in which + // case the index will move to the `ERROR` state. The process can be recovered + // by fixing the data that caused the error, followed by calling + // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again. + rpc DeleteIndex(DeleteIndexRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/projects/{project_id}/indexes/{index_id}" + }; + option (google.longrunning.operation_info) = { + response_type: "Index" + metadata_type: "IndexOperationMetadata" + }; + } + + // Gets an index. + rpc GetIndex(GetIndexRequest) returns (Index) { + option (google.api.http) = { + get: "/v1/projects/{project_id}/indexes/{index_id}" + }; + } + + // Lists the indexes that match the specified filters. Datastore uses an + // eventually consistent query to fetch the list of indexes and may + // occasionally return stale results. + rpc ListIndexes(ListIndexesRequest) returns (ListIndexesResponse) { + option (google.api.http) = { + get: "/v1/projects/{project_id}/indexes" + }; + } +} + +// Metadata common to all Datastore Admin operations. +message CommonMetadata { + // The various possible states for an ongoing Operation. + enum State { + // Unspecified. + STATE_UNSPECIFIED = 0; + + // Request is being prepared for processing. + INITIALIZING = 1; + + // Request is actively being processed. + PROCESSING = 2; + + // Request is in the process of being cancelled after user called + // google.longrunning.Operations.CancelOperation on the operation. + CANCELLING = 3; + + // Request has been processed and is in its finalization stage. + FINALIZING = 4; + + // Request has completed successfully. + SUCCESSFUL = 5; + + // Request has finished being processed, but encountered an error. + FAILED = 6; + + // Request has finished being cancelled after user called + // google.longrunning.Operations.CancelOperation. + CANCELLED = 7; + } + + // The time that work began on the operation. + google.protobuf.Timestamp start_time = 1; + + // The time the operation ended, either successfully or otherwise. + google.protobuf.Timestamp end_time = 2; + + // The type of the operation. Can be used as a filter in + // ListOperationsRequest. + OperationType operation_type = 3; + + // The client-assigned labels which were provided when the operation was + // created. May also include additional labels. + map labels = 4; + + // The current state of the Operation. + State state = 5; +} + +// Measures the progress of a particular metric. +message Progress { + // The amount of work that has been completed. Note that this may be greater + // than work_estimated. + int64 work_completed = 1; + + // An estimate of how much work needs to be performed. May be zero if the + // work estimate is unavailable. + int64 work_estimated = 2; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. +message ExportEntitiesRequest { + // Required. Project ID against which to make the request. + string project_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Client-assigned labels. + map labels = 2; + + // Description of what data from the project is included in the export. + EntityFilter entity_filter = 3; + + // Required. Location for the export metadata and data files. + // + // The full resource URL of the external storage location. Currently, only + // Google Cloud Storage is supported. So output_url_prefix should be of the + // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the + // name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud + // Storage namespace path (this is not a Cloud Datastore namespace). For more + // information about Cloud Storage namespace paths, see + // [Object name + // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + // + // The resulting files will be nested deeper than the specified URL prefix. + // The final output URL will be provided in the + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] field. That + // value should be used for subsequent ImportEntities operations. + // + // By nesting the data files deeper, the same Cloud Storage bucket can be used + // in multiple ExportEntities operations without conflict. + string output_url_prefix = 4 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.ImportEntities][google.datastore.admin.v1.DatastoreAdmin.ImportEntities]. +message ImportEntitiesRequest { + // Required. Project ID against which to make the request. + string project_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Client-assigned labels. + map labels = 2; + + // Required. The full resource URL of the external storage location. Currently, only + // Google Cloud Storage is supported. So input_url should be of the form: + // `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where + // `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is + // an optional Cloud Storage namespace path (this is not a Cloud Datastore + // namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written + // by the ExportEntities operation. For more information about Cloud Storage + // namespace paths, see + // [Object name + // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + // + // For more information, see + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. + string input_url = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optionally specify which kinds/namespaces are to be imported. If provided, + // the list must be a subset of the EntityFilter used in creating the export, + // otherwise a FAILED_PRECONDITION error will be returned. If no filter is + // specified then all entities from the export are imported. + EntityFilter entity_filter = 4; +} + +// The response for +// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. +message ExportEntitiesResponse { + // Location of the output metadata file. This can be used to begin an import + // into Cloud Datastore (this project or another project). See + // [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url]. + // Only present if the operation completed successfully. + string output_url = 1; +} + +// Metadata for ExportEntities operations. +message ExportEntitiesMetadata { + // Metadata common to all Datastore Admin operations. + CommonMetadata common = 1; + + // An estimate of the number of entities processed. + Progress progress_entities = 2; + + // An estimate of the number of bytes processed. + Progress progress_bytes = 3; + + // Description of which entities are being exported. + EntityFilter entity_filter = 4; + + // Location for the export metadata and data files. This will be the same + // value as the + // [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix] + // field. The final output location is provided in + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. + string output_url_prefix = 5; +} + +// Metadata for ImportEntities operations. +message ImportEntitiesMetadata { + // Metadata common to all Datastore Admin operations. + CommonMetadata common = 1; + + // An estimate of the number of entities processed. + Progress progress_entities = 2; + + // An estimate of the number of bytes processed. + Progress progress_bytes = 3; + + // Description of which entities are being imported. + EntityFilter entity_filter = 4; + + // The location of the import metadata file. This will be the same value as + // the [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] field. + string input_url = 5; +} + +// Identifies a subset of entities in a project. This is specified as +// combinations of kinds and namespaces (either or both of which may be all, as +// described in the following examples). +// Example usage: +// +// Entire project: +// kinds=[], namespace_ids=[] +// +// Kinds Foo and Bar in all namespaces: +// kinds=['Foo', 'Bar'], namespace_ids=[] +// +// Kinds Foo and Bar only in the default namespace: +// kinds=['Foo', 'Bar'], namespace_ids=[''] +// +// Kinds Foo and Bar in both the default and Baz namespaces: +// kinds=['Foo', 'Bar'], namespace_ids=['', 'Baz'] +// +// The entire Baz namespace: +// kinds=[], namespace_ids=['Baz'] +message EntityFilter { + // If empty, then this represents all kinds. + repeated string kinds = 1; + + // An empty list represents all namespaces. This is the preferred + // usage for projects that don't use namespaces. + // + // An empty string element represents the default namespace. This should be + // used if the project has data in non-default namespaces, but doesn't want to + // include them. + // Each namespace in this list must be unique. + repeated string namespace_ids = 2; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.CreateIndex][google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. +message CreateIndexRequest { + // Project ID against which to make the request. + string project_id = 1; + + // The index to create. The name and state fields are output only and will be + // ignored. Single property indexes cannot be created or deleted. + Index index = 3; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.DeleteIndex][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex]. +message DeleteIndexRequest { + // Project ID against which to make the request. + string project_id = 1; + + // The resource ID of the index to delete. + string index_id = 3; +} + +// The request for [google.datastore.admin.v1.DatastoreAdmin.GetIndex][google.datastore.admin.v1.DatastoreAdmin.GetIndex]. +message GetIndexRequest { + // Project ID against which to make the request. + string project_id = 1; + + // The resource ID of the index to get. + string index_id = 3; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. +message ListIndexesRequest { + // Project ID against which to make the request. + string project_id = 1; + + string filter = 3; + + // The maximum number of items to return. If zero, then all results will be + // returned. + int32 page_size = 4; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 5; +} + +// The response for +// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. +message ListIndexesResponse { + // The indexes. + repeated Index indexes = 1; + + // The standard List next-page token. + string next_page_token = 2; +} + +// Metadata for Index operations. +message IndexOperationMetadata { + // Metadata common to all Datastore Admin operations. + CommonMetadata common = 1; + + // An estimate of the number of entities processed. + Progress progress_entities = 2; + + // The index resource ID that this operation is acting on. + string index_id = 3; +} + +// Metadata for Datastore to Firestore migration operations. +// +// The DatastoreFirestoreMigration operation is not started by the end-user via +// an explicit "creation" method. This is an intentional deviation from the LRO +// design pattern. +// +// This singleton resource can be accessed at: +// "projects/{project_id}/operations/datastore-firestore-migration" +message DatastoreFirestoreMigrationMetadata { + // The current state of migration from Cloud Datastore to Cloud Firestore in + // Datastore mode. + MigrationState migration_state = 1; + + // The current step of migration from Cloud Datastore to Cloud Firestore in + // Datastore mode. + MigrationStep migration_step = 2; +} + +// Operation types. +enum OperationType { + // Unspecified. + OPERATION_TYPE_UNSPECIFIED = 0; + + // ExportEntities. + EXPORT_ENTITIES = 1; + + // ImportEntities. + IMPORT_ENTITIES = 2; + + // CreateIndex. + CREATE_INDEX = 3; + + // DeleteIndex. + DELETE_INDEX = 4; +} diff --git a/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/index.proto b/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/index.proto new file mode 100644 index 000000000..0162af523 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/index.proto @@ -0,0 +1,115 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.datastore.admin.v1; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; +option go_package = "google.golang.org/genproto/googleapis/datastore/admin/v1;admin"; +option java_multiple_files = true; +option java_outer_classname = "IndexProto"; +option java_package = "com.google.datastore.admin.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Datastore::Admin::V1"; + +// Datastore composite index definition. +message Index { + // For an ordered index, specifies whether each of the entity's ancestors + // will be included. + enum AncestorMode { + // The ancestor mode is unspecified. + ANCESTOR_MODE_UNSPECIFIED = 0; + + // Do not include the entity's ancestors in the index. + NONE = 1; + + // Include all the entity's ancestors in the index. + ALL_ANCESTORS = 2; + } + + // The direction determines how a property is indexed. + enum Direction { + // The direction is unspecified. + DIRECTION_UNSPECIFIED = 0; + + // The property's values are indexed so as to support sequencing in + // ascending order and also query by <, >, <=, >=, and =. + ASCENDING = 1; + + // The property's values are indexed so as to support sequencing in + // descending order and also query by <, >, <=, >=, and =. + DESCENDING = 2; + } + + // A property of an index. + message IndexedProperty { + // Required. The property name to index. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The indexed property's direction. Must not be DIRECTION_UNSPECIFIED. + Direction direction = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // The possible set of states of an index. + enum State { + // The state is unspecified. + STATE_UNSPECIFIED = 0; + + // The index is being created, and cannot be used by queries. + // There is an active long-running operation for the index. + // The index is updated when writing an entity. + // Some index data may exist. + CREATING = 1; + + // The index is ready to be used. + // The index is updated when writing an entity. + // The index is fully populated from all stored entities it applies to. + READY = 2; + + // The index is being deleted, and cannot be used by queries. + // There is an active long-running operation for the index. + // The index is not updated when writing an entity. + // Some index data may exist. + DELETING = 3; + + // The index was being created or deleted, but something went wrong. + // The index cannot by used by queries. + // There is no active long-running operation for the index, + // and the most recently finished long-running operation failed. + // The index is not updated when writing an entity. + // Some index data may exist. + ERROR = 4; + } + + // Output only. Project ID. + string project_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The resource ID of the index. + string index_id = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The entity kind to which this index applies. + string kind = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. The index's ancestor mode. Must not be ANCESTOR_MODE_UNSPECIFIED. + AncestorMode ancestor = 5 [(google.api.field_behavior) = REQUIRED]; + + // Required. An ordered sequence of property names and their index attributes. + repeated IndexedProperty properties = 6 [(google.api.field_behavior) = REQUIRED]; + + // Output only. The state of the index. + State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/migration.proto b/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/migration.proto new file mode 100644 index 000000000..dbbe473c9 --- /dev/null +++ b/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/migration.proto @@ -0,0 +1,124 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.datastore.admin.v1; + +option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; +option go_package = "google.golang.org/genproto/googleapis/datastore/admin/v1;admin"; +option java_multiple_files = true; +option java_outer_classname = "MigrationProto"; +option java_package = "com.google.datastore.admin.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Datastore::Admin::V1"; + +// An event signifying a change in state of a [migration from Cloud Datastore to +// Cloud Firestore in Datastore +// mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore). +message MigrationStateEvent { + // The new state of the migration. + MigrationState state = 1; +} + +// An event signifying the start of a new step in a [migration from Cloud +// Datastore to Cloud Firestore in Datastore +// mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore). +message MigrationProgressEvent { + // Concurrency modes for transactions in Cloud Firestore. + enum ConcurrencyMode { + // Unspecified. + CONCURRENCY_MODE_UNSPECIFIED = 0; + + // Pessimistic concurrency. + PESSIMISTIC = 1; + + // Optimistic concurrency. + OPTIMISTIC = 2; + + // Optimistic concurrency with entity groups. + OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + } + + // Details for the `PREPARE` step. + message PrepareStepDetails { + // The concurrency mode this database will use when it reaches the + // `REDIRECT_WRITES` step. + ConcurrencyMode concurrency_mode = 1; + } + + // Details for the `REDIRECT_WRITES` step. + message RedirectWritesStepDetails { + // Ths concurrency mode for this database. + ConcurrencyMode concurrency_mode = 1; + } + + // The step that is starting. + // + // An event with step set to `START` indicates that the migration + // has been reverted back to the initial pre-migration state. + MigrationStep step = 1; + + // Details about this step. + oneof step_details { + // Details for the `PREPARE` step. + PrepareStepDetails prepare_step_details = 2; + + // Details for the `REDIRECT_WRITES` step. + RedirectWritesStepDetails redirect_writes_step_details = 3; + } +} + +// States for a migration. +enum MigrationState { + // Unspecified. + MIGRATION_STATE_UNSPECIFIED = 0; + + // The migration is running. + RUNNING = 1; + + // The migration is paused. + PAUSED = 2; + + // The migration is complete. + COMPLETE = 3; +} + +// Steps in a migration. +enum MigrationStep { + // Unspecified. + MIGRATION_STEP_UNSPECIFIED = 0; + + // Pre-migration: the database is prepared for migration. + PREPARE = 6; + + // Start of migration. + START = 1; + + // Writes are applied synchronously to at least one replica. + APPLY_WRITES_SYNCHRONOUSLY = 7; + + // Data is copied to Cloud Firestore and then verified to match the data in + // Cloud Datastore. + COPY_AND_VERIFY = 2; + + // Eventually-consistent reads are redirected to Cloud Firestore. + REDIRECT_EVENTUALLY_CONSISTENT_READS = 3; + + // Strongly-consistent reads are redirected to Cloud Firestore. + REDIRECT_STRONGLY_CONSISTENT_READS = 4; + + // Writes are redirected to Cloud Firestore. + REDIRECT_WRITES = 5; +} diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.create_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.create_index.js new file mode 100644 index 000000000..25a4e7008 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.create_index.js @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START datastore_v1_generated_DatastoreAdmin_CreateIndex_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * The index to create. The name and state fields are output only and will be + * ignored. Single property indexes cannot be created or deleted. + */ + // const index = {} + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callCreateIndex() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await adminClient.createIndex(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateIndex(); + // [END datastore_v1_generated_DatastoreAdmin_CreateIndex_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.delete_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.delete_index.js new file mode 100644 index 000000000..ada02df71 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.delete_index.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START datastore_v1_generated_DatastoreAdmin_DeleteIndex_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * The resource ID of the index to delete. + */ + // const indexId = 'abc123' + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callDeleteIndex() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await adminClient.deleteIndex(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteIndex(); + // [END datastore_v1_generated_DatastoreAdmin_DeleteIndex_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.export_entities.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.export_entities.js new file mode 100644 index 000000000..81b946e65 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.export_entities.js @@ -0,0 +1,86 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, outputUrlPrefix) { + // [START datastore_v1_generated_DatastoreAdmin_ExportEntities_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * Client-assigned labels. + */ + // const labels = 1234 + /** + * Description of what data from the project is included in the export. + */ + // const entityFilter = {} + /** + * Required. Location for the export metadata and data files. + * The full resource URL of the external storage location. Currently, only + * Google Cloud Storage is supported. So output_url_prefix should be of the + * form: `gs://BUCKET_NAME/NAMESPACE_PATH`, where `BUCKET_NAME` is the + * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud + * Storage namespace path (this is not a Cloud Datastore namespace). For more + * information about Cloud Storage namespace paths, see + * Object name + * considerations (https://cloud.google.com/storage/docs/naming#object-considerations). + * The resulting files will be nested deeper than the specified URL prefix. + * The final output URL will be provided in the + * google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url field. That + * value should be used for subsequent ImportEntities operations. + * By nesting the data files deeper, the same Cloud Storage bucket can be used + * in multiple ExportEntities operations without conflict. + */ + // const outputUrlPrefix = 'abc123' + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callExportEntities() { + // Construct request + const request = { + projectId, + outputUrlPrefix, + }; + + // Run request + const [operation] = await adminClient.exportEntities(request); + const [response] = await operation.promise(); + console.log(response); + } + + callExportEntities(); + // [END datastore_v1_generated_DatastoreAdmin_ExportEntities_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.get_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.get_index.js new file mode 100644 index 000000000..ae88c96af --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.get_index.js @@ -0,0 +1,61 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START datastore_v1_generated_DatastoreAdmin_GetIndex_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * The resource ID of the index to get. + */ + // const indexId = 'abc123' + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callGetIndex() { + // Construct request + const request = { + }; + + // Run request + const response = await adminClient.getIndex(request); + console.log(response); + } + + callGetIndex(); + // [END datastore_v1_generated_DatastoreAdmin_GetIndex_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.import_entities.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.import_entities.js new file mode 100644 index 000000000..d2d3e53f9 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.import_entities.js @@ -0,0 +1,86 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, inputUrl) { + // [START datastore_v1_generated_DatastoreAdmin_ImportEntities_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * Client-assigned labels. + */ + // const labels = 1234 + /** + * Required. The full resource URL of the external storage location. Currently, only + * Google Cloud Storage is supported. So input_url should be of the form: + * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where + * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is + * an optional Cloud Storage namespace path (this is not a Cloud Datastore + * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written + * by the ExportEntities operation. For more information about Cloud Storage + * namespace paths, see + * Object name + * considerations (https://cloud.google.com/storage/docs/naming#object-considerations). + * For more information, see + * google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url. + */ + // const inputUrl = 'abc123' + /** + * Optionally specify which kinds/namespaces are to be imported. If provided, + * the list must be a subset of the EntityFilter used in creating the export, + * otherwise a FAILED_PRECONDITION error will be returned. If no filter is + * specified then all entities from the export are imported. + */ + // const entityFilter = {} + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callImportEntities() { + // Construct request + const request = { + projectId, + inputUrl, + }; + + // Run request + const [operation] = await adminClient.importEntities(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportEntities(); + // [END datastore_v1_generated_DatastoreAdmin_ImportEntities_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.list_indexes.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.list_indexes.js new file mode 100644 index 000000000..e47f17381 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.list_indexes.js @@ -0,0 +1,71 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START datastore_v1_generated_DatastoreAdmin_ListIndexes_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + */ + // const filter = 'abc123' + /** + * The maximum number of items to return. If zero, then all results will be + * returned. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callListIndexes() { + // Construct request + const request = { + }; + + // Run request + const iterable = await adminClient.listIndexesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListIndexes(); + // [END datastore_v1_generated_DatastoreAdmin_ListIndexes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json b/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json new file mode 100644 index 000000000..e2bbccc60 --- /dev/null +++ b/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json @@ -0,0 +1,303 @@ +{ + "clientLibrary": { + "name": "nodejs-admin", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.datastore.admin.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_ExportEntities_async", + "title": "DatastoreAdmin exportEntities Sample", + "origin": "API_DEFINITION", + "description": " Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage. Recent updates to entities may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage.", + "canonical": true, + "file": "datastore_admin.export_entities.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ExportEntities", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "entity_filter", + "type": ".google.datastore.admin.v1.EntityFilter" + }, + { + "name": "output_url_prefix", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "ExportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ExportEntities", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_ImportEntities_async", + "title": "DatastoreAdmin importEntities Sample", + "origin": "API_DEFINITION", + "description": " Imports entities into Google Cloud Datastore. Existing entities with the same key are overwritten. The import occurs in the background and its progress can be monitored and managed via the Operation resource that is created. If an ImportEntities operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Datastore.", + "canonical": true, + "file": "datastore_admin.import_entities.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ImportEntities", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "input_url", + "type": "TYPE_STRING" + }, + { + "name": "entity_filter", + "type": ".google.datastore.admin.v1.EntityFilter" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "ImportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ImportEntities", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_CreateIndex_async", + "title": "DatastoreAdmin createIndex Sample", + "origin": "API_DEFINITION", + "description": " Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. During index creation, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. Indexes with a single property cannot be created.", + "canonical": true, + "file": "datastore_admin.create_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.CreateIndex", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "index", + "type": ".google.datastore.admin.v1.Index" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "CreateIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.CreateIndex", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_DeleteIndex_async", + "title": "DatastoreAdmin deleteIndex Sample", + "origin": "API_DEFINITION", + "description": " Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. On successful execution of the request, the index will be in a `DELETING` [state][google.datastore.admin.v1.Index.State]. And on completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. During index deletion, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.", + "canonical": true, + "file": "datastore_admin.delete_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.DeleteIndex", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "index_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "DeleteIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.DeleteIndex", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_GetIndex_async", + "title": "DatastoreAdmin getIndex Sample", + "origin": "API_DEFINITION", + "description": " Gets an index.", + "canonical": true, + "file": "datastore_admin.get_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.GetIndex", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "index_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.datastore.admin.v1.Index", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "GetIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.GetIndex", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_ListIndexes_async", + "title": "DatastoreAdmin listIndexes Sample", + "origin": "API_DEFINITION", + "description": " Lists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.", + "canonical": true, + "file": "datastore_admin.list_indexes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListIndexes", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ListIndexes", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.datastore.admin.v1.ListIndexesResponse", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "ListIndexes", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ListIndexes", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + } + ] +} diff --git a/owl-bot-staging/admin/v1/src/index.ts b/owl-bot-staging/admin/v1/src/index.ts new file mode 100644 index 000000000..85a09fe29 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const DatastoreAdminClient = v1.DatastoreAdminClient; +type DatastoreAdminClient = v1.DatastoreAdminClient; +export {v1, DatastoreAdminClient}; +export default {v1, DatastoreAdminClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/admin/v1/src/v1/datastore_admin_client.ts b/owl-bot-staging/admin/v1/src/v1/datastore_admin_client.ts new file mode 100644 index 000000000..5e82ab3fb --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/datastore_admin_client.ts @@ -0,0 +1,1295 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/datastore_admin_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './datastore_admin_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Google Cloud Datastore Admin API + * + * + * The Datastore Admin API provides several admin services for Cloud Datastore. + * + * ----------------------------------------------------------------------------- + * ## Concepts + * + * Project, namespace, kind, and entity as defined in the Google Cloud Datastore + * API. + * + * Operation: An Operation represents work being performed in the background. + * + * EntityFilter: Allows specifying a subset of entities in a project. This is + * specified as a combination of kinds and namespaces (either or both of which + * may be all). + * + * ----------------------------------------------------------------------------- + * ## Services + * + * # Export/Import + * + * The Export/Import service provides the ability to copy all or a subset of + * entities to/from Google Cloud Storage. + * + * Exported data may be imported into Cloud Datastore for any Google Cloud + * Platform project. It is not restricted to the export source project. It is + * possible to export from one project and then import into another. + * + * Exported data can also be loaded into Google BigQuery for analysis. + * + * Exports and imports are performed asynchronously. An Operation resource is + * created for each export/import. The state (including any errors encountered) + * of the export/import may be queried via the Operation resource. + * + * # Index + * + * The index service manages Cloud Datastore composite indexes. + * + * Index creation and deletion are performed asynchronously. + * An Operation resource is created for each such asynchronous operation. + * The state of the operation (including any errors encountered) + * may be queried via the Operation resource. + * + * # Operation + * + * The Operations collection provides a record of actions performed for the + * specified project (including any operations in progress). Operations are not + * created directly but through calls on other collections or resources. + * + * An operation that is not yet done may be cancelled. The request to cancel is + * asynchronous and the operation may continue to run for some time after the + * request to cancel is made. + * + * An operation that is done may be deleted so that it is no longer listed as + * part of the Operation collection. + * + * ListOperations returns all pending operations, but not completed operations. + * + * Operations are created by service DatastoreAdmin, + * but are accessed via service google.longrunning.Operations. + * @class + * @memberof v1 + */ +export class DatastoreAdminClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + operationsClient: gax.OperationsClient; + datastoreAdminStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DatastoreAdminClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DatastoreAdminClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listIndexes: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'indexes') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{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',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const exportEntitiesResponse = protoFilesRoot.lookup( + '.google.datastore.admin.v1.ExportEntitiesResponse') as gax.protobuf.Type; + const exportEntitiesMetadata = protoFilesRoot.lookup( + '.google.datastore.admin.v1.ExportEntitiesMetadata') as gax.protobuf.Type; + const importEntitiesResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const importEntitiesMetadata = protoFilesRoot.lookup( + '.google.datastore.admin.v1.ImportEntitiesMetadata') as gax.protobuf.Type; + const createIndexResponse = protoFilesRoot.lookup( + '.google.datastore.admin.v1.Index') as gax.protobuf.Type; + const createIndexMetadata = protoFilesRoot.lookup( + '.google.datastore.admin.v1.IndexOperationMetadata') as gax.protobuf.Type; + const deleteIndexResponse = protoFilesRoot.lookup( + '.google.datastore.admin.v1.Index') as gax.protobuf.Type; + const deleteIndexMetadata = protoFilesRoot.lookup( + '.google.datastore.admin.v1.IndexOperationMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + exportEntities: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + exportEntitiesResponse.decode.bind(exportEntitiesResponse), + exportEntitiesMetadata.decode.bind(exportEntitiesMetadata)), + importEntities: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importEntitiesResponse.decode.bind(importEntitiesResponse), + importEntitiesMetadata.decode.bind(importEntitiesMetadata)), + createIndex: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createIndexResponse.decode.bind(createIndexResponse), + createIndexMetadata.decode.bind(createIndexMetadata)), + deleteIndex: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteIndexResponse.decode.bind(deleteIndexResponse), + deleteIndexMetadata.decode.bind(deleteIndexMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.datastore.admin.v1.DatastoreAdmin', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.datastoreAdminStub) { + return this.datastoreAdminStub; + } + + // Put together the "service stub" for + // google.datastore.admin.v1.DatastoreAdmin. + this.datastoreAdminStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.datastore.admin.v1.DatastoreAdmin') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.datastore.admin.v1.DatastoreAdmin, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const datastoreAdminStubMethods = + ['exportEntities', 'importEntities', 'createIndex', 'deleteIndex', 'getIndex', 'listIndexes']; + for (const methodName of datastoreAdminStubMethods) { + const callPromise = this.datastoreAdminStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.datastoreAdminStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'datastore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'datastore.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Gets an index. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {string} request.indexId + * The resource ID of the index to get. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Index]{@link google.datastore.admin.v1.Index}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.get_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_GetIndex_async + */ + getIndex( + request?: protos.google.datastore.admin.v1.IGetIndexRequest, + options?: CallOptions): + Promise<[ + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest|undefined, {}|undefined + ]>; + getIndex( + request: protos.google.datastore.admin.v1.IGetIndexRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest|null|undefined, + {}|null|undefined>): void; + getIndex( + request: protos.google.datastore.admin.v1.IGetIndexRequest, + callback: Callback< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest|null|undefined, + {}|null|undefined>): void; + getIndex( + request?: protos.google.datastore.admin.v1.IGetIndexRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + 'index_id': request.indexId || '', + }); + this.initialize(); + return this.innerApiCalls.getIndex(request, options, callback); + } + +/** + * Exports a copy of all or a subset of entities from Google Cloud Datastore + * to another storage system, such as Google Cloud Storage. Recent updates to + * entities may not be reflected in the export. The export occurs in the + * background and its progress can be monitored and managed via the + * Operation resource that is created. The output of an export may only be + * used once the associated operation is done. If an export operation is + * cancelled before completion it may leave partial data behind in Google + * Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. Project ID against which to make the request. + * @param {number[]} request.labels + * Client-assigned labels. + * @param {google.datastore.admin.v1.EntityFilter} request.entityFilter + * Description of what data from the project is included in the export. + * @param {string} request.outputUrlPrefix + * Required. Location for the export metadata and data files. + * + * The full resource URL of the external storage location. Currently, only + * Google Cloud Storage is supported. So output_url_prefix should be of the + * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the + * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud + * Storage namespace path (this is not a Cloud Datastore namespace). For more + * information about Cloud Storage namespace paths, see + * [Object name + * considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + * + * The resulting files will be nested deeper than the specified URL prefix. + * The final output URL will be provided in the + * {@link google.datastore.admin.v1.ExportEntitiesResponse.output_url|google.datastore.admin.v1.ExportEntitiesResponse.output_url} field. That + * value should be used for subsequent ImportEntities operations. + * + * By nesting the data files deeper, the same Cloud Storage bucket can be used + * in multiple ExportEntities operations without conflict. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.export_entities.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ExportEntities_async + */ + exportEntities( + request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + exportEntities( + request: protos.google.datastore.admin.v1.IExportEntitiesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + exportEntities( + request: protos.google.datastore.admin.v1.IExportEntitiesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + exportEntities( + request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.exportEntities(request, options, callback); + } +/** + * Check the status of the long running operation returned by `exportEntities()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.export_entities.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ExportEntities_async + */ + async checkExportEntitiesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.exportEntities, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Imports entities into Google Cloud Datastore. Existing entities with the + * same key are overwritten. The import occurs in the background and its + * progress can be monitored and managed via the Operation resource that is + * created. If an ImportEntities operation is cancelled, it is possible + * that a subset of the data has already been imported to Cloud Datastore. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. Project ID against which to make the request. + * @param {number[]} request.labels + * Client-assigned labels. + * @param {string} request.inputUrl + * Required. The full resource URL of the external storage location. Currently, only + * Google Cloud Storage is supported. So input_url should be of the form: + * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where + * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is + * an optional Cloud Storage namespace path (this is not a Cloud Datastore + * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written + * by the ExportEntities operation. For more information about Cloud Storage + * namespace paths, see + * [Object name + * considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + * + * For more information, see + * {@link google.datastore.admin.v1.ExportEntitiesResponse.output_url|google.datastore.admin.v1.ExportEntitiesResponse.output_url}. + * @param {google.datastore.admin.v1.EntityFilter} request.entityFilter + * Optionally specify which kinds/namespaces are to be imported. If provided, + * the list must be a subset of the EntityFilter used in creating the export, + * otherwise a FAILED_PRECONDITION error will be returned. If no filter is + * specified then all entities from the export are imported. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.import_entities.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ImportEntities_async + */ + importEntities( + request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + importEntities( + request: protos.google.datastore.admin.v1.IImportEntitiesRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importEntities( + request: protos.google.datastore.admin.v1.IImportEntitiesRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + importEntities( + request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.importEntities(request, options, callback); + } +/** + * Check the status of the long running operation returned by `importEntities()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.import_entities.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ImportEntities_async + */ + async checkImportEntitiesProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importEntities, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Creates the specified index. + * A newly created index's initial state is `CREATING`. On completion of the + * returned {@link google.longrunning.Operation|google.longrunning.Operation}, the state will be `READY`. + * If the index already exists, the call will return an `ALREADY_EXISTS` + * status. + * + * During index creation, the process could result in an error, in which + * case the index will move to the `ERROR` state. The process can be recovered + * by fixing the data that caused the error, removing the index with + * {@link google.datastore.admin.v1.DatastoreAdmin.DeleteIndex|delete}, then + * re-creating the index with [create] + * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + * + * Indexes with a single property cannot be created. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {google.datastore.admin.v1.Index} request.index + * The index to create. The name and state fields are output only and will be + * ignored. Single property indexes cannot be created or deleted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.create_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_CreateIndex_async + */ + createIndex( + request?: protos.google.datastore.admin.v1.ICreateIndexRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createIndex( + request: protos.google.datastore.admin.v1.ICreateIndexRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createIndex( + request: protos.google.datastore.admin.v1.ICreateIndexRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createIndex( + request?: protos.google.datastore.admin.v1.ICreateIndexRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.createIndex(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createIndex()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.create_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_CreateIndex_async + */ + async checkCreateIndexProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createIndex, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes an existing index. + * An index can only be deleted if it is in a `READY` or `ERROR` state. On + * successful execution of the request, the index will be in a `DELETING` + * {@link google.datastore.admin.v1.Index.State|state}. And on completion of the + * returned {@link google.longrunning.Operation|google.longrunning.Operation}, the index will be removed. + * + * During index deletion, the process could result in an error, in which + * case the index will move to the `ERROR` state. The process can be recovered + * by fixing the data that caused the error, followed by calling + * {@link google.datastore.admin.v1.DatastoreAdmin.DeleteIndex|delete} again. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {string} request.indexId + * The resource ID of the index to delete. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.delete_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_DeleteIndex_async + */ + deleteIndex( + request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteIndex( + request: protos.google.datastore.admin.v1.IDeleteIndexRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteIndex( + request: protos.google.datastore.admin.v1.IDeleteIndexRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteIndex( + request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + 'index_id': request.indexId || '', + }); + this.initialize(); + return this.innerApiCalls.deleteIndex(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteIndex()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.delete_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_DeleteIndex_async + */ + async checkDeleteIndexProgress(name: string): Promise>{ + const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.deleteIndex, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists the indexes that match the specified filters. Datastore uses an + * eventually consistent query to fetch the list of indexes and may + * occasionally return stale results. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {string} request.filter + * @param {number} request.pageSize + * The maximum number of items to return. If zero, then all results will be + * returned. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Index]{@link google.datastore.admin.v1.Index}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listIndexesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listIndexes( + request?: protos.google.datastore.admin.v1.IListIndexesRequest, + options?: CallOptions): + Promise<[ + protos.google.datastore.admin.v1.IIndex[], + protos.google.datastore.admin.v1.IListIndexesRequest|null, + protos.google.datastore.admin.v1.IListIndexesResponse + ]>; + listIndexes( + request: protos.google.datastore.admin.v1.IListIndexesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.datastore.admin.v1.IListIndexesRequest, + protos.google.datastore.admin.v1.IListIndexesResponse|null|undefined, + protos.google.datastore.admin.v1.IIndex>): void; + listIndexes( + request: protos.google.datastore.admin.v1.IListIndexesRequest, + callback: PaginationCallback< + protos.google.datastore.admin.v1.IListIndexesRequest, + protos.google.datastore.admin.v1.IListIndexesResponse|null|undefined, + protos.google.datastore.admin.v1.IIndex>): void; + listIndexes( + request?: protos.google.datastore.admin.v1.IListIndexesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.datastore.admin.v1.IListIndexesRequest, + protos.google.datastore.admin.v1.IListIndexesResponse|null|undefined, + protos.google.datastore.admin.v1.IIndex>, + callback?: PaginationCallback< + protos.google.datastore.admin.v1.IListIndexesRequest, + protos.google.datastore.admin.v1.IListIndexesResponse|null|undefined, + protos.google.datastore.admin.v1.IIndex>): + Promise<[ + protos.google.datastore.admin.v1.IIndex[], + protos.google.datastore.admin.v1.IListIndexesRequest|null, + protos.google.datastore.admin.v1.IListIndexesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.listIndexes(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {string} request.filter + * @param {number} request.pageSize + * The maximum number of items to return. If zero, then all results will be + * returned. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Index]{@link google.datastore.admin.v1.Index} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listIndexesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listIndexesStream( + request?: protos.google.datastore.admin.v1.IListIndexesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + const defaultCallSettings = this._defaults['listIndexes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listIndexes.createStream( + this.innerApiCalls.listIndexes as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listIndexes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {string} request.filter + * @param {number} request.pageSize + * The maximum number of items to return. If zero, then all results will be + * returned. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Index]{@link google.datastore.admin.v1.Index}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/datastore_admin.list_indexes.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ListIndexes_async + */ + listIndexesAsync( + request?: protos.google.datastore.admin.v1.IListIndexesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + const defaultCallSettings = this._defaults['listIndexes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listIndexes.asyncIterate( + this.innerApiCalls['listIndexes'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.datastoreAdminStub && !this._terminated) { + return this.datastoreAdminStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/admin/v1/src/v1/datastore_admin_client_config.json b/owl-bot-staging/admin/v1/src/v1/datastore_admin_client_config.json new file mode 100644 index 000000000..9dbc3f5ff --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/datastore_admin_client_config.json @@ -0,0 +1,56 @@ +{ + "interfaces": { + "google.datastore.admin.v1.DatastoreAdmin": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "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": { + "ExportEntities": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ImportEntities": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateIndex": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteIndex": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIndex": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListIndexes": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/admin/v1/src/v1/datastore_admin_proto_list.json b/owl-bot-staging/admin/v1/src/v1/datastore_admin_proto_list.json new file mode 100644 index 000000000..7a038c3a1 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/datastore_admin_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/datastore/admin/v1/datastore_admin.proto", + "../../protos/google/datastore/admin/v1/index.proto", + "../../protos/google/datastore/admin/v1/migration.proto" +] diff --git a/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json b/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json new file mode 100644 index 000000000..2b53e796b --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json @@ -0,0 +1,87 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.datastore.admin.v1", + "libraryPackage": "@google-cloud/datastore-admin", + "services": { + "DatastoreAdmin": { + "clients": { + "grpc": { + "libraryClient": "DatastoreAdminClient", + "rpcs": { + "GetIndex": { + "methods": [ + "getIndex" + ] + }, + "ExportEntities": { + "methods": [ + "exportEntities" + ] + }, + "ImportEntities": { + "methods": [ + "importEntities" + ] + }, + "CreateIndex": { + "methods": [ + "createIndex" + ] + }, + "DeleteIndex": { + "methods": [ + "deleteIndex" + ] + }, + "ListIndexes": { + "methods": [ + "listIndexes", + "listIndexesStream", + "listIndexesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DatastoreAdminClient", + "rpcs": { + "GetIndex": { + "methods": [ + "getIndex" + ] + }, + "ExportEntities": { + "methods": [ + "exportEntities" + ] + }, + "ImportEntities": { + "methods": [ + "importEntities" + ] + }, + "CreateIndex": { + "methods": [ + "createIndex" + ] + }, + "DeleteIndex": { + "methods": [ + "deleteIndex" + ] + }, + "ListIndexes": { + "methods": [ + "listIndexes", + "listIndexesStream", + "listIndexesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/admin/v1/src/v1/index.ts b/owl-bot-staging/admin/v1/src/v1/index.ts new file mode 100644 index 000000000..9a4370473 --- /dev/null +++ b/owl-bot-staging/admin/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {DatastoreAdminClient} from './datastore_admin_client'; diff --git a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 000000000..aa9f615db --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const admin = require('@google-cloud/datastore-admin'); + +function main() { + const datastoreAdminClient = new admin.DatastoreAdminClient(); +} + +main(); diff --git a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 000000000..83f1cd29f --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {DatastoreAdminClient} from '@google-cloud/datastore-admin'; + +// check that the client class type name can be used +function doStuffWithDatastoreAdminClient(client: DatastoreAdminClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const datastoreAdminClient = new DatastoreAdminClient(); + doStuffWithDatastoreAdminClient(datastoreAdminClient); +} + +main(); diff --git a/owl-bot-staging/admin/v1/system-test/install.ts b/owl-bot-staging/admin/v1/system-test/install.ts new file mode 100644 index 000000000..8ec452229 --- /dev/null +++ b/owl-bot-staging/admin/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/admin/v1/test/gapic_datastore_admin_v1.ts b/owl-bot-staging/admin/v1/test/gapic_datastore_admin_v1.ts new file mode 100644 index 000000000..78befb3c3 --- /dev/null +++ b/owl-bot-staging/admin/v1/test/gapic_datastore_admin_v1.ts @@ -0,0 +1,1357 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as datastoreadminModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DatastoreAdminClient', () => { + it('has servicePath', () => { + const servicePath = datastoreadminModule.v1.DatastoreAdminClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = datastoreadminModule.v1.DatastoreAdminClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = datastoreadminModule.v1.DatastoreAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.datastoreAdminStub, undefined); + await client.initialize(); + assert(client.datastoreAdminStub); + }); + + it('has close method for the initialized client', done => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.datastoreAdminStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.datastoreAdminStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getIndex', () => { + it('invokes getIndex without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.GetIndexRequest()); + request.projectId = ''; + request.indexId = ''; + const expectedHeaderRequestParams = "project_id=&index_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.admin.v1.Index()); + client.innerApiCalls.getIndex = stubSimpleCall(expectedResponse); + const [response] = await client.getIndex(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIndex without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.GetIndexRequest()); + request.projectId = ''; + request.indexId = ''; + const expectedHeaderRequestParams = "project_id=&index_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.admin.v1.Index()); + client.innerApiCalls.getIndex = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIndex( + request, + (err?: Error|null, result?: protos.google.datastore.admin.v1.IIndex|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIndex with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.GetIndexRequest()); + request.projectId = ''; + request.indexId = ''; + const expectedHeaderRequestParams = "project_id=&index_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIndex(request), expectedError); + assert((client.innerApiCalls.getIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIndex with closed client', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.GetIndexRequest()); + request.projectId = ''; + request.indexId = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIndex(request), expectedError); + }); + }); + + describe('exportEntities', () => { + it('invokes exportEntities without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ExportEntitiesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.exportEntities = stubLongRunningCall(expectedResponse); + const [operation] = await client.exportEntities(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.exportEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes exportEntities without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ExportEntitiesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.exportEntities = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.exportEntities( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.exportEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes exportEntities with call error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ExportEntitiesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.exportEntities = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.exportEntities(request), expectedError); + assert((client.innerApiCalls.exportEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes exportEntities with LRO error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ExportEntitiesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.exportEntities = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.exportEntities(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.exportEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkExportEntitiesProgress without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkExportEntitiesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkExportEntitiesProgress with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkExportEntitiesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('importEntities', () => { + it('invokes importEntities without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ImportEntitiesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importEntities = stubLongRunningCall(expectedResponse); + const [operation] = await client.importEntities(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importEntities without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ImportEntitiesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.importEntities = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importEntities( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importEntities with call error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ImportEntitiesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importEntities = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importEntities(request), expectedError); + assert((client.innerApiCalls.importEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importEntities with LRO error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ImportEntitiesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importEntities = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importEntities(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.importEntities as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkImportEntitiesProgress without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportEntitiesProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportEntitiesProgress with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkImportEntitiesProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('createIndex', () => { + it('invokes createIndex without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.CreateIndexRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createIndex = stubLongRunningCall(expectedResponse); + const [operation] = await client.createIndex(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createIndex without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.CreateIndexRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createIndex = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createIndex( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createIndex with call error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.CreateIndexRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createIndex(request), expectedError); + assert((client.innerApiCalls.createIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createIndex with LRO error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.CreateIndexRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createIndex = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createIndex(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateIndexProgress without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateIndexProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateIndexProgress with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateIndexProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteIndex', () => { + it('invokes deleteIndex without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.DeleteIndexRequest()); + request.projectId = ''; + request.indexId = ''; + const expectedHeaderRequestParams = "project_id=&index_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteIndex = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteIndex(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteIndex without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.DeleteIndexRequest()); + request.projectId = ''; + request.indexId = ''; + const expectedHeaderRequestParams = "project_id=&index_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteIndex = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteIndex( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteIndex with call error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.DeleteIndexRequest()); + request.projectId = ''; + request.indexId = ''; + const expectedHeaderRequestParams = "project_id=&index_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteIndex = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteIndex(request), expectedError); + assert((client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteIndex with LRO error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.DeleteIndexRequest()); + request.projectId = ''; + request.indexId = ''; + const expectedHeaderRequestParams = "project_id=&index_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteIndex = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteIndex(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteIndex as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteIndexProgress without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteIndexProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteIndexProgress with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkDeleteIndexProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listIndexes', () => { + it('invokes listIndexes without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + ]; + client.innerApiCalls.listIndexes = stubSimpleCall(expectedResponse); + const [response] = await client.listIndexes(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listIndexes without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + ]; + client.innerApiCalls.listIndexes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listIndexes( + request, + (err?: Error|null, result?: protos.google.datastore.admin.v1.IIndex[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listIndexes with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listIndexes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listIndexes(request), expectedError); + assert((client.innerApiCalls.listIndexes as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listIndexesStream without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedResponse = [ + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + ]; + client.descriptors.page.listIndexes.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listIndexesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.datastore.admin.v1.Index[] = []; + stream.on('data', (response: protos.google.datastore.admin.v1.Index) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listIndexes, request)); + assert.strictEqual( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listIndexesStream with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedError = new Error('expected'); + client.descriptors.page.listIndexes.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listIndexesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.datastore.admin.v1.Index[] = []; + stream.on('data', (response: protos.google.datastore.admin.v1.Index) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listIndexes, request)); + assert.strictEqual( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listIndexes without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedResponse = [ + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + ]; + client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.datastore.admin.v1.IIndex[] = []; + const iterable = client.listIndexesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listIndexes with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id=";const expectedError = new Error('expected'); + client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listIndexesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.datastore.admin.v1.IIndex[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); +}); diff --git a/owl-bot-staging/admin/v1/tsconfig.json b/owl-bot-staging/admin/v1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/admin/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/admin/v1/webpack.config.js b/owl-bot-staging/admin/v1/webpack.config.js new file mode 100644 index 000000000..1f646dd1e --- /dev/null +++ b/owl-bot-staging/admin/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'DatastoreAdmin', + filename: './datastore-admin.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 000000000..cfc348ec4 --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 000000000..782153495 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 000000000..a3585eb98 --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/datastore', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 000000000..481c522b0 --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 000000000..494e14786 --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 000000000..85e311e00 --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Datastore: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 000000000..befd23c86 --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 000000000..797318ad1 --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/datastore", + "version": "0.1.0", + "description": "Datastore client for Node.js", + "repository": "googleapis/nodejs-datastore", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google datastore", + "datastore", + "datastore" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.1.1" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/v1/protos/google/datastore/v1/datastore.proto b/owl-bot-staging/v1/protos/google/datastore/v1/datastore.proto new file mode 100644 index 000000000..22d930ad0 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/datastore/v1/datastore.proto @@ -0,0 +1,443 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; +option java_multiple_files = true; +option java_outer_classname = "DatastoreProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// Each RPC normalizes the partition IDs of the keys in its input entities, +// and always returns entities with keys with normalized partition IDs. +// This applies to all keys and entities, including those in values, except keys +// with both an empty path and an empty or unset partition ID. Normalization of +// input keys sets the project ID (if not already set) to the project ID from +// 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. + rpc RunQuery(RunQueryRequest) returns (RunQueryResponse) { + 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: "/v1/projects/{project_id}:beginTransaction" + body: "*" + }; + option (google.api.method_signature) = "project_id"; + } + + // Commits a transaction, optionally creating, deleting or modifying some + // entities. + rpc Commit(CommitRequest) returns (CommitResponse) { + option (google.api.http) = { + 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. + rpc Rollback(RollbackRequest) returns (RollbackResponse) { + option (google.api.http) = { + 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 + // before it is inserted. + rpc AllocateIds(AllocateIdsRequest) returns (AllocateIdsResponse) { + option (google.api.http) = { + 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 + // Datastore. + rpc ReserveIds(ReserveIdsRequest) returns (ReserveIdsResponse) { + option (google.api.http) = { + 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 { + // 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; + + // 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]. +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 + // input. + repeated EntityResult found = 1; + + // Entities not found as `ResultType.KEY_ONLY` entities. The order of results + // in this field is undefined and has no relation to the order of the keys + // in the input. + repeated EntityResult missing = 2; + + // A list of keys that were not looked up due to resource constraints. The + // order of results in this field is undefined and has no relation to the + // order of the keys in the input. + repeated Key deferred = 3; + + // The time at which these entities were read or found missing. + google.protobuf.Timestamp read_time = 7; +} + +// The request for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. +message RunQueryRequest { + // 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. + // This partition ID is normalized with the standard default context + // partition ID. + PartitionId partition_id = 2; + + // The options for this query. + ReadOptions read_options = 1; + + // The type of query. + oneof query_type { + // The query to run. + Query query = 3; + + // The GQL query to run. + GqlQuery gql_query = 7; + } +} + +// The response for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. +message RunQueryResponse { + // A batch of query results (always present). + QueryResultBatch batch = 1; + + // The parsed form of the `GqlQuery` from the request, if it was set. + Query query = 2; +} + +// The request for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. +message BeginTransactionRequest { + // 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]. +message BeginTransactionResponse { + // The transaction identifier (always present). + bytes transaction = 1; +} + +// The request for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. +message RollbackRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // Required. The transaction identifier, returned by a call to + // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + bytes transaction = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// 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 { + // The modes available for commits. + enum Mode { + // Unspecified. This value must not be used. + MODE_UNSPECIFIED = 0; + + // Transactional: The mutations are either all applied, or none are applied. + // Learn about transactions + // [here](https://cloud.google.com/datastore/docs/concepts/transactions). + TRANSACTIONAL = 1; + + // Non-transactional: The mutations may not apply as all or none. + NON_TRANSACTIONAL = 2; + } + + // 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; + + // Must be set when mode is `TRANSACTIONAL`. + oneof transaction_selector { + // The identifier of the transaction associated with the commit. A + // transaction identifier is returned by a call to + // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + bytes transaction = 1; + } + + // The mutations to perform. + // + // When mode is `TRANSACTIONAL`, mutations affecting a single entity are + // applied in order. The following sequences of mutations affecting a single + // entity are not permitted in a single `Commit` request: + // + // - `insert` followed by `insert` + // - `update` followed by `insert` + // - `upsert` followed by `insert` + // - `delete` followed by `update` + // + // When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single + // entity. + repeated Mutation mutations = 6; +} + +// 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. + repeated MutationResult mutation_results = 3; + + // The number of index entries updated during the commit, or zero if none were + // updated. + int32 index_updates = 4; + + // The transaction commit timestamp. Not set for non-transactional commits. + google.protobuf.Timestamp commit_time = 8; +} + +// The request for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. +message AllocateIdsRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // 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 [(google.api.field_behavior) = REQUIRED]; +} + +// 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]. +message ReserveIdsRequest { + // 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; + + // Required. A list of keys with complete key paths whose numeric IDs should not be + // auto-allocated. + repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The response for [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. +message ReserveIdsResponse { + +} + +// A mutation to apply to an entity. +message Mutation { + // The mutation operation. + // + // For `insert`, `update`, and `upsert`: + // - The entity's key must not be reserved/read-only. + // - No property in the entity may have a reserved name, + // not even a property in an entity in a value. + // - No value in the entity may have meaning 18, + // not even a value in an entity in another value. + oneof operation { + // The entity to insert. The entity must not already exist. + // The entity key's final path element may be incomplete. + Entity insert = 4; + + // The entity to update. The entity must already exist. + // Must have a complete key path. + Entity update = 5; + + // The entity to upsert. The entity may or may not already exist. + // The entity key's final path element may be incomplete. + Entity upsert = 6; + + // The key of the entity to delete. The entity may or may not already exist. + // 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 update time of the entity that this mutation is being applied + // to. If this does not match the current update time on the server, the + // mutation conflicts. + google.protobuf.Timestamp update_time = 11; + } +} + +// 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; + + // The update time of the entity on the server after processing the mutation. + // If the mutation doesn't change anything on the server, then the timestamp + // will be the update timestamp of the current entity. This field will not be + // set after a 'delete'. + google.protobuf.Timestamp update_time = 6; + + // 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. +message ReadOptions { + // The possible values for read consistencies. + enum ReadConsistency { + // Unspecified. This value must not be used. + READ_CONSISTENCY_UNSPECIFIED = 0; + + // Strong consistency. + STRONG = 1; + + // Eventual consistency. + EVENTUAL = 2; + } + + // For Cloud Datastore, if read_consistency is not specified, then lookups and + // ancestor queries default to `read_consistency`=`STRONG`, global queries + // default to `read_consistency`=`EVENTUAL`. + // + // For Cloud Firestore in Datastore mode, if read_consistency is not specified + // then lookups and all queries default to `read_consistency`=`STRONG`. + // + // Explicitly setting `read_consistency`=`EVENTUAL` will result in eventually + // consistent lookups & queries in both Cloud Datastore & Cloud Firestore in + // Datastore mode. + oneof consistency_type { + // The non-transactional read consistency to use. + // Cannot be set to `STRONG` for global queries. + ReadConsistency read_consistency = 1; + + // 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; + + // Reads entities as they were at the given time. This may not be older + // than 270 seconds. This value is only supported for Cloud Firestore in + // Datastore mode. + google.protobuf.Timestamp read_time = 4; + } +} + +// 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. +message TransactionOptions { + // Options specific to read / write transactions. + message ReadWrite { + // The transaction identifier of the transaction being retried. + bytes previous_transaction = 1; + } + + // Options specific to read-only transactions. + message ReadOnly { + // Reads entities at the given time. + // This may not be older than 60 seconds. + google.protobuf.Timestamp read_time = 1; + } + + // The `mode` of the transaction, indicating whether write operations are + // supported. + oneof mode { + // The transaction should allow both reads and writes. + ReadWrite read_write = 1; + + // The transaction should only allow reads. + ReadOnly read_only = 2; + } +} diff --git a/owl-bot-staging/v1/protos/google/datastore/v1/entity.proto b/owl-bot-staging/v1/protos/google/datastore/v1/entity.proto new file mode 100644 index 000000000..55d7b64fe --- /dev/null +++ b/owl-bot-staging/v1/protos/google/datastore/v1/entity.proto @@ -0,0 +1,214 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.datastore.v1; + +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/latlng.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; +option java_multiple_files = true; +option java_outer_classname = "EntityProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// A partition ID identifies a grouping of entities. The grouping is always +// by project and namespace, however the namespace ID may be empty. +// +// A partition ID contains several dimensions: +// project ID and namespace ID. +// +// Partition dimensions: +// +// - May be `""`. +// - Must be valid UTF-8 bytes. +// - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}` +// If the value of any dimension matches regex `__.*__`, the partition is +// reserved/read-only. +// A reserved/read-only partition ID is forbidden in certain documented +// contexts. +// +// Foreign partition IDs (in which the project ID does +// not match the context project ID ) are discouraged. +// Reads and writes of foreign partition IDs may fail if the project is not in an active state. +message PartitionId { + // The ID of the project to which the entities belong. + string project_id = 2; + + // If not empty, the ID of the namespace to which the entities belong. + string namespace_id = 4; +} + +// A unique identifier for an entity. +// If a key's partition ID or any of its path kinds or names are +// reserved/read-only, the key is reserved/read-only. +// A reserved/read-only key is forbidden in certain documented contexts. +message Key { + // A (kind, ID/name) pair used to construct a key path. + // + // If either name or ID is set, the element is complete. + // If neither is set, the element is incomplete. + message PathElement { + // The kind of the entity. + // + // A kind matching regex `__.*__` is reserved/read-only. + // A kind must not contain more than 1500 bytes when UTF-8 encoded. + // Cannot be `""`. + // + // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are + // encoded as `__bytes__` where `` is the base-64 encoding of the + // bytes. + string kind = 1; + + // The type of ID. + oneof id_type { + // The auto-allocated ID of the entity. + // + // Never equal to zero. Values less than zero are discouraged and may not + // be supported in the future. + int64 id = 2; + + // The name of the entity. + // + // A name matching regex `__.*__` is reserved/read-only. + // A name must not be more than 1500 bytes when UTF-8 encoded. + // Cannot be `""`. + // + // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are + // encoded as `__bytes__` where `` is the base-64 encoding of the + // bytes. + string name = 3; + } + } + + // Entities are partitioned into subsets, currently identified by a project + // ID and namespace ID. + // Queries are scoped to a single partition. + PartitionId partition_id = 1; + + // The entity path. + // An entity path consists of one or more elements composed of a kind and a + // string or numerical identifier, which identify entities. The first + // element identifies a _root entity_, the second element identifies + // a _child_ of the root entity, the third element identifies a child of the + // second entity, and so forth. The entities identified by all prefixes of + // the path are called the element's _ancestors_. + // + // An entity path is always fully complete: *all* of the entity's ancestors + // are required to be in the path along with the entity identifier itself. + // The only exception is that in some documented cases, the identifier in the + // last path element (for the entity) itself may be omitted. For example, + // the last path element of the key of `Mutation.insert` may have no + // identifier. + // + // A path can never be empty, and a path can have at most 100 elements. + repeated PathElement path = 2; +} + +// An array value. +message ArrayValue { + // Values in the array. + // 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; +} + +// A message that can hold any of the supported value types and associated +// metadata. +message Value { + // Must have a value set. + oneof value_type { + // A null value. + google.protobuf.NullValue null_value = 11; + + // A boolean value. + bool boolean_value = 1; + + // An integer value. + int64 integer_value = 2; + + // A double value. + double double_value = 3; + + // A timestamp value. + // When stored in the Datastore, precise only to microseconds; + // any additional precision is rounded down. + google.protobuf.Timestamp timestamp_value = 10; + + // A key 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 most 1,000,000 bytes. + string string_value = 17; + + // A blob value. + // May have at most 1,000,000 bytes. + // When `exclude_from_indexes` is false, may have at most 1500 bytes. + // In JSON requests, must be base64-encoded. + bytes blob_value = 18; + + // A geo point value representing a point on the surface of Earth. + google.type.LatLng geo_point_value = 8; + + // An entity value. + // + // - May have no key. + // - May have a key with an incomplete key path. + // - May have a reserved/read-only key. + Entity entity_value = 6; + + // An array value. + // Cannot contain another array value. + // A `Value` instance that sets field `array_value` must not set fields + // `meaning` or `exclude_from_indexes`. + ArrayValue array_value = 9; + } + + // The `meaning` field should only be populated for backwards compatibility. + int32 meaning = 14; + + // If the value should be excluded from all indexes including those defined + // explicitly. + bool exclude_from_indexes = 19; +} + +// A Datastore data object. +// +// An entity is limited to 1 megabyte when stored. That _roughly_ +// corresponds to a limit of 1 megabyte for the serialized form of this +// message. +message Entity { + // The entity's key. + // + // An entity must have a key, unless otherwise documented (for example, + // an entity in `Value.entity_value` may have no key). + // An entity's kind is its key path's last element's kind, + // or null if it has no key. + Key key = 1; + + // The entity's properties. + // The map's keys are property names. + // A property name matching regex `__.*__` is reserved. + // A reserved property name is forbidden in certain documented contexts. + // The name must not contain more than 500 characters. + // The name cannot be `""`. + map properties = 3; +} diff --git a/owl-bot-staging/v1/protos/google/datastore/v1/query.proto b/owl-bot-staging/v1/protos/google/datastore/v1/query.proto new file mode 100644 index 000000000..00c020021 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/datastore/v1/query.proto @@ -0,0 +1,375 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.datastore.v1; + +import "google/datastore/v1/entity.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; +option java_multiple_files = true; +option java_outer_classname = "QueryProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// The result of fetching an entity from Datastore. +message EntityResult { + // Specifies what data the 'entity' field contains. + // A `ResultType` is either implied (for example, in `LookupResponse.missing` + // from `datastore.proto`, it is always `KEY_ONLY`) or specified by context + // (for example, in message `QueryResultBatch`, field `entity_result_type` + // specifies a `ResultType` for all the values in field `entity_results`). + enum ResultType { + // Unspecified. This value is never used. + RESULT_TYPE_UNSPECIFIED = 0; + + // The key and properties. + FULL = 1; + + // A projected subset of properties. The entity may have no key. + PROJECTION = 2; + + // Only the key. + KEY_ONLY = 3; + } + + // The resulting entity. + Entity entity = 1; + + // 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. + // + // 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; + + // The time at which the entity was last changed. + // This field is set for [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity + // results. + // If this entity is missing, this field will not be set. + google.protobuf.Timestamp update_time = 5; + + // A cursor that points to the position after the result entity. + // Set only when the `EntityResult` is part of a `QueryResultBatch` message. + bytes cursor = 3; +} + +// A query for entities. +message Query { + // The projection to return. Defaults to returning all properties. + repeated Projection projection = 2; + + // The kinds to query (if empty, returns entities of all kinds). + // Currently at most 1 kind may be specified. + repeated KindExpression kind = 3; + + // The filter to apply. + Filter filter = 4; + + // The order to apply to the query results (if empty, order is unspecified). + repeated PropertyOrder order = 5; + + // The properties to make distinct. The query results will contain the first + // result for each distinct combination of values for the given properties + // (if empty, all results are returned). + repeated PropertyReference distinct_on = 6; + + // A starting point for the query results. Query cursors are + // returned in query result batches and + // [can only be used to continue the same + // query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). + bytes start_cursor = 7; + + // An ending point for the query results. Query cursors are + // returned in query result batches and + // [can only be used to limit the same + // query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). + bytes end_cursor = 8; + + // The number of results to skip. Applies before limit, but after all other + // constraints. Optional. Must be >= 0 if specified. + int32 offset = 10; + + // The maximum number of results to return. Applies after all other + // constraints. Optional. + // Unspecified is interpreted as no limit. + // Must be >= 0 if specified. + google.protobuf.Int32Value limit = 12; +} + +// A representation of a kind. +message KindExpression { + // The name of the kind. + string name = 1; +} + +// A reference to a property relative to the kind expressions. +message PropertyReference { + // The name of the property. + // If name includes "."s, it may be interpreted as a property name path. + string name = 2; +} + +// A representation of a property in a projection. +message Projection { + // The property to project. + PropertyReference property = 1; +} + +// The desired order for a specific property. +message PropertyOrder { + // The sort direction. + enum Direction { + // Unspecified. This value must not be used. + DIRECTION_UNSPECIFIED = 0; + + // Ascending. + ASCENDING = 1; + + // Descending. + DESCENDING = 2; + } + + // The property to order by. + PropertyReference property = 1; + + // The direction to order by. Defaults to `ASCENDING`. + Direction direction = 2; +} + +// A holder for any type of filter. +message Filter { + // The type of filter. + oneof filter_type { + // A composite filter. + CompositeFilter composite_filter = 1; + + // A filter on a property. + PropertyFilter property_filter = 2; + } +} + +// A filter that merges multiple other filters using the given operator. +message CompositeFilter { + // A composite filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The results are required to satisfy each of the combined filters. + AND = 1; + } + + // The operator for combining multiple filters. + Operator op = 1; + + // The list of filters to combine. + // Must contain at least one filter. + repeated Filter filters = 2; +} + +// A filter on a specific property. +message PropertyFilter { + // A property filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The given `property` is less than the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + LESS_THAN = 1; + + // The given `property` is less than or equal to the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + LESS_THAN_OR_EQUAL = 2; + + // The given `property` is greater than the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + GREATER_THAN = 3; + + // The given `property` is greater than or equal to the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + GREATER_THAN_OR_EQUAL = 4; + + // The given `property` is equal to the given `value`. + EQUAL = 5; + + // The given `property` is equal to at least one value in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN` or `NOT_IN` is in the same query. + IN = 6; + + // The given `property` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL` or `NOT_IN` is in the same query. + // * That `property` comes first in the `order_by`. + NOT_EQUAL = 9; + + // Limit the result set to the given entity and its descendants. + // + // Requires: + // + // * That `value` is an entity key. + HAS_ANCESTOR = 11; + + // The value of the `property` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `IN`, `NOT_IN`, `NOT_EQUAL` is in the same query. + // * That `field` comes first in the `order_by`. + NOT_IN = 13; + } + + // The property to filter by. + PropertyReference property = 1; + + // The operator to filter by. + Operator op = 2; + + // The value to compare the property to. + Value value = 3; +} + +// A [GQL +// query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). +message GqlQuery { + // A string of the format described + // [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). + string query_string = 1; + + // When false, the query string must not contain any literals and instead must + // bind all values. For example, + // `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while + // `SELECT * FROM Kind WHERE a = @value` is. + bool allow_literals = 2; + + // For each non-reserved named binding site in the query string, there must be + // a named parameter with that name, but not necessarily the inverse. + // + // Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex + // `__.*__`, and must not be `""`. + map named_bindings = 5; + + // Numbered binding site @1 references the first numbered parameter, + // effectively using 1-based indexing, rather than the usual 0. + // + // For each binding site numbered i in `query_string`, there must be an i-th + // numbered parameter. The inverse must also be true. + repeated GqlQueryParameter positional_bindings = 4; +} + +// A binding parameter for a GQL query. +message GqlQueryParameter { + // The type of parameter. + oneof parameter_type { + // A value parameter. + Value value = 2; + + // A query cursor. Query cursors are returned in query + // result batches. + bytes cursor = 3; + } +} + +// A batch of results produced by a query. +message QueryResultBatch { + // The possible values for the `more_results` field. + enum MoreResultsType { + // Unspecified. This value is never used. + MORE_RESULTS_TYPE_UNSPECIFIED = 0; + + // There may be additional batches to fetch from this query. + NOT_FINISHED = 1; + + // The query is finished, but there may be more results after the limit. + MORE_RESULTS_AFTER_LIMIT = 2; + + // The query is finished, but there may be more results after the end + // cursor. + MORE_RESULTS_AFTER_CURSOR = 4; + + // The query is finished, and there are no more results. + NO_MORE_RESULTS = 3; + } + + // The number of results skipped, typically because of an offset. + int32 skipped_results = 6; + + // A cursor that points to the position after the last skipped result. + // Will be set when `skipped_results` != 0. + bytes skipped_cursor = 3; + + // The result type for every entity in `entity_results`. + EntityResult.ResultType entity_result_type = 1; + + // The results for this batch. + repeated EntityResult entity_results = 2; + + // A cursor that points to the position after the last result in the batch. + bytes end_cursor = 4; + + // The state of the query after the current batch. + MoreResultsType more_results = 5; + + // The version number of the snapshot this batch was returned from. + // This applies to the range of results from the query's `start_cursor` (or + // the beginning of the query if no cursor was given) to this batch's + // `end_cursor` (not the query's `end_cursor`). + // + // In a single transaction, subsequent query result batches for the same query + // can have a greater snapshot version number. Each batch's snapshot version + // is valid for all preceding batches. + // The value will be zero for eventually consistent queries. + int64 snapshot_version = 7; + + // Read timestamp this batch was returned from. + // This applies to the range of results from the query's `start_cursor` (or + // the beginning of the query if no cursor was given) to this batch's + // `end_cursor` (not the query's `end_cursor`). + // + // In a single transaction, subsequent query result batches for the same query + // can have a greater timestamp. Each batch's read timestamp + // is valid for all preceding batches. + // This value will not be set for eventually consistent queries in Cloud + // Datastore. + google.protobuf.Timestamp read_time = 8; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.allocate_ids.js b/owl-bot-staging/v1/samples/generated/v1/datastore.allocate_ids.js new file mode 100644 index 000000000..9700a2d52 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/datastore.allocate_ids.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, keys) { + // [START datastore_v1_generated_Datastore_AllocateIds_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * Required. A list of keys with incomplete key paths for which to allocate IDs. + * No key may be reserved/read-only. + */ + // const keys = 1234 + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callAllocateIds() { + // Construct request + const request = { + projectId, + keys, + }; + + // Run request + const response = await datastoreClient.allocateIds(request); + console.log(response); + } + + callAllocateIds(); + // [END datastore_v1_generated_Datastore_AllocateIds_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.begin_transaction.js b/owl-bot-staging/v1/samples/generated/v1/datastore.begin_transaction.js new file mode 100644 index 000000000..81880be31 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/datastore.begin_transaction.js @@ -0,0 +1,62 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId) { + // [START datastore_v1_generated_Datastore_BeginTransaction_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * Options for a new transaction. + */ + // const transactionOptions = {} + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callBeginTransaction() { + // Construct request + const request = { + projectId, + }; + + // Run request + const response = await datastoreClient.beginTransaction(request); + console.log(response); + } + + callBeginTransaction(); + // [END datastore_v1_generated_Datastore_BeginTransaction_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.commit.js b/owl-bot-staging/v1/samples/generated/v1/datastore.commit.js new file mode 100644 index 000000000..cf2309444 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/datastore.commit.js @@ -0,0 +1,81 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId) { + // [START datastore_v1_generated_Datastore_Commit_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The type of commit to perform. Defaults to `TRANSACTIONAL`. + */ + // const mode = {} + /** + * The identifier of the transaction associated with the commit. A + * transaction identifier is returned by a call to + * Datastore.BeginTransaction google.datastore.v1.Datastore.BeginTransaction. + */ + // const transaction = 'Buffer.from('string')' + /** + * The mutations to perform. + * When mode is `TRANSACTIONAL`, mutations affecting a single entity are + * applied in order. The following sequences of mutations affecting a single + * entity are not permitted in a single `Commit` request: + * - `insert` followed by `insert` + * - `update` followed by `insert` + * - `upsert` followed by `insert` + * - `delete` followed by `update` + * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single + * entity. + */ + // const mutations = 1234 + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callCommit() { + // Construct request + const request = { + projectId, + }; + + // Run request + const response = await datastoreClient.commit(request); + console.log(response); + } + + callCommit(); + // [END datastore_v1_generated_Datastore_Commit_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.lookup.js b/owl-bot-staging/v1/samples/generated/v1/datastore.lookup.js new file mode 100644 index 000000000..2fe543be6 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/datastore.lookup.js @@ -0,0 +1,67 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, keys) { + // [START datastore_v1_generated_Datastore_Lookup_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The options for this lookup request. + */ + // const readOptions = {} + /** + * Required. Keys of entities to look up. + */ + // const keys = 1234 + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callLookup() { + // Construct request + const request = { + projectId, + keys, + }; + + // Run request + const response = await datastoreClient.lookup(request); + console.log(response); + } + + callLookup(); + // [END datastore_v1_generated_Datastore_Lookup_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.reserve_ids.js b/owl-bot-staging/v1/samples/generated/v1/datastore.reserve_ids.js new file mode 100644 index 000000000..be7e91d6a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/datastore.reserve_ids.js @@ -0,0 +1,68 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, keys) { + // [START datastore_v1_generated_Datastore_ReserveIds_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * If not empty, the ID of the database against which to make the request. + */ + // const databaseId = 'abc123' + /** + * Required. A list of keys with complete key paths whose numeric IDs should not be + * auto-allocated. + */ + // const keys = 1234 + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callReserveIds() { + // Construct request + const request = { + projectId, + keys, + }; + + // Run request + const response = await datastoreClient.reserveIds(request); + console.log(response); + } + + callReserveIds(); + // [END datastore_v1_generated_Datastore_ReserveIds_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.rollback.js b/owl-bot-staging/v1/samples/generated/v1/datastore.rollback.js new file mode 100644 index 000000000..7cead96b5 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/datastore.rollback.js @@ -0,0 +1,64 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, transaction) { + // [START datastore_v1_generated_Datastore_Rollback_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * Required. The transaction identifier, returned by a call to + * Datastore.BeginTransaction google.datastore.v1.Datastore.BeginTransaction. + */ + // const transaction = 'Buffer.from('string')' + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callRollback() { + // Construct request + const request = { + projectId, + transaction, + }; + + // Run request + const response = await datastoreClient.rollback(request); + console.log(response); + } + + callRollback(); + // [END datastore_v1_generated_Datastore_Rollback_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.run_query.js b/owl-bot-staging/v1/samples/generated/v1/datastore.run_query.js new file mode 100644 index 000000000..d5995beff --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/datastore.run_query.js @@ -0,0 +1,77 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId) { + // [START datastore_v1_generated_Datastore_RunQuery_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * Entities are partitioned into subsets, identified by a partition ID. + * Queries are scoped to a single partition. + * This partition ID is normalized with the standard default context + * partition ID. + */ + // const partitionId = {} + /** + * The options for this query. + */ + // const readOptions = {} + /** + * The query to run. + */ + // const query = {} + /** + * The GQL query to run. + */ + // const gqlQuery = {} + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callRunQuery() { + // Construct request + const request = { + projectId, + }; + + // Run request + const response = await datastoreClient.runQuery(request); + console.log(response); + } + + callRunQuery(); + // [END datastore_v1_generated_Datastore_RunQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.datastore.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.datastore.v1.json new file mode 100644 index 000000000..d41928b9c --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.datastore.v1.json @@ -0,0 +1,351 @@ +{ + "clientLibrary": { + "name": "nodejs-datastore", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.datastore.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "datastore_v1_generated_Datastore_Lookup_async", + "title": "datastore lookup Sample", + "origin": "API_DEFINITION", + "description": " Looks up entities by key.", + "canonical": true, + "file": "datastore.lookup.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Lookup", + "fullName": "google.datastore.v1.Datastore.Lookup", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "read_options", + "type": ".google.datastore.v1.ReadOptions" + }, + { + "name": "keys", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.LookupResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "Lookup", + "fullName": "google.datastore.v1.Datastore.Lookup", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_RunQuery_async", + "title": "datastore runQuery Sample", + "origin": "API_DEFINITION", + "description": " Queries for entities.", + "canonical": true, + "file": "datastore.run_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunQuery", + "fullName": "google.datastore.v1.Datastore.RunQuery", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "partition_id", + "type": ".google.datastore.v1.PartitionId" + }, + { + "name": "read_options", + "type": ".google.datastore.v1.ReadOptions" + }, + { + "name": "query", + "type": ".google.datastore.v1.Query" + }, + { + "name": "gql_query", + "type": ".google.datastore.v1.GqlQuery" + } + ], + "resultType": ".google.datastore.v1.RunQueryResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "RunQuery", + "fullName": "google.datastore.v1.Datastore.RunQuery", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_BeginTransaction_async", + "title": "datastore beginTransaction Sample", + "origin": "API_DEFINITION", + "description": " Begins a new transaction.", + "canonical": true, + "file": "datastore.begin_transaction.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BeginTransaction", + "fullName": "google.datastore.v1.Datastore.BeginTransaction", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "transaction_options", + "type": ".google.datastore.v1.TransactionOptions" + } + ], + "resultType": ".google.datastore.v1.BeginTransactionResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "BeginTransaction", + "fullName": "google.datastore.v1.Datastore.BeginTransaction", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_Commit_async", + "title": "datastore commit Sample", + "origin": "API_DEFINITION", + "description": " Commits a transaction, optionally creating, deleting or modifying some entities.", + "canonical": true, + "file": "datastore.commit.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 73, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Commit", + "fullName": "google.datastore.v1.Datastore.Commit", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "mode", + "type": ".google.datastore.v1.CommitRequest.Mode" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "mutations", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.CommitResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "Commit", + "fullName": "google.datastore.v1.Datastore.Commit", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_Rollback_async", + "title": "datastore rollback Sample", + "origin": "API_DEFINITION", + "description": " Rolls back a transaction.", + "canonical": true, + "file": "datastore.rollback.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Rollback", + "fullName": "google.datastore.v1.Datastore.Rollback", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.datastore.v1.RollbackResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "Rollback", + "fullName": "google.datastore.v1.Datastore.Rollback", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_AllocateIds_async", + "title": "datastore allocateIds Sample", + "origin": "API_DEFINITION", + "description": " Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.", + "canonical": true, + "file": "datastore.allocate_ids.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AllocateIds", + "fullName": "google.datastore.v1.Datastore.AllocateIds", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "keys", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.AllocateIdsResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "AllocateIds", + "fullName": "google.datastore.v1.Datastore.AllocateIds", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_ReserveIds_async", + "title": "datastore reserveIds Sample", + "origin": "API_DEFINITION", + "description": " Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.", + "canonical": true, + "file": "datastore.reserve_ids.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReserveIds", + "fullName": "google.datastore.v1.Datastore.ReserveIds", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "keys", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.ReserveIdsResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "ReserveIds", + "fullName": "google.datastore.v1.Datastore.ReserveIds", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 000000000..9dc4ec49b --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const DatastoreClient = v1.DatastoreClient; +type DatastoreClient = v1.DatastoreClient; +export {v1, DatastoreClient}; +export default {v1, DatastoreClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/datastore_client.ts b/owl-bot-staging/v1/src/v1/datastore_client.ts new file mode 100644 index 000000000..8147be899 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/datastore_client.ts @@ -0,0 +1,847 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/datastore_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './datastore_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Each RPC normalizes the partition IDs of the keys in its input entities, + * and always returns entities with keys with normalized partition IDs. + * This applies to all keys and entities, including those in values, except keys + * with both an empty path and an empty or unset partition ID. Normalization of + * input keys sets the project ID (if not already set) to the project ID from + * the request. + * + * @class + * @memberof v1 + */ +export class DatastoreClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + datastoreStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DatastoreClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DatastoreClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.datastore.v1.Datastore', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.datastoreStub) { + return this.datastoreStub; + } + + // Put together the "service stub" for + // google.datastore.v1.Datastore. + this.datastoreStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.datastore.v1.Datastore') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.datastore.v1.Datastore, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const datastoreStubMethods = + ['lookup', 'runQuery', 'beginTransaction', 'commit', 'rollback', 'allocateIds', 'reserveIds']; + for (const methodName of datastoreStubMethods) { + const callPromise = this.datastoreStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.datastoreStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'datastore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'datastore.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/datastore' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Looks up entities by key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {google.datastore.v1.ReadOptions} request.readOptions + * The options for this lookup request. + * @param {number[]} request.keys + * Required. Keys of entities to look up. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LookupResponse]{@link google.datastore.v1.LookupResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/datastore.lookup.js + * region_tag:datastore_v1_generated_Datastore_Lookup_async + */ + lookup( + request?: protos.google.datastore.v1.ILookupRequest, + options?: CallOptions): + Promise<[ + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest|undefined, {}|undefined + ]>; + lookup( + request: protos.google.datastore.v1.ILookupRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest|null|undefined, + {}|null|undefined>): void; + lookup( + request: protos.google.datastore.v1.ILookupRequest, + callback: Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest|null|undefined, + {}|null|undefined>): void; + lookup( + request?: protos.google.datastore.v1.ILookupRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.lookup(request, options, callback); + } +/** + * Queries for entities. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {google.datastore.v1.PartitionId} request.partitionId + * Entities are partitioned into subsets, identified by a partition ID. + * Queries are scoped to a single partition. + * This partition ID is normalized with the standard default context + * partition ID. + * @param {google.datastore.v1.ReadOptions} request.readOptions + * The options for this query. + * @param {google.datastore.v1.Query} request.query + * The query to run. + * @param {google.datastore.v1.GqlQuery} request.gqlQuery + * The GQL query to run. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [RunQueryResponse]{@link google.datastore.v1.RunQueryResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/datastore.run_query.js + * region_tag:datastore_v1_generated_Datastore_RunQuery_async + */ + runQuery( + request?: protos.google.datastore.v1.IRunQueryRequest, + options?: CallOptions): + Promise<[ + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest|undefined, {}|undefined + ]>; + runQuery( + request: protos.google.datastore.v1.IRunQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest|null|undefined, + {}|null|undefined>): void; + runQuery( + request: protos.google.datastore.v1.IRunQueryRequest, + callback: Callback< + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest|null|undefined, + {}|null|undefined>): void; + runQuery( + request?: protos.google.datastore.v1.IRunQueryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.runQuery(request, options, callback); + } +/** + * Begins a new transaction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {google.datastore.v1.TransactionOptions} request.transactionOptions + * Options for a new transaction. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BeginTransactionResponse]{@link google.datastore.v1.BeginTransactionResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/datastore.begin_transaction.js + * region_tag:datastore_v1_generated_Datastore_BeginTransaction_async + */ + beginTransaction( + request?: protos.google.datastore.v1.IBeginTransactionRequest, + options?: CallOptions): + Promise<[ + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest|undefined, {}|undefined + ]>; + beginTransaction( + request: protos.google.datastore.v1.IBeginTransactionRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): void; + beginTransaction( + request: protos.google.datastore.v1.IBeginTransactionRequest, + callback: Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): void; + beginTransaction( + request?: protos.google.datastore.v1.IBeginTransactionRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.beginTransaction(request, options, callback); + } +/** + * Commits a transaction, optionally creating, deleting or modifying some + * entities. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {google.datastore.v1.CommitRequest.Mode} request.mode + * The type of commit to perform. Defaults to `TRANSACTIONAL`. + * @param {Buffer} request.transaction + * The identifier of the transaction associated with the commit. A + * transaction identifier is returned by a call to + * {@link google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}. + * @param {number[]} request.mutations + * The mutations to perform. + * + * When mode is `TRANSACTIONAL`, mutations affecting a single entity are + * applied in order. The following sequences of mutations affecting a single + * entity are not permitted in a single `Commit` request: + * + * - `insert` followed by `insert` + * - `update` followed by `insert` + * - `upsert` followed by `insert` + * - `delete` followed by `update` + * + * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single + * entity. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CommitResponse]{@link google.datastore.v1.CommitResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/datastore.commit.js + * region_tag:datastore_v1_generated_Datastore_Commit_async + */ + commit( + request?: protos.google.datastore.v1.ICommitRequest, + options?: CallOptions): + Promise<[ + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest|undefined, {}|undefined + ]>; + commit( + request: protos.google.datastore.v1.ICommitRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest|null|undefined, + {}|null|undefined>): void; + commit( + request: protos.google.datastore.v1.ICommitRequest, + callback: Callback< + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest|null|undefined, + {}|null|undefined>): void; + commit( + request?: protos.google.datastore.v1.ICommitRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.commit(request, options, callback); + } +/** + * Rolls back a transaction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {Buffer} request.transaction + * Required. The transaction identifier, returned by a call to + * {@link google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [RollbackResponse]{@link google.datastore.v1.RollbackResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/datastore.rollback.js + * region_tag:datastore_v1_generated_Datastore_Rollback_async + */ + rollback( + request?: protos.google.datastore.v1.IRollbackRequest, + options?: CallOptions): + Promise<[ + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest|undefined, {}|undefined + ]>; + rollback( + request: protos.google.datastore.v1.IRollbackRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest|null|undefined, + {}|null|undefined>): void; + rollback( + request: protos.google.datastore.v1.IRollbackRequest, + callback: Callback< + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest|null|undefined, + {}|null|undefined>): void; + rollback( + request?: protos.google.datastore.v1.IRollbackRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.rollback(request, options, callback); + } +/** + * Allocates IDs for the given keys, which is useful for referencing an entity + * before it is inserted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {number[]} request.keys + * Required. A list of keys with incomplete key paths for which to allocate IDs. + * No key may be reserved/read-only. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AllocateIdsResponse]{@link google.datastore.v1.AllocateIdsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/datastore.allocate_ids.js + * region_tag:datastore_v1_generated_Datastore_AllocateIds_async + */ + allocateIds( + request?: protos.google.datastore.v1.IAllocateIdsRequest, + options?: CallOptions): + Promise<[ + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest|undefined, {}|undefined + ]>; + allocateIds( + request: protos.google.datastore.v1.IAllocateIdsRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest|null|undefined, + {}|null|undefined>): void; + allocateIds( + request: protos.google.datastore.v1.IAllocateIdsRequest, + callback: Callback< + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest|null|undefined, + {}|null|undefined>): void; + allocateIds( + request?: protos.google.datastore.v1.IAllocateIdsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.allocateIds(request, options, callback); + } +/** + * Prevents the supplied keys' IDs from being auto-allocated by Cloud + * Datastore. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {string} request.databaseId + * If not empty, the ID of the database against which to make the request. + * @param {number[]} request.keys + * Required. A list of keys with complete key paths whose numeric IDs should not be + * auto-allocated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ReserveIdsResponse]{@link google.datastore.v1.ReserveIdsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/datastore.reserve_ids.js + * region_tag:datastore_v1_generated_Datastore_ReserveIds_async + */ + reserveIds( + request?: protos.google.datastore.v1.IReserveIdsRequest, + options?: CallOptions): + Promise<[ + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest|undefined, {}|undefined + ]>; + reserveIds( + request: protos.google.datastore.v1.IReserveIdsRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest|null|undefined, + {}|null|undefined>): void; + reserveIds( + request: protos.google.datastore.v1.IReserveIdsRequest, + callback: Callback< + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest|null|undefined, + {}|null|undefined>): void; + reserveIds( + request?: protos.google.datastore.v1.IReserveIdsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'project_id': request.projectId || '', + }); + this.initialize(); + return this.innerApiCalls.reserveIds(request, options, callback); + } + + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.datastoreStub && !this._terminated) { + return this.datastoreStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/datastore_client_config.json b/owl-bot-staging/v1/src/v1/datastore_client_config.json new file mode 100644 index 000000000..37bd1c737 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/datastore_client_config.json @@ -0,0 +1,61 @@ +{ + "interfaces": { + "google.datastore.v1.Datastore": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "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": { + "Lookup": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RunQuery": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BeginTransaction": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Commit": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "Rollback": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "AllocateIds": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ReserveIds": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/datastore_proto_list.json b/owl-bot-staging/v1/src/v1/datastore_proto_list.json new file mode 100644 index 000000000..0636f1215 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/datastore_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/datastore/v1/datastore.proto", + "../../protos/google/datastore/v1/entity.proto", + "../../protos/google/datastore/v1/query.proto" +] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 000000000..d5eb8d916 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,93 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.datastore.v1", + "libraryPackage": "@google-cloud/datastore", + "services": { + "Datastore": { + "clients": { + "grpc": { + "libraryClient": "DatastoreClient", + "rpcs": { + "Lookup": { + "methods": [ + "lookup" + ] + }, + "RunQuery": { + "methods": [ + "runQuery" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "AllocateIds": { + "methods": [ + "allocateIds" + ] + }, + "ReserveIds": { + "methods": [ + "reserveIds" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DatastoreClient", + "rpcs": { + "Lookup": { + "methods": [ + "lookup" + ] + }, + "RunQuery": { + "methods": [ + "runQuery" + ] + }, + "BeginTransaction": { + "methods": [ + "beginTransaction" + ] + }, + "Commit": { + "methods": [ + "commit" + ] + }, + "Rollback": { + "methods": [ + "rollback" + ] + }, + "AllocateIds": { + "methods": [ + "allocateIds" + ] + }, + "ReserveIds": { + "methods": [ + "reserveIds" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 000000000..63381b364 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {DatastoreClient} from './datastore_client'; diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 000000000..5dbaf7a7b --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const datastore = require('@google-cloud/datastore'); + +function main() { + const datastoreClient = new datastore.DatastoreClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 000000000..28b7ce4d6 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {DatastoreClient} from '@google-cloud/datastore'; + +// check that the client class type name can be used +function doStuffWithDatastoreClient(client: DatastoreClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const datastoreClient = new DatastoreClient(); + doStuffWithDatastoreClient(datastoreClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 000000000..8ec452229 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1/test/gapic_datastore_v1.ts b/owl-bot-staging/v1/test/gapic_datastore_v1.ts new file mode 100644 index 000000000..4a4d331c6 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_datastore_v1.ts @@ -0,0 +1,814 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as datastoreModule from '../src'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +describe('v1.DatastoreClient', () => { + it('has servicePath', () => { + const servicePath = datastoreModule.v1.DatastoreClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = datastoreModule.v1.DatastoreClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = datastoreModule.v1.DatastoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new datastoreModule.v1.DatastoreClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new datastoreModule.v1.DatastoreClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.datastoreStub, undefined); + await client.initialize(); + assert(client.datastoreStub); + }); + + it('has close method for the initialized client', done => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.datastoreStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.datastoreStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('lookup', () => { + it('invokes lookup without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.LookupRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.LookupResponse()); + client.innerApiCalls.lookup = stubSimpleCall(expectedResponse); + const [response] = await client.lookup(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.lookup as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes lookup without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.LookupRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.LookupResponse()); + client.innerApiCalls.lookup = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.lookup( + request, + (err?: Error|null, result?: protos.google.datastore.v1.ILookupResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.lookup as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes lookup with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.LookupRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.lookup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.lookup(request), expectedError); + assert((client.innerApiCalls.lookup as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes lookup with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.LookupRequest()); + request.projectId = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.lookup(request), expectedError); + }); + }); + + describe('runQuery', () => { + it('invokes runQuery without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.RunQueryRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.RunQueryResponse()); + client.innerApiCalls.runQuery = stubSimpleCall(expectedResponse); + const [response] = await client.runQuery(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.runQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes runQuery without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.RunQueryRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.RunQueryResponse()); + client.innerApiCalls.runQuery = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runQuery( + request, + (err?: Error|null, result?: protos.google.datastore.v1.IRunQueryResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.runQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes runQuery with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.RunQueryRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.runQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.runQuery(request), expectedError); + assert((client.innerApiCalls.runQuery as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes runQuery with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.RunQueryRequest()); + request.projectId = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.runQuery(request), expectedError); + }); + }); + + describe('beginTransaction', () => { + it('invokes beginTransaction without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionResponse()); + client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); + const [response] = await client.beginTransaction(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes beginTransaction without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionResponse()); + client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.beginTransaction( + request, + (err?: Error|null, result?: protos.google.datastore.v1.IBeginTransactionResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes beginTransaction with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.beginTransaction(request), expectedError); + assert((client.innerApiCalls.beginTransaction as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes beginTransaction with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionRequest()); + request.projectId = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.beginTransaction(request), expectedError); + }); + }); + + describe('commit', () => { + it('invokes commit without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.CommitRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.CommitResponse()); + client.innerApiCalls.commit = stubSimpleCall(expectedResponse); + const [response] = await client.commit(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.commit as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes commit without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.CommitRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.CommitResponse()); + client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.commit( + request, + (err?: Error|null, result?: protos.google.datastore.v1.ICommitResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.commit as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes commit with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.CommitRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.commit(request), expectedError); + assert((client.innerApiCalls.commit as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes commit with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.CommitRequest()); + request.projectId = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.commit(request), expectedError); + }); + }); + + describe('rollback', () => { + it('invokes rollback without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.RollbackRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.RollbackResponse()); + client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); + const [response] = await client.rollback(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rollback as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rollback without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.RollbackRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.RollbackResponse()); + client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollback( + request, + (err?: Error|null, result?: protos.google.datastore.v1.IRollbackResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.rollback as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes rollback with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.RollbackRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.rollback(request), expectedError); + assert((client.innerApiCalls.rollback as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes rollback with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.RollbackRequest()); + request.projectId = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.rollback(request), expectedError); + }); + }); + + describe('allocateIds', () => { + it('invokes allocateIds without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsResponse()); + client.innerApiCalls.allocateIds = stubSimpleCall(expectedResponse); + const [response] = await client.allocateIds(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.allocateIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes allocateIds without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsResponse()); + client.innerApiCalls.allocateIds = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.allocateIds( + request, + (err?: Error|null, result?: protos.google.datastore.v1.IAllocateIdsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.allocateIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes allocateIds with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.allocateIds = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.allocateIds(request), expectedError); + assert((client.innerApiCalls.allocateIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes allocateIds with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsRequest()); + request.projectId = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.allocateIds(request), expectedError); + }); + }); + + describe('reserveIds', () => { + it('invokes reserveIds without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsResponse()); + client.innerApiCalls.reserveIds = stubSimpleCall(expectedResponse); + const [response] = await client.reserveIds(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.reserveIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes reserveIds without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsResponse()); + client.innerApiCalls.reserveIds = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reserveIds( + request, + (err?: Error|null, result?: protos.google.datastore.v1.IReserveIdsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.reserveIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes reserveIds with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsRequest()); + request.projectId = ''; + const expectedHeaderRequestParams = "project_id="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.reserveIds = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.reserveIds(request), expectedError); + assert((client.innerApiCalls.reserveIds as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes reserveIds with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsRequest()); + request.projectId = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.reserveIds(request), expectedError); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 000000000..c78f1c884 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 000000000..6df22195e --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'datastore', + filename: './datastore.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From fe76e1acb4ac30f90a4e69b7154b1a1a8073b1c8 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 24 Jun 2022 10:43:44 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- owl-bot-staging/admin/v1/.eslintignore | 7 - owl-bot-staging/admin/v1/.eslintrc.json | 3 - owl-bot-staging/admin/v1/.gitignore | 14 - owl-bot-staging/admin/v1/.jsdoc.js | 55 - owl-bot-staging/admin/v1/.mocharc.js | 33 - owl-bot-staging/admin/v1/.prettierrc.js | 22 - owl-bot-staging/admin/v1/README.md | 1 - .../admin/v1/linkinator.config.json | 16 - owl-bot-staging/admin/v1/package.json | 64 - .../datastore/admin/v1/datastore_admin.proto | 511 ------- .../google/datastore/admin/v1/index.proto | 115 -- .../google/datastore/admin/v1/migration.proto | 124 -- .../v1/datastore_admin.create_index.js | 63 - .../v1/datastore_admin.delete_index.js | 62 - .../v1/datastore_admin.export_entities.js | 86 -- .../generated/v1/datastore_admin.get_index.js | 61 - .../v1/datastore_admin.import_entities.js | 86 -- .../v1/datastore_admin.list_indexes.js | 71 - ...et_metadata.google.datastore.admin.v1.json | 303 ---- owl-bot-staging/admin/v1/src/index.ts | 25 - .../admin/v1/src/v1/datastore_admin_client.ts | 1295 ---------------- .../src/v1/datastore_admin_client_config.json | 56 - .../v1/src/v1/datastore_admin_proto_list.json | 5 - .../admin/v1/src/v1/gapic_metadata.json | 87 -- owl-bot-staging/admin/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - .../admin/v1/system-test/install.ts | 49 - .../admin/v1/test/gapic_datastore_admin_v1.ts | 1357 ----------------- owl-bot-staging/admin/v1/tsconfig.json | 19 - owl-bot-staging/admin/v1/webpack.config.js | 64 - owl-bot-staging/v1/.eslintignore | 7 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 16 - owl-bot-staging/v1/package.json | 64 - .../google/datastore/v1/datastore.proto | 443 ------ .../protos/google/datastore/v1/entity.proto | 214 --- .../v1/protos/google/datastore/v1/query.proto | 375 ----- .../generated/v1/datastore.allocate_ids.js | 64 - .../v1/datastore.begin_transaction.js | 62 - .../samples/generated/v1/datastore.commit.js | 81 - .../samples/generated/v1/datastore.lookup.js | 67 - .../generated/v1/datastore.reserve_ids.js | 68 - .../generated/v1/datastore.rollback.js | 64 - .../generated/v1/datastore.run_query.js | 77 - .../snippet_metadata.google.datastore.v1.json | 351 ----- owl-bot-staging/v1/src/index.ts | 25 - owl-bot-staging/v1/src/v1/datastore_client.ts | 847 ---------- .../v1/src/v1/datastore_client_config.json | 61 - .../v1/src/v1/datastore_proto_list.json | 5 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 93 -- owl-bot-staging/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - owl-bot-staging/v1/system-test/install.ts | 49 - owl-bot-staging/v1/test/gapic_datastore_v1.ts | 814 ---------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - src/v1/datastore_admin_client.ts | 44 +- src/v1/datastore_client.ts | 11 +- 65 files changed, 37 insertions(+), 8886 deletions(-) delete mode 100644 owl-bot-staging/admin/v1/.eslintignore delete mode 100644 owl-bot-staging/admin/v1/.eslintrc.json delete mode 100644 owl-bot-staging/admin/v1/.gitignore delete mode 100644 owl-bot-staging/admin/v1/.jsdoc.js delete mode 100644 owl-bot-staging/admin/v1/.mocharc.js delete mode 100644 owl-bot-staging/admin/v1/.prettierrc.js delete mode 100644 owl-bot-staging/admin/v1/README.md delete mode 100644 owl-bot-staging/admin/v1/linkinator.config.json delete mode 100644 owl-bot-staging/admin/v1/package.json delete mode 100644 owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/datastore_admin.proto delete mode 100644 owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/index.proto delete mode 100644 owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/migration.proto delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.create_index.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.delete_index.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.export_entities.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.get_index.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.import_entities.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.list_indexes.js delete mode 100644 owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json delete mode 100644 owl-bot-staging/admin/v1/src/index.ts delete mode 100644 owl-bot-staging/admin/v1/src/v1/datastore_admin_client.ts delete mode 100644 owl-bot-staging/admin/v1/src/v1/datastore_admin_client_config.json delete mode 100644 owl-bot-staging/admin/v1/src/v1/datastore_admin_proto_list.json delete mode 100644 owl-bot-staging/admin/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/admin/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/admin/v1/system-test/install.ts delete mode 100644 owl-bot-staging/admin/v1/test/gapic_datastore_admin_v1.ts delete mode 100644 owl-bot-staging/admin/v1/tsconfig.json delete mode 100644 owl-bot-staging/admin/v1/webpack.config.js delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/datastore/v1/datastore.proto delete mode 100644 owl-bot-staging/v1/protos/google/datastore/v1/entity.proto delete mode 100644 owl-bot-staging/v1/protos/google/datastore/v1/query.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.allocate_ids.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.begin_transaction.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.commit.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.lookup.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.reserve_ids.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.rollback.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/datastore.run_query.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.datastore.v1.json delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/datastore_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/datastore_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/datastore_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_datastore_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js diff --git a/owl-bot-staging/admin/v1/.eslintignore b/owl-bot-staging/admin/v1/.eslintignore deleted file mode 100644 index cfc348ec4..000000000 --- a/owl-bot-staging/admin/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/admin/v1/.eslintrc.json b/owl-bot-staging/admin/v1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/admin/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/admin/v1/.gitignore b/owl-bot-staging/admin/v1/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/owl-bot-staging/admin/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/admin/v1/.jsdoc.js b/owl-bot-staging/admin/v1/.jsdoc.js deleted file mode 100644 index 702ded023..000000000 --- a/owl-bot-staging/admin/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/datastore-admin', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/admin/v1/.mocharc.js b/owl-bot-staging/admin/v1/.mocharc.js deleted file mode 100644 index 481c522b0..000000000 --- a/owl-bot-staging/admin/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/admin/v1/.prettierrc.js b/owl-bot-staging/admin/v1/.prettierrc.js deleted file mode 100644 index 494e14786..000000000 --- a/owl-bot-staging/admin/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/admin/v1/README.md b/owl-bot-staging/admin/v1/README.md deleted file mode 100644 index 5d45b74ed..000000000 --- a/owl-bot-staging/admin/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Admin: Nodejs Client diff --git a/owl-bot-staging/admin/v1/linkinator.config.json b/owl-bot-staging/admin/v1/linkinator.config.json deleted file mode 100644 index befd23c86..000000000 --- a/owl-bot-staging/admin/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/admin/v1/package.json b/owl-bot-staging/admin/v1/package.json deleted file mode 100644 index 6d499920d..000000000 --- a/owl-bot-staging/admin/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/datastore-admin", - "version": "0.1.0", - "description": "Admin client for Node.js", - "repository": "googleapis/nodejs-admin", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google admin", - "admin", - "datastore admin" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.1.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/datastore_admin.proto b/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/datastore_admin.proto deleted file mode 100644 index 0d624956e..000000000 --- a/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/datastore_admin.proto +++ /dev/null @@ -1,511 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.datastore.admin.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/datastore/admin/v1/index.proto"; -import "google/datastore/admin/v1/migration.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/admin/v1;admin"; -option java_multiple_files = true; -option java_outer_classname = "DatastoreAdminProto"; -option java_package = "com.google.datastore.admin.v1"; -option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; -option ruby_package = "Google::Cloud::Datastore::Admin::V1"; - -// Google Cloud Datastore Admin API -// -// -// The Datastore Admin API provides several admin services for Cloud Datastore. -// -// ----------------------------------------------------------------------------- -// ## Concepts -// -// Project, namespace, kind, and entity as defined in the Google Cloud Datastore -// API. -// -// Operation: An Operation represents work being performed in the background. -// -// EntityFilter: Allows specifying a subset of entities in a project. This is -// specified as a combination of kinds and namespaces (either or both of which -// may be all). -// -// ----------------------------------------------------------------------------- -// ## Services -// -// # Export/Import -// -// The Export/Import service provides the ability to copy all or a subset of -// entities to/from Google Cloud Storage. -// -// Exported data may be imported into Cloud Datastore for any Google Cloud -// Platform project. It is not restricted to the export source project. It is -// possible to export from one project and then import into another. -// -// Exported data can also be loaded into Google BigQuery for analysis. -// -// Exports and imports are performed asynchronously. An Operation resource is -// created for each export/import. The state (including any errors encountered) -// of the export/import may be queried via the Operation resource. -// -// # Index -// -// The index service manages Cloud Datastore composite indexes. -// -// Index creation and deletion are performed asynchronously. -// An Operation resource is created for each such asynchronous operation. -// The state of the operation (including any errors encountered) -// may be queried via the Operation resource. -// -// # Operation -// -// The Operations collection provides a record of actions performed for the -// specified project (including any operations in progress). Operations are not -// created directly but through calls on other collections or resources. -// -// An operation that is not yet done may be cancelled. The request to cancel is -// asynchronous and the operation may continue to run for some time after the -// request to cancel is made. -// -// An operation that is done may be deleted so that it is no longer listed as -// part of the Operation collection. -// -// ListOperations returns all pending operations, but not completed operations. -// -// Operations are created by service DatastoreAdmin, -// but are accessed via service google.longrunning.Operations. -service DatastoreAdmin { - 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"; - - // Exports a copy of all or a subset of entities from Google Cloud Datastore - // to another storage system, such as Google Cloud Storage. Recent updates to - // entities may not be reflected in the export. The export occurs in the - // background and its progress can be monitored and managed via the - // Operation resource that is created. The output of an export may only be - // used once the associated operation is done. If an export operation is - // cancelled before completion it may leave partial data behind in Google - // Cloud Storage. - rpc ExportEntities(ExportEntitiesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/projects/{project_id}:export" - body: "*" - }; - option (google.api.method_signature) = "project_id,labels,entity_filter,output_url_prefix"; - option (google.longrunning.operation_info) = { - response_type: "ExportEntitiesResponse" - metadata_type: "ExportEntitiesMetadata" - }; - } - - // Imports entities into Google Cloud Datastore. Existing entities with the - // same key are overwritten. The import occurs in the background and its - // progress can be monitored and managed via the Operation resource that is - // created. If an ImportEntities operation is cancelled, it is possible - // that a subset of the data has already been imported to Cloud Datastore. - rpc ImportEntities(ImportEntitiesRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/projects/{project_id}:import" - body: "*" - }; - option (google.api.method_signature) = "project_id,labels,input_url,entity_filter"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "ImportEntitiesMetadata" - }; - } - - // Creates the specified index. - // A newly created index's initial state is `CREATING`. On completion of the - // returned [google.longrunning.Operation][google.longrunning.Operation], the state will be `READY`. - // If the index already exists, the call will return an `ALREADY_EXISTS` - // status. - // - // During index creation, the process could result in an error, in which - // case the index will move to the `ERROR` state. The process can be recovered - // by fixing the data that caused the error, removing the index with - // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then - // re-creating the index with [create] - // [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. - // - // Indexes with a single property cannot be created. - rpc CreateIndex(CreateIndexRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v1/projects/{project_id}/indexes" - body: "index" - }; - option (google.longrunning.operation_info) = { - response_type: "Index" - metadata_type: "IndexOperationMetadata" - }; - } - - // Deletes an existing index. - // An index can only be deleted if it is in a `READY` or `ERROR` state. On - // successful execution of the request, the index will be in a `DELETING` - // [state][google.datastore.admin.v1.Index.State]. And on completion of the - // returned [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. - // - // During index deletion, the process could result in an error, in which - // case the index will move to the `ERROR` state. The process can be recovered - // by fixing the data that caused the error, followed by calling - // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again. - rpc DeleteIndex(DeleteIndexRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v1/projects/{project_id}/indexes/{index_id}" - }; - option (google.longrunning.operation_info) = { - response_type: "Index" - metadata_type: "IndexOperationMetadata" - }; - } - - // Gets an index. - rpc GetIndex(GetIndexRequest) returns (Index) { - option (google.api.http) = { - get: "/v1/projects/{project_id}/indexes/{index_id}" - }; - } - - // Lists the indexes that match the specified filters. Datastore uses an - // eventually consistent query to fetch the list of indexes and may - // occasionally return stale results. - rpc ListIndexes(ListIndexesRequest) returns (ListIndexesResponse) { - option (google.api.http) = { - get: "/v1/projects/{project_id}/indexes" - }; - } -} - -// Metadata common to all Datastore Admin operations. -message CommonMetadata { - // The various possible states for an ongoing Operation. - enum State { - // Unspecified. - STATE_UNSPECIFIED = 0; - - // Request is being prepared for processing. - INITIALIZING = 1; - - // Request is actively being processed. - PROCESSING = 2; - - // Request is in the process of being cancelled after user called - // google.longrunning.Operations.CancelOperation on the operation. - CANCELLING = 3; - - // Request has been processed and is in its finalization stage. - FINALIZING = 4; - - // Request has completed successfully. - SUCCESSFUL = 5; - - // Request has finished being processed, but encountered an error. - FAILED = 6; - - // Request has finished being cancelled after user called - // google.longrunning.Operations.CancelOperation. - CANCELLED = 7; - } - - // The time that work began on the operation. - google.protobuf.Timestamp start_time = 1; - - // The time the operation ended, either successfully or otherwise. - google.protobuf.Timestamp end_time = 2; - - // The type of the operation. Can be used as a filter in - // ListOperationsRequest. - OperationType operation_type = 3; - - // The client-assigned labels which were provided when the operation was - // created. May also include additional labels. - map labels = 4; - - // The current state of the Operation. - State state = 5; -} - -// Measures the progress of a particular metric. -message Progress { - // The amount of work that has been completed. Note that this may be greater - // than work_estimated. - int64 work_completed = 1; - - // An estimate of how much work needs to be performed. May be zero if the - // work estimate is unavailable. - int64 work_estimated = 2; -} - -// The request for -// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. -message ExportEntitiesRequest { - // Required. Project ID against which to make the request. - string project_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Client-assigned labels. - map labels = 2; - - // Description of what data from the project is included in the export. - EntityFilter entity_filter = 3; - - // Required. Location for the export metadata and data files. - // - // The full resource URL of the external storage location. Currently, only - // Google Cloud Storage is supported. So output_url_prefix should be of the - // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the - // name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud - // Storage namespace path (this is not a Cloud Datastore namespace). For more - // information about Cloud Storage namespace paths, see - // [Object name - // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). - // - // The resulting files will be nested deeper than the specified URL prefix. - // The final output URL will be provided in the - // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] field. That - // value should be used for subsequent ImportEntities operations. - // - // By nesting the data files deeper, the same Cloud Storage bucket can be used - // in multiple ExportEntities operations without conflict. - string output_url_prefix = 4 [(google.api.field_behavior) = REQUIRED]; -} - -// The request for -// [google.datastore.admin.v1.DatastoreAdmin.ImportEntities][google.datastore.admin.v1.DatastoreAdmin.ImportEntities]. -message ImportEntitiesRequest { - // Required. Project ID against which to make the request. - string project_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Client-assigned labels. - map labels = 2; - - // Required. The full resource URL of the external storage location. Currently, only - // Google Cloud Storage is supported. So input_url should be of the form: - // `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where - // `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is - // an optional Cloud Storage namespace path (this is not a Cloud Datastore - // namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written - // by the ExportEntities operation. For more information about Cloud Storage - // namespace paths, see - // [Object name - // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). - // - // For more information, see - // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. - string input_url = 3 [(google.api.field_behavior) = REQUIRED]; - - // Optionally specify which kinds/namespaces are to be imported. If provided, - // the list must be a subset of the EntityFilter used in creating the export, - // otherwise a FAILED_PRECONDITION error will be returned. If no filter is - // specified then all entities from the export are imported. - EntityFilter entity_filter = 4; -} - -// The response for -// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. -message ExportEntitiesResponse { - // Location of the output metadata file. This can be used to begin an import - // into Cloud Datastore (this project or another project). See - // [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url]. - // Only present if the operation completed successfully. - string output_url = 1; -} - -// Metadata for ExportEntities operations. -message ExportEntitiesMetadata { - // Metadata common to all Datastore Admin operations. - CommonMetadata common = 1; - - // An estimate of the number of entities processed. - Progress progress_entities = 2; - - // An estimate of the number of bytes processed. - Progress progress_bytes = 3; - - // Description of which entities are being exported. - EntityFilter entity_filter = 4; - - // Location for the export metadata and data files. This will be the same - // value as the - // [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix] - // field. The final output location is provided in - // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. - string output_url_prefix = 5; -} - -// Metadata for ImportEntities operations. -message ImportEntitiesMetadata { - // Metadata common to all Datastore Admin operations. - CommonMetadata common = 1; - - // An estimate of the number of entities processed. - Progress progress_entities = 2; - - // An estimate of the number of bytes processed. - Progress progress_bytes = 3; - - // Description of which entities are being imported. - EntityFilter entity_filter = 4; - - // The location of the import metadata file. This will be the same value as - // the [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] field. - string input_url = 5; -} - -// Identifies a subset of entities in a project. This is specified as -// combinations of kinds and namespaces (either or both of which may be all, as -// described in the following examples). -// Example usage: -// -// Entire project: -// kinds=[], namespace_ids=[] -// -// Kinds Foo and Bar in all namespaces: -// kinds=['Foo', 'Bar'], namespace_ids=[] -// -// Kinds Foo and Bar only in the default namespace: -// kinds=['Foo', 'Bar'], namespace_ids=[''] -// -// Kinds Foo and Bar in both the default and Baz namespaces: -// kinds=['Foo', 'Bar'], namespace_ids=['', 'Baz'] -// -// The entire Baz namespace: -// kinds=[], namespace_ids=['Baz'] -message EntityFilter { - // If empty, then this represents all kinds. - repeated string kinds = 1; - - // An empty list represents all namespaces. This is the preferred - // usage for projects that don't use namespaces. - // - // An empty string element represents the default namespace. This should be - // used if the project has data in non-default namespaces, but doesn't want to - // include them. - // Each namespace in this list must be unique. - repeated string namespace_ids = 2; -} - -// The request for -// [google.datastore.admin.v1.DatastoreAdmin.CreateIndex][google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. -message CreateIndexRequest { - // Project ID against which to make the request. - string project_id = 1; - - // The index to create. The name and state fields are output only and will be - // ignored. Single property indexes cannot be created or deleted. - Index index = 3; -} - -// The request for -// [google.datastore.admin.v1.DatastoreAdmin.DeleteIndex][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex]. -message DeleteIndexRequest { - // Project ID against which to make the request. - string project_id = 1; - - // The resource ID of the index to delete. - string index_id = 3; -} - -// The request for [google.datastore.admin.v1.DatastoreAdmin.GetIndex][google.datastore.admin.v1.DatastoreAdmin.GetIndex]. -message GetIndexRequest { - // Project ID against which to make the request. - string project_id = 1; - - // The resource ID of the index to get. - string index_id = 3; -} - -// The request for -// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. -message ListIndexesRequest { - // Project ID against which to make the request. - string project_id = 1; - - string filter = 3; - - // The maximum number of items to return. If zero, then all results will be - // returned. - int32 page_size = 4; - - // The next_page_token value returned from a previous List request, if any. - string page_token = 5; -} - -// The response for -// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. -message ListIndexesResponse { - // The indexes. - repeated Index indexes = 1; - - // The standard List next-page token. - string next_page_token = 2; -} - -// Metadata for Index operations. -message IndexOperationMetadata { - // Metadata common to all Datastore Admin operations. - CommonMetadata common = 1; - - // An estimate of the number of entities processed. - Progress progress_entities = 2; - - // The index resource ID that this operation is acting on. - string index_id = 3; -} - -// Metadata for Datastore to Firestore migration operations. -// -// The DatastoreFirestoreMigration operation is not started by the end-user via -// an explicit "creation" method. This is an intentional deviation from the LRO -// design pattern. -// -// This singleton resource can be accessed at: -// "projects/{project_id}/operations/datastore-firestore-migration" -message DatastoreFirestoreMigrationMetadata { - // The current state of migration from Cloud Datastore to Cloud Firestore in - // Datastore mode. - MigrationState migration_state = 1; - - // The current step of migration from Cloud Datastore to Cloud Firestore in - // Datastore mode. - MigrationStep migration_step = 2; -} - -// Operation types. -enum OperationType { - // Unspecified. - OPERATION_TYPE_UNSPECIFIED = 0; - - // ExportEntities. - EXPORT_ENTITIES = 1; - - // ImportEntities. - IMPORT_ENTITIES = 2; - - // CreateIndex. - CREATE_INDEX = 3; - - // DeleteIndex. - DELETE_INDEX = 4; -} diff --git a/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/index.proto b/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/index.proto deleted file mode 100644 index 0162af523..000000000 --- a/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/index.proto +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.datastore.admin.v1; - -import "google/api/field_behavior.proto"; - -option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/admin/v1;admin"; -option java_multiple_files = true; -option java_outer_classname = "IndexProto"; -option java_package = "com.google.datastore.admin.v1"; -option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; -option ruby_package = "Google::Cloud::Datastore::Admin::V1"; - -// Datastore composite index definition. -message Index { - // For an ordered index, specifies whether each of the entity's ancestors - // will be included. - enum AncestorMode { - // The ancestor mode is unspecified. - ANCESTOR_MODE_UNSPECIFIED = 0; - - // Do not include the entity's ancestors in the index. - NONE = 1; - - // Include all the entity's ancestors in the index. - ALL_ANCESTORS = 2; - } - - // The direction determines how a property is indexed. - enum Direction { - // The direction is unspecified. - DIRECTION_UNSPECIFIED = 0; - - // The property's values are indexed so as to support sequencing in - // ascending order and also query by <, >, <=, >=, and =. - ASCENDING = 1; - - // The property's values are indexed so as to support sequencing in - // descending order and also query by <, >, <=, >=, and =. - DESCENDING = 2; - } - - // A property of an index. - message IndexedProperty { - // Required. The property name to index. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The indexed property's direction. Must not be DIRECTION_UNSPECIFIED. - Direction direction = 2 [(google.api.field_behavior) = REQUIRED]; - } - - // The possible set of states of an index. - enum State { - // The state is unspecified. - STATE_UNSPECIFIED = 0; - - // The index is being created, and cannot be used by queries. - // There is an active long-running operation for the index. - // The index is updated when writing an entity. - // Some index data may exist. - CREATING = 1; - - // The index is ready to be used. - // The index is updated when writing an entity. - // The index is fully populated from all stored entities it applies to. - READY = 2; - - // The index is being deleted, and cannot be used by queries. - // There is an active long-running operation for the index. - // The index is not updated when writing an entity. - // Some index data may exist. - DELETING = 3; - - // The index was being created or deleted, but something went wrong. - // The index cannot by used by queries. - // There is no active long-running operation for the index, - // and the most recently finished long-running operation failed. - // The index is not updated when writing an entity. - // Some index data may exist. - ERROR = 4; - } - - // Output only. Project ID. - string project_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The resource ID of the index. - string index_id = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The entity kind to which this index applies. - string kind = 4 [(google.api.field_behavior) = REQUIRED]; - - // Required. The index's ancestor mode. Must not be ANCESTOR_MODE_UNSPECIFIED. - AncestorMode ancestor = 5 [(google.api.field_behavior) = REQUIRED]; - - // Required. An ordered sequence of property names and their index attributes. - repeated IndexedProperty properties = 6 [(google.api.field_behavior) = REQUIRED]; - - // Output only. The state of the index. - State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/migration.proto b/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/migration.proto deleted file mode 100644 index dbbe473c9..000000000 --- a/owl-bot-staging/admin/v1/protos/google/datastore/admin/v1/migration.proto +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.datastore.admin.v1; - -option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/admin/v1;admin"; -option java_multiple_files = true; -option java_outer_classname = "MigrationProto"; -option java_package = "com.google.datastore.admin.v1"; -option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; -option ruby_package = "Google::Cloud::Datastore::Admin::V1"; - -// An event signifying a change in state of a [migration from Cloud Datastore to -// Cloud Firestore in Datastore -// mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore). -message MigrationStateEvent { - // The new state of the migration. - MigrationState state = 1; -} - -// An event signifying the start of a new step in a [migration from Cloud -// Datastore to Cloud Firestore in Datastore -// mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore). -message MigrationProgressEvent { - // Concurrency modes for transactions in Cloud Firestore. - enum ConcurrencyMode { - // Unspecified. - CONCURRENCY_MODE_UNSPECIFIED = 0; - - // Pessimistic concurrency. - PESSIMISTIC = 1; - - // Optimistic concurrency. - OPTIMISTIC = 2; - - // Optimistic concurrency with entity groups. - OPTIMISTIC_WITH_ENTITY_GROUPS = 3; - } - - // Details for the `PREPARE` step. - message PrepareStepDetails { - // The concurrency mode this database will use when it reaches the - // `REDIRECT_WRITES` step. - ConcurrencyMode concurrency_mode = 1; - } - - // Details for the `REDIRECT_WRITES` step. - message RedirectWritesStepDetails { - // Ths concurrency mode for this database. - ConcurrencyMode concurrency_mode = 1; - } - - // The step that is starting. - // - // An event with step set to `START` indicates that the migration - // has been reverted back to the initial pre-migration state. - MigrationStep step = 1; - - // Details about this step. - oneof step_details { - // Details for the `PREPARE` step. - PrepareStepDetails prepare_step_details = 2; - - // Details for the `REDIRECT_WRITES` step. - RedirectWritesStepDetails redirect_writes_step_details = 3; - } -} - -// States for a migration. -enum MigrationState { - // Unspecified. - MIGRATION_STATE_UNSPECIFIED = 0; - - // The migration is running. - RUNNING = 1; - - // The migration is paused. - PAUSED = 2; - - // The migration is complete. - COMPLETE = 3; -} - -// Steps in a migration. -enum MigrationStep { - // Unspecified. - MIGRATION_STEP_UNSPECIFIED = 0; - - // Pre-migration: the database is prepared for migration. - PREPARE = 6; - - // Start of migration. - START = 1; - - // Writes are applied synchronously to at least one replica. - APPLY_WRITES_SYNCHRONOUSLY = 7; - - // Data is copied to Cloud Firestore and then verified to match the data in - // Cloud Datastore. - COPY_AND_VERIFY = 2; - - // Eventually-consistent reads are redirected to Cloud Firestore. - REDIRECT_EVENTUALLY_CONSISTENT_READS = 3; - - // Strongly-consistent reads are redirected to Cloud Firestore. - REDIRECT_STRONGLY_CONSISTENT_READS = 4; - - // Writes are redirected to Cloud Firestore. - REDIRECT_WRITES = 5; -} diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.create_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.create_index.js deleted file mode 100644 index 25a4e7008..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.create_index.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START datastore_v1_generated_DatastoreAdmin_CreateIndex_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Project ID against which to make the request. - */ - // const projectId = 'abc123' - /** - * The index to create. The name and state fields are output only and will be - * ignored. Single property indexes cannot be created or deleted. - */ - // const index = {} - - // Imports the Admin library - const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; - - // Instantiates a client - const adminClient = new DatastoreAdminClient(); - - async function callCreateIndex() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await adminClient.createIndex(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateIndex(); - // [END datastore_v1_generated_DatastoreAdmin_CreateIndex_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.delete_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.delete_index.js deleted file mode 100644 index ada02df71..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.delete_index.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START datastore_v1_generated_DatastoreAdmin_DeleteIndex_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Project ID against which to make the request. - */ - // const projectId = 'abc123' - /** - * The resource ID of the index to delete. - */ - // const indexId = 'abc123' - - // Imports the Admin library - const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; - - // Instantiates a client - const adminClient = new DatastoreAdminClient(); - - async function callDeleteIndex() { - // Construct request - const request = { - }; - - // Run request - const [operation] = await adminClient.deleteIndex(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteIndex(); - // [END datastore_v1_generated_DatastoreAdmin_DeleteIndex_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.export_entities.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.export_entities.js deleted file mode 100644 index 81b946e65..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.export_entities.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(projectId, outputUrlPrefix) { - // [START datastore_v1_generated_DatastoreAdmin_ExportEntities_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Project ID against which to make the request. - */ - // const projectId = 'abc123' - /** - * Client-assigned labels. - */ - // const labels = 1234 - /** - * Description of what data from the project is included in the export. - */ - // const entityFilter = {} - /** - * Required. Location for the export metadata and data files. - * The full resource URL of the external storage location. Currently, only - * Google Cloud Storage is supported. So output_url_prefix should be of the - * form: `gs://BUCKET_NAME/NAMESPACE_PATH`, where `BUCKET_NAME` is the - * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud - * Storage namespace path (this is not a Cloud Datastore namespace). For more - * information about Cloud Storage namespace paths, see - * Object name - * considerations (https://cloud.google.com/storage/docs/naming#object-considerations). - * The resulting files will be nested deeper than the specified URL prefix. - * The final output URL will be provided in the - * google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url field. That - * value should be used for subsequent ImportEntities operations. - * By nesting the data files deeper, the same Cloud Storage bucket can be used - * in multiple ExportEntities operations without conflict. - */ - // const outputUrlPrefix = 'abc123' - - // Imports the Admin library - const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; - - // Instantiates a client - const adminClient = new DatastoreAdminClient(); - - async function callExportEntities() { - // Construct request - const request = { - projectId, - outputUrlPrefix, - }; - - // Run request - const [operation] = await adminClient.exportEntities(request); - const [response] = await operation.promise(); - console.log(response); - } - - callExportEntities(); - // [END datastore_v1_generated_DatastoreAdmin_ExportEntities_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.get_index.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.get_index.js deleted file mode 100644 index ae88c96af..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.get_index.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START datastore_v1_generated_DatastoreAdmin_GetIndex_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Project ID against which to make the request. - */ - // const projectId = 'abc123' - /** - * The resource ID of the index to get. - */ - // const indexId = 'abc123' - - // Imports the Admin library - const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; - - // Instantiates a client - const adminClient = new DatastoreAdminClient(); - - async function callGetIndex() { - // Construct request - const request = { - }; - - // Run request - const response = await adminClient.getIndex(request); - console.log(response); - } - - callGetIndex(); - // [END datastore_v1_generated_DatastoreAdmin_GetIndex_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.import_entities.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.import_entities.js deleted file mode 100644 index d2d3e53f9..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.import_entities.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(projectId, inputUrl) { - // [START datastore_v1_generated_DatastoreAdmin_ImportEntities_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Project ID against which to make the request. - */ - // const projectId = 'abc123' - /** - * Client-assigned labels. - */ - // const labels = 1234 - /** - * Required. The full resource URL of the external storage location. Currently, only - * Google Cloud Storage is supported. So input_url should be of the form: - * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where - * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is - * an optional Cloud Storage namespace path (this is not a Cloud Datastore - * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written - * by the ExportEntities operation. For more information about Cloud Storage - * namespace paths, see - * Object name - * considerations (https://cloud.google.com/storage/docs/naming#object-considerations). - * For more information, see - * google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url. - */ - // const inputUrl = 'abc123' - /** - * Optionally specify which kinds/namespaces are to be imported. If provided, - * the list must be a subset of the EntityFilter used in creating the export, - * otherwise a FAILED_PRECONDITION error will be returned. If no filter is - * specified then all entities from the export are imported. - */ - // const entityFilter = {} - - // Imports the Admin library - const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; - - // Instantiates a client - const adminClient = new DatastoreAdminClient(); - - async function callImportEntities() { - // Construct request - const request = { - projectId, - inputUrl, - }; - - // Run request - const [operation] = await adminClient.importEntities(request); - const [response] = await operation.promise(); - console.log(response); - } - - callImportEntities(); - // [END datastore_v1_generated_DatastoreAdmin_ImportEntities_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.list_indexes.js b/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.list_indexes.js deleted file mode 100644 index e47f17381..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/datastore_admin.list_indexes.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main() { - // [START datastore_v1_generated_DatastoreAdmin_ListIndexes_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Project ID against which to make the request. - */ - // const projectId = 'abc123' - /** - */ - // const filter = 'abc123' - /** - * The maximum number of items to return. If zero, then all results will be - * returned. - */ - // const pageSize = 1234 - /** - * The next_page_token value returned from a previous List request, if any. - */ - // const pageToken = 'abc123' - - // Imports the Admin library - const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; - - // Instantiates a client - const adminClient = new DatastoreAdminClient(); - - async function callListIndexes() { - // Construct request - const request = { - }; - - // Run request - const iterable = await adminClient.listIndexesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListIndexes(); - // [END datastore_v1_generated_DatastoreAdmin_ListIndexes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json b/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json deleted file mode 100644 index e2bbccc60..000000000 --- a/owl-bot-staging/admin/v1/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json +++ /dev/null @@ -1,303 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-admin", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.datastore.admin.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "datastore_v1_generated_DatastoreAdmin_ExportEntities_async", - "title": "DatastoreAdmin exportEntities Sample", - "origin": "API_DEFINITION", - "description": " Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage. Recent updates to entities may not be reflected in the export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage.", - "canonical": true, - "file": "datastore_admin.export_entities.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ExportEntities", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.ExportEntities", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "entity_filter", - "type": ".google.datastore.admin.v1.EntityFilter" - }, - { - "name": "output_url_prefix", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DatastoreAdminClient", - "fullName": "google.datastore.admin.v1.DatastoreAdminClient" - }, - "method": { - "shortName": "ExportEntities", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.ExportEntities", - "service": { - "shortName": "DatastoreAdmin", - "fullName": "google.datastore.admin.v1.DatastoreAdmin" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_DatastoreAdmin_ImportEntities_async", - "title": "DatastoreAdmin importEntities Sample", - "origin": "API_DEFINITION", - "description": " Imports entities into Google Cloud Datastore. Existing entities with the same key are overwritten. The import occurs in the background and its progress can be monitored and managed via the Operation resource that is created. If an ImportEntities operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Datastore.", - "canonical": true, - "file": "datastore_admin.import_entities.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 78, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ImportEntities", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.ImportEntities", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "input_url", - "type": "TYPE_STRING" - }, - { - "name": "entity_filter", - "type": ".google.datastore.admin.v1.EntityFilter" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DatastoreAdminClient", - "fullName": "google.datastore.admin.v1.DatastoreAdminClient" - }, - "method": { - "shortName": "ImportEntities", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.ImportEntities", - "service": { - "shortName": "DatastoreAdmin", - "fullName": "google.datastore.admin.v1.DatastoreAdmin" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_DatastoreAdmin_CreateIndex_async", - "title": "DatastoreAdmin createIndex Sample", - "origin": "API_DEFINITION", - "description": " Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. During index creation, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. Indexes with a single property cannot be created.", - "canonical": true, - "file": "datastore_admin.create_index.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateIndex", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.CreateIndex", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "index", - "type": ".google.datastore.admin.v1.Index" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DatastoreAdminClient", - "fullName": "google.datastore.admin.v1.DatastoreAdminClient" - }, - "method": { - "shortName": "CreateIndex", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.CreateIndex", - "service": { - "shortName": "DatastoreAdmin", - "fullName": "google.datastore.admin.v1.DatastoreAdmin" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_DatastoreAdmin_DeleteIndex_async", - "title": "DatastoreAdmin deleteIndex Sample", - "origin": "API_DEFINITION", - "description": " Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. On successful execution of the request, the index will be in a `DELETING` [state][google.datastore.admin.v1.Index.State]. And on completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. During index deletion, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.", - "canonical": true, - "file": "datastore_admin.delete_index.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteIndex", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.DeleteIndex", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "index_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "DatastoreAdminClient", - "fullName": "google.datastore.admin.v1.DatastoreAdminClient" - }, - "method": { - "shortName": "DeleteIndex", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.DeleteIndex", - "service": { - "shortName": "DatastoreAdmin", - "fullName": "google.datastore.admin.v1.DatastoreAdmin" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_DatastoreAdmin_GetIndex_async", - "title": "DatastoreAdmin getIndex Sample", - "origin": "API_DEFINITION", - "description": " Gets an index.", - "canonical": true, - "file": "datastore_admin.get_index.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIndex", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.GetIndex", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "index_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.datastore.admin.v1.Index", - "client": { - "shortName": "DatastoreAdminClient", - "fullName": "google.datastore.admin.v1.DatastoreAdminClient" - }, - "method": { - "shortName": "GetIndex", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.GetIndex", - "service": { - "shortName": "DatastoreAdmin", - "fullName": "google.datastore.admin.v1.DatastoreAdmin" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_DatastoreAdmin_ListIndexes_async", - "title": "DatastoreAdmin listIndexes Sample", - "origin": "API_DEFINITION", - "description": " Lists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.", - "canonical": true, - "file": "datastore_admin.list_indexes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListIndexes", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.ListIndexes", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "filter", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.datastore.admin.v1.ListIndexesResponse", - "client": { - "shortName": "DatastoreAdminClient", - "fullName": "google.datastore.admin.v1.DatastoreAdminClient" - }, - "method": { - "shortName": "ListIndexes", - "fullName": "google.datastore.admin.v1.DatastoreAdmin.ListIndexes", - "service": { - "shortName": "DatastoreAdmin", - "fullName": "google.datastore.admin.v1.DatastoreAdmin" - } - } - } - } - ] -} diff --git a/owl-bot-staging/admin/v1/src/index.ts b/owl-bot-staging/admin/v1/src/index.ts deleted file mode 100644 index 85a09fe29..000000000 --- a/owl-bot-staging/admin/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const DatastoreAdminClient = v1.DatastoreAdminClient; -type DatastoreAdminClient = v1.DatastoreAdminClient; -export {v1, DatastoreAdminClient}; -export default {v1, DatastoreAdminClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/admin/v1/src/v1/datastore_admin_client.ts b/owl-bot-staging/admin/v1/src/v1/datastore_admin_client.ts deleted file mode 100644 index 5e82ab3fb..000000000 --- a/owl-bot-staging/admin/v1/src/v1/datastore_admin_client.ts +++ /dev/null @@ -1,1295 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/datastore_admin_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './datastore_admin_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Google Cloud Datastore Admin API - * - * - * The Datastore Admin API provides several admin services for Cloud Datastore. - * - * ----------------------------------------------------------------------------- - * ## Concepts - * - * Project, namespace, kind, and entity as defined in the Google Cloud Datastore - * API. - * - * Operation: An Operation represents work being performed in the background. - * - * EntityFilter: Allows specifying a subset of entities in a project. This is - * specified as a combination of kinds and namespaces (either or both of which - * may be all). - * - * ----------------------------------------------------------------------------- - * ## Services - * - * # Export/Import - * - * The Export/Import service provides the ability to copy all or a subset of - * entities to/from Google Cloud Storage. - * - * Exported data may be imported into Cloud Datastore for any Google Cloud - * Platform project. It is not restricted to the export source project. It is - * possible to export from one project and then import into another. - * - * Exported data can also be loaded into Google BigQuery for analysis. - * - * Exports and imports are performed asynchronously. An Operation resource is - * created for each export/import. The state (including any errors encountered) - * of the export/import may be queried via the Operation resource. - * - * # Index - * - * The index service manages Cloud Datastore composite indexes. - * - * Index creation and deletion are performed asynchronously. - * An Operation resource is created for each such asynchronous operation. - * The state of the operation (including any errors encountered) - * may be queried via the Operation resource. - * - * # Operation - * - * The Operations collection provides a record of actions performed for the - * specified project (including any operations in progress). Operations are not - * created directly but through calls on other collections or resources. - * - * An operation that is not yet done may be cancelled. The request to cancel is - * asynchronous and the operation may continue to run for some time after the - * request to cancel is made. - * - * An operation that is done may be deleted so that it is no longer listed as - * part of the Operation collection. - * - * ListOperations returns all pending operations, but not completed operations. - * - * Operations are created by service DatastoreAdmin, - * but are accessed via service google.longrunning.Operations. - * @class - * @memberof v1 - */ -export class DatastoreAdminClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - operationsClient: gax.OperationsClient; - datastoreAdminStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DatastoreAdminClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DatastoreAdminClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listIndexes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'indexes') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{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',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const exportEntitiesResponse = protoFilesRoot.lookup( - '.google.datastore.admin.v1.ExportEntitiesResponse') as gax.protobuf.Type; - const exportEntitiesMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.ExportEntitiesMetadata') as gax.protobuf.Type; - const importEntitiesResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const importEntitiesMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.ImportEntitiesMetadata') as gax.protobuf.Type; - const createIndexResponse = protoFilesRoot.lookup( - '.google.datastore.admin.v1.Index') as gax.protobuf.Type; - const createIndexMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.IndexOperationMetadata') as gax.protobuf.Type; - const deleteIndexResponse = protoFilesRoot.lookup( - '.google.datastore.admin.v1.Index') as gax.protobuf.Type; - const deleteIndexMetadata = protoFilesRoot.lookup( - '.google.datastore.admin.v1.IndexOperationMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - exportEntities: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - exportEntitiesResponse.decode.bind(exportEntitiesResponse), - exportEntitiesMetadata.decode.bind(exportEntitiesMetadata)), - importEntities: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - importEntitiesResponse.decode.bind(importEntitiesResponse), - importEntitiesMetadata.decode.bind(importEntitiesMetadata)), - createIndex: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createIndexResponse.decode.bind(createIndexResponse), - createIndexMetadata.decode.bind(createIndexMetadata)), - deleteIndex: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteIndexResponse.decode.bind(deleteIndexResponse), - deleteIndexMetadata.decode.bind(deleteIndexMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.datastore.admin.v1.DatastoreAdmin', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.datastoreAdminStub) { - return this.datastoreAdminStub; - } - - // Put together the "service stub" for - // google.datastore.admin.v1.DatastoreAdmin. - this.datastoreAdminStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.datastore.admin.v1.DatastoreAdmin') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.datastore.admin.v1.DatastoreAdmin, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const datastoreAdminStubMethods = - ['exportEntities', 'importEntities', 'createIndex', 'deleteIndex', 'getIndex', 'listIndexes']; - for (const methodName of datastoreAdminStubMethods) { - const callPromise = this.datastoreAdminStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.datastoreAdminStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'datastore.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'datastore.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Gets an index. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Project ID against which to make the request. - * @param {string} request.indexId - * The resource ID of the index to get. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Index]{@link google.datastore.admin.v1.Index}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.get_index.js - * region_tag:datastore_v1_generated_DatastoreAdmin_GetIndex_async - */ - getIndex( - request?: protos.google.datastore.admin.v1.IGetIndexRequest, - options?: CallOptions): - Promise<[ - protos.google.datastore.admin.v1.IIndex, - protos.google.datastore.admin.v1.IGetIndexRequest|undefined, {}|undefined - ]>; - getIndex( - request: protos.google.datastore.admin.v1.IGetIndexRequest, - options: CallOptions, - callback: Callback< - protos.google.datastore.admin.v1.IIndex, - protos.google.datastore.admin.v1.IGetIndexRequest|null|undefined, - {}|null|undefined>): void; - getIndex( - request: protos.google.datastore.admin.v1.IGetIndexRequest, - callback: Callback< - protos.google.datastore.admin.v1.IIndex, - protos.google.datastore.admin.v1.IGetIndexRequest|null|undefined, - {}|null|undefined>): void; - getIndex( - request?: protos.google.datastore.admin.v1.IGetIndexRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.datastore.admin.v1.IIndex, - protos.google.datastore.admin.v1.IGetIndexRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.datastore.admin.v1.IIndex, - protos.google.datastore.admin.v1.IGetIndexRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.datastore.admin.v1.IIndex, - protos.google.datastore.admin.v1.IGetIndexRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - 'index_id': request.indexId || '', - }); - this.initialize(); - return this.innerApiCalls.getIndex(request, options, callback); - } - -/** - * Exports a copy of all or a subset of entities from Google Cloud Datastore - * to another storage system, such as Google Cloud Storage. Recent updates to - * entities may not be reflected in the export. The export occurs in the - * background and its progress can be monitored and managed via the - * Operation resource that is created. The output of an export may only be - * used once the associated operation is done. If an export operation is - * cancelled before completion it may leave partial data behind in Google - * Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Required. Project ID against which to make the request. - * @param {number[]} request.labels - * Client-assigned labels. - * @param {google.datastore.admin.v1.EntityFilter} request.entityFilter - * Description of what data from the project is included in the export. - * @param {string} request.outputUrlPrefix - * Required. Location for the export metadata and data files. - * - * The full resource URL of the external storage location. Currently, only - * Google Cloud Storage is supported. So output_url_prefix should be of the - * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the - * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud - * Storage namespace path (this is not a Cloud Datastore namespace). For more - * information about Cloud Storage namespace paths, see - * [Object name - * considerations](https://cloud.google.com/storage/docs/naming#object-considerations). - * - * The resulting files will be nested deeper than the specified URL prefix. - * The final output URL will be provided in the - * {@link google.datastore.admin.v1.ExportEntitiesResponse.output_url|google.datastore.admin.v1.ExportEntitiesResponse.output_url} field. That - * value should be used for subsequent ImportEntities operations. - * - * By nesting the data files deeper, the same Cloud Storage bucket can be used - * in multiple ExportEntities operations without conflict. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.export_entities.js - * region_tag:datastore_v1_generated_DatastoreAdmin_ExportEntities_async - */ - exportEntities( - request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - exportEntities( - request: protos.google.datastore.admin.v1.IExportEntitiesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - exportEntities( - request: protos.google.datastore.admin.v1.IExportEntitiesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - exportEntities( - request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.exportEntities(request, options, callback); - } -/** - * Check the status of the long running operation returned by `exportEntities()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.export_entities.js - * region_tag:datastore_v1_generated_DatastoreAdmin_ExportEntities_async - */ - async checkExportEntitiesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.exportEntities, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Imports entities into Google Cloud Datastore. Existing entities with the - * same key are overwritten. The import occurs in the background and its - * progress can be monitored and managed via the Operation resource that is - * created. If an ImportEntities operation is cancelled, it is possible - * that a subset of the data has already been imported to Cloud Datastore. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Required. Project ID against which to make the request. - * @param {number[]} request.labels - * Client-assigned labels. - * @param {string} request.inputUrl - * Required. The full resource URL of the external storage location. Currently, only - * Google Cloud Storage is supported. So input_url should be of the form: - * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where - * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is - * an optional Cloud Storage namespace path (this is not a Cloud Datastore - * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written - * by the ExportEntities operation. For more information about Cloud Storage - * namespace paths, see - * [Object name - * considerations](https://cloud.google.com/storage/docs/naming#object-considerations). - * - * For more information, see - * {@link google.datastore.admin.v1.ExportEntitiesResponse.output_url|google.datastore.admin.v1.ExportEntitiesResponse.output_url}. - * @param {google.datastore.admin.v1.EntityFilter} request.entityFilter - * Optionally specify which kinds/namespaces are to be imported. If provided, - * the list must be a subset of the EntityFilter used in creating the export, - * otherwise a FAILED_PRECONDITION error will be returned. If no filter is - * specified then all entities from the export are imported. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.import_entities.js - * region_tag:datastore_v1_generated_DatastoreAdmin_ImportEntities_async - */ - importEntities( - request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - importEntities( - request: protos.google.datastore.admin.v1.IImportEntitiesRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importEntities( - request: protos.google.datastore.admin.v1.IImportEntitiesRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - importEntities( - request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.importEntities(request, options, callback); - } -/** - * Check the status of the long running operation returned by `importEntities()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.import_entities.js - * region_tag:datastore_v1_generated_DatastoreAdmin_ImportEntities_async - */ - async checkImportEntitiesProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importEntities, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Creates the specified index. - * A newly created index's initial state is `CREATING`. On completion of the - * returned {@link google.longrunning.Operation|google.longrunning.Operation}, the state will be `READY`. - * If the index already exists, the call will return an `ALREADY_EXISTS` - * status. - * - * During index creation, the process could result in an error, in which - * case the index will move to the `ERROR` state. The process can be recovered - * by fixing the data that caused the error, removing the index with - * {@link google.datastore.admin.v1.DatastoreAdmin.DeleteIndex|delete}, then - * re-creating the index with [create] - * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. - * - * Indexes with a single property cannot be created. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Project ID against which to make the request. - * @param {google.datastore.admin.v1.Index} request.index - * The index to create. The name and state fields are output only and will be - * ignored. Single property indexes cannot be created or deleted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.create_index.js - * region_tag:datastore_v1_generated_DatastoreAdmin_CreateIndex_async - */ - createIndex( - request?: protos.google.datastore.admin.v1.ICreateIndexRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createIndex( - request: protos.google.datastore.admin.v1.ICreateIndexRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createIndex( - request: protos.google.datastore.admin.v1.ICreateIndexRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createIndex( - request?: protos.google.datastore.admin.v1.ICreateIndexRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.createIndex(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createIndex()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.create_index.js - * region_tag:datastore_v1_generated_DatastoreAdmin_CreateIndex_async - */ - async checkCreateIndexProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createIndex, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes an existing index. - * An index can only be deleted if it is in a `READY` or `ERROR` state. On - * successful execution of the request, the index will be in a `DELETING` - * {@link google.datastore.admin.v1.Index.State|state}. And on completion of the - * returned {@link google.longrunning.Operation|google.longrunning.Operation}, the index will be removed. - * - * During index deletion, the process could result in an error, in which - * case the index will move to the `ERROR` state. The process can be recovered - * by fixing the data that caused the error, followed by calling - * {@link google.datastore.admin.v1.DatastoreAdmin.DeleteIndex|delete} again. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Project ID against which to make the request. - * @param {string} request.indexId - * The resource ID of the index to delete. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.delete_index.js - * region_tag:datastore_v1_generated_DatastoreAdmin_DeleteIndex_async - */ - deleteIndex( - request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteIndex( - request: protos.google.datastore.admin.v1.IDeleteIndexRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteIndex( - request: protos.google.datastore.admin.v1.IDeleteIndexRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteIndex( - request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - 'index_id': request.indexId || '', - }); - this.initialize(); - return this.innerApiCalls.deleteIndex(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteIndex()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.delete_index.js - * region_tag:datastore_v1_generated_DatastoreAdmin_DeleteIndex_async - */ - async checkDeleteIndexProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.deleteIndex, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the indexes that match the specified filters. Datastore uses an - * eventually consistent query to fetch the list of indexes and may - * occasionally return stale results. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Project ID against which to make the request. - * @param {string} request.filter - * @param {number} request.pageSize - * The maximum number of items to return. If zero, then all results will be - * returned. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Index]{@link google.datastore.admin.v1.Index}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listIndexesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listIndexes( - request?: protos.google.datastore.admin.v1.IListIndexesRequest, - options?: CallOptions): - Promise<[ - protos.google.datastore.admin.v1.IIndex[], - protos.google.datastore.admin.v1.IListIndexesRequest|null, - protos.google.datastore.admin.v1.IListIndexesResponse - ]>; - listIndexes( - request: protos.google.datastore.admin.v1.IListIndexesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.datastore.admin.v1.IListIndexesRequest, - protos.google.datastore.admin.v1.IListIndexesResponse|null|undefined, - protos.google.datastore.admin.v1.IIndex>): void; - listIndexes( - request: protos.google.datastore.admin.v1.IListIndexesRequest, - callback: PaginationCallback< - protos.google.datastore.admin.v1.IListIndexesRequest, - protos.google.datastore.admin.v1.IListIndexesResponse|null|undefined, - protos.google.datastore.admin.v1.IIndex>): void; - listIndexes( - request?: protos.google.datastore.admin.v1.IListIndexesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.datastore.admin.v1.IListIndexesRequest, - protos.google.datastore.admin.v1.IListIndexesResponse|null|undefined, - protos.google.datastore.admin.v1.IIndex>, - callback?: PaginationCallback< - protos.google.datastore.admin.v1.IListIndexesRequest, - protos.google.datastore.admin.v1.IListIndexesResponse|null|undefined, - protos.google.datastore.admin.v1.IIndex>): - Promise<[ - protos.google.datastore.admin.v1.IIndex[], - protos.google.datastore.admin.v1.IListIndexesRequest|null, - protos.google.datastore.admin.v1.IListIndexesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.listIndexes(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Project ID against which to make the request. - * @param {string} request.filter - * @param {number} request.pageSize - * The maximum number of items to return. If zero, then all results will be - * returned. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Index]{@link google.datastore.admin.v1.Index} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listIndexesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listIndexesStream( - request?: protos.google.datastore.admin.v1.IListIndexesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - const defaultCallSettings = this._defaults['listIndexes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listIndexes.createStream( - this.innerApiCalls.listIndexes as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listIndexes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Project ID against which to make the request. - * @param {string} request.filter - * @param {number} request.pageSize - * The maximum number of items to return. If zero, then all results will be - * returned. - * @param {string} request.pageToken - * The next_page_token value returned from a previous List request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Index]{@link google.datastore.admin.v1.Index}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/datastore_admin.list_indexes.js - * region_tag:datastore_v1_generated_DatastoreAdmin_ListIndexes_async - */ - listIndexesAsync( - request?: protos.google.datastore.admin.v1.IListIndexesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - const defaultCallSettings = this._defaults['listIndexes']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listIndexes.asyncIterate( - this.innerApiCalls['listIndexes'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * [google.longrunning.Operation]{@link - * external:"google.longrunning.Operation"}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * [google.longrunning.Operation]{@link - * external:"google.longrunning.Operation"}. The promise has a method named - * "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.datastoreAdminStub && !this._terminated) { - return this.datastoreAdminStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/admin/v1/src/v1/datastore_admin_client_config.json b/owl-bot-staging/admin/v1/src/v1/datastore_admin_client_config.json deleted file mode 100644 index 9dbc3f5ff..000000000 --- a/owl-bot-staging/admin/v1/src/v1/datastore_admin_client_config.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "interfaces": { - "google.datastore.admin.v1.DatastoreAdmin": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "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": { - "ExportEntities": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ImportEntities": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateIndex": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteIndex": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIndex": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListIndexes": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/admin/v1/src/v1/datastore_admin_proto_list.json b/owl-bot-staging/admin/v1/src/v1/datastore_admin_proto_list.json deleted file mode 100644 index 7a038c3a1..000000000 --- a/owl-bot-staging/admin/v1/src/v1/datastore_admin_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/datastore/admin/v1/datastore_admin.proto", - "../../protos/google/datastore/admin/v1/index.proto", - "../../protos/google/datastore/admin/v1/migration.proto" -] diff --git a/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json b/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 2b53e796b..000000000 --- a/owl-bot-staging/admin/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.datastore.admin.v1", - "libraryPackage": "@google-cloud/datastore-admin", - "services": { - "DatastoreAdmin": { - "clients": { - "grpc": { - "libraryClient": "DatastoreAdminClient", - "rpcs": { - "GetIndex": { - "methods": [ - "getIndex" - ] - }, - "ExportEntities": { - "methods": [ - "exportEntities" - ] - }, - "ImportEntities": { - "methods": [ - "importEntities" - ] - }, - "CreateIndex": { - "methods": [ - "createIndex" - ] - }, - "DeleteIndex": { - "methods": [ - "deleteIndex" - ] - }, - "ListIndexes": { - "methods": [ - "listIndexes", - "listIndexesStream", - "listIndexesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DatastoreAdminClient", - "rpcs": { - "GetIndex": { - "methods": [ - "getIndex" - ] - }, - "ExportEntities": { - "methods": [ - "exportEntities" - ] - }, - "ImportEntities": { - "methods": [ - "importEntities" - ] - }, - "CreateIndex": { - "methods": [ - "createIndex" - ] - }, - "DeleteIndex": { - "methods": [ - "deleteIndex" - ] - }, - "ListIndexes": { - "methods": [ - "listIndexes", - "listIndexesStream", - "listIndexesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/admin/v1/src/v1/index.ts b/owl-bot-staging/admin/v1/src/v1/index.ts deleted file mode 100644 index 9a4370473..000000000 --- a/owl-bot-staging/admin/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {DatastoreAdminClient} from './datastore_admin_client'; diff --git a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index aa9f615db..000000000 --- a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const admin = require('@google-cloud/datastore-admin'); - -function main() { - const datastoreAdminClient = new admin.DatastoreAdminClient(); -} - -main(); diff --git a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 83f1cd29f..000000000 --- a/owl-bot-staging/admin/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {DatastoreAdminClient} from '@google-cloud/datastore-admin'; - -// check that the client class type name can be used -function doStuffWithDatastoreAdminClient(client: DatastoreAdminClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const datastoreAdminClient = new DatastoreAdminClient(); - doStuffWithDatastoreAdminClient(datastoreAdminClient); -} - -main(); diff --git a/owl-bot-staging/admin/v1/system-test/install.ts b/owl-bot-staging/admin/v1/system-test/install.ts deleted file mode 100644 index 8ec452229..000000000 --- a/owl-bot-staging/admin/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/admin/v1/test/gapic_datastore_admin_v1.ts b/owl-bot-staging/admin/v1/test/gapic_datastore_admin_v1.ts deleted file mode 100644 index 78befb3c3..000000000 --- a/owl-bot-staging/admin/v1/test/gapic_datastore_admin_v1.ts +++ /dev/null @@ -1,1357 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as datastoreadminModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.DatastoreAdminClient', () => { - it('has servicePath', () => { - const servicePath = datastoreadminModule.v1.DatastoreAdminClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = datastoreadminModule.v1.DatastoreAdminClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = datastoreadminModule.v1.DatastoreAdminClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.datastoreAdminStub, undefined); - await client.initialize(); - assert(client.datastoreAdminStub); - }); - - it('has close method for the initialized client', done => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.datastoreAdminStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.datastoreAdminStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('getIndex', () => { - it('invokes getIndex without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.GetIndexRequest()); - request.projectId = ''; - request.indexId = ''; - const expectedHeaderRequestParams = "project_id=&index_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.admin.v1.Index()); - client.innerApiCalls.getIndex = stubSimpleCall(expectedResponse); - const [response] = await client.getIndex(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIndex without error using callback', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.GetIndexRequest()); - request.projectId = ''; - request.indexId = ''; - const expectedHeaderRequestParams = "project_id=&index_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.admin.v1.Index()); - client.innerApiCalls.getIndex = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIndex( - request, - (err?: Error|null, result?: protos.google.datastore.admin.v1.IIndex|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIndex with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.GetIndexRequest()); - request.projectId = ''; - request.indexId = ''; - const expectedHeaderRequestParams = "project_id=&index_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIndex(request), expectedError); - assert((client.innerApiCalls.getIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIndex with closed client', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.GetIndexRequest()); - request.projectId = ''; - request.indexId = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIndex(request), expectedError); - }); - }); - - describe('exportEntities', () => { - it('invokes exportEntities without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ExportEntitiesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.exportEntities = stubLongRunningCall(expectedResponse); - const [operation] = await client.exportEntities(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.exportEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes exportEntities without error using callback', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ExportEntitiesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.exportEntities = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.exportEntities( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.exportEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes exportEntities with call error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ExportEntitiesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.exportEntities = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.exportEntities(request), expectedError); - assert((client.innerApiCalls.exportEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes exportEntities with LRO error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ExportEntitiesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.exportEntities = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.exportEntities(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.exportEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkExportEntitiesProgress without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkExportEntitiesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkExportEntitiesProgress with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkExportEntitiesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('importEntities', () => { - it('invokes importEntities without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ImportEntitiesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importEntities = stubLongRunningCall(expectedResponse); - const [operation] = await client.importEntities(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importEntities without error using callback', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ImportEntitiesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.importEntities = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importEntities( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.importEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes importEntities with call error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ImportEntitiesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importEntities = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importEntities(request), expectedError); - assert((client.innerApiCalls.importEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes importEntities with LRO error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ImportEntitiesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importEntities = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importEntities(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.importEntities as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkImportEntitiesProgress without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportEntitiesProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkImportEntitiesProgress with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportEntitiesProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createIndex', () => { - it('invokes createIndex without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.CreateIndexRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createIndex = stubLongRunningCall(expectedResponse); - const [operation] = await client.createIndex(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createIndex without error using callback', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.CreateIndexRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createIndex = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createIndex( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createIndex with call error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.CreateIndexRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createIndex = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createIndex(request), expectedError); - assert((client.innerApiCalls.createIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createIndex with LRO error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.CreateIndexRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createIndex = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createIndex(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateIndexProgress without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateIndexProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateIndexProgress with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateIndexProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteIndex', () => { - it('invokes deleteIndex without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.DeleteIndexRequest()); - request.projectId = ''; - request.indexId = ''; - const expectedHeaderRequestParams = "project_id=&index_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteIndex = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteIndex(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteIndex without error using callback', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.DeleteIndexRequest()); - request.projectId = ''; - request.indexId = ''; - const expectedHeaderRequestParams = "project_id=&index_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteIndex = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteIndex( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteIndex with call error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.DeleteIndexRequest()); - request.projectId = ''; - request.indexId = ''; - const expectedHeaderRequestParams = "project_id=&index_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteIndex = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteIndex(request), expectedError); - assert((client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteIndex with LRO error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.DeleteIndexRequest()); - request.projectId = ''; - request.indexId = ''; - const expectedHeaderRequestParams = "project_id=&index_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteIndex = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteIndex(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteIndexProgress without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteIndexProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteIndexProgress with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteIndexProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listIndexes', () => { - it('invokes listIndexes without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - ]; - client.innerApiCalls.listIndexes = stubSimpleCall(expectedResponse); - const [response] = await client.listIndexes(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listIndexes without error using callback', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - ]; - client.innerApiCalls.listIndexes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listIndexes( - request, - (err?: Error|null, result?: protos.google.datastore.admin.v1.IIndex[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listIndexes with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listIndexes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listIndexes(request), expectedError); - assert((client.innerApiCalls.listIndexes as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listIndexesStream without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedResponse = [ - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - ]; - client.descriptors.page.listIndexes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listIndexesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.datastore.admin.v1.Index[] = []; - stream.on('data', (response: protos.google.datastore.admin.v1.Index) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listIndexes, request)); - assert.strictEqual( - (client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listIndexesStream with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedError = new Error('expected'); - client.descriptors.page.listIndexes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listIndexesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.datastore.admin.v1.Index[] = []; - stream.on('data', (response: protos.google.datastore.admin.v1.Index) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listIndexes, request)); - assert.strictEqual( - (client.descriptors.page.listIndexes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listIndexes without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedResponse = [ - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - generateSampleMessage(new protos.google.datastore.admin.v1.Index()), - ]; - client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.datastore.admin.v1.IIndex[] = []; - const iterable = client.listIndexesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listIndexes with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.admin.v1.ListIndexesRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id=";const expectedError = new Error('expected'); - client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listIndexesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.datastore.admin.v1.IIndex[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new datastoreadminModule.v1.DatastoreAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); -}); diff --git a/owl-bot-staging/admin/v1/tsconfig.json b/owl-bot-staging/admin/v1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/admin/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/admin/v1/webpack.config.js b/owl-bot-staging/admin/v1/webpack.config.js deleted file mode 100644 index 1f646dd1e..000000000 --- a/owl-bot-staging/admin/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'DatastoreAdmin', - filename: './datastore-admin.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index cfc348ec4..000000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 782153495..000000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b2378..000000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index a3585eb98..000000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/datastore', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 481c522b0..000000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 494e14786..000000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index 85e311e00..000000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Datastore: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index befd23c86..000000000 --- a/owl-bot-staging/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 797318ad1..000000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/datastore", - "version": "0.1.0", - "description": "Datastore client for Node.js", - "repository": "googleapis/nodejs-datastore", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google datastore", - "datastore", - "datastore" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.1.1" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/v1/protos/google/datastore/v1/datastore.proto b/owl-bot-staging/v1/protos/google/datastore/v1/datastore.proto deleted file mode 100644 index 22d930ad0..000000000 --- a/owl-bot-staging/v1/protos/google/datastore/v1/datastore.proto +++ /dev/null @@ -1,443 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -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"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Datastore.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; -option java_multiple_files = true; -option java_outer_classname = "DatastoreProto"; -option java_package = "com.google.datastore.v1"; -option php_namespace = "Google\\Cloud\\Datastore\\V1"; -option ruby_package = "Google::Cloud::Datastore::V1"; - -// Each RPC normalizes the partition IDs of the keys in its input entities, -// and always returns entities with keys with normalized partition IDs. -// This applies to all keys and entities, including those in values, except keys -// with both an empty path and an empty or unset partition ID. Normalization of -// input keys sets the project ID (if not already set) to the project ID from -// 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. - rpc RunQuery(RunQueryRequest) returns (RunQueryResponse) { - 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: "/v1/projects/{project_id}:beginTransaction" - body: "*" - }; - option (google.api.method_signature) = "project_id"; - } - - // Commits a transaction, optionally creating, deleting or modifying some - // entities. - rpc Commit(CommitRequest) returns (CommitResponse) { - option (google.api.http) = { - 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. - rpc Rollback(RollbackRequest) returns (RollbackResponse) { - option (google.api.http) = { - 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 - // before it is inserted. - rpc AllocateIds(AllocateIdsRequest) returns (AllocateIdsResponse) { - option (google.api.http) = { - 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 - // Datastore. - rpc ReserveIds(ReserveIdsRequest) returns (ReserveIdsResponse) { - option (google.api.http) = { - 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 { - // 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; - - // 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]. -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 - // input. - repeated EntityResult found = 1; - - // Entities not found as `ResultType.KEY_ONLY` entities. The order of results - // in this field is undefined and has no relation to the order of the keys - // in the input. - repeated EntityResult missing = 2; - - // A list of keys that were not looked up due to resource constraints. The - // order of results in this field is undefined and has no relation to the - // order of the keys in the input. - repeated Key deferred = 3; - - // The time at which these entities were read or found missing. - google.protobuf.Timestamp read_time = 7; -} - -// The request for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. -message RunQueryRequest { - // 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. - // This partition ID is normalized with the standard default context - // partition ID. - PartitionId partition_id = 2; - - // The options for this query. - ReadOptions read_options = 1; - - // The type of query. - oneof query_type { - // The query to run. - Query query = 3; - - // The GQL query to run. - GqlQuery gql_query = 7; - } -} - -// The response for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. -message RunQueryResponse { - // A batch of query results (always present). - QueryResultBatch batch = 1; - - // The parsed form of the `GqlQuery` from the request, if it was set. - Query query = 2; -} - -// The request for [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. -message BeginTransactionRequest { - // 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]. -message BeginTransactionResponse { - // The transaction identifier (always present). - bytes transaction = 1; -} - -// The request for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. -message RollbackRequest { - // Required. The ID of the project against which to make the request. - string project_id = 8 [(google.api.field_behavior) = REQUIRED]; - - // Required. The transaction identifier, returned by a call to - // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. - bytes transaction = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// 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 { - // The modes available for commits. - enum Mode { - // Unspecified. This value must not be used. - MODE_UNSPECIFIED = 0; - - // Transactional: The mutations are either all applied, or none are applied. - // Learn about transactions - // [here](https://cloud.google.com/datastore/docs/concepts/transactions). - TRANSACTIONAL = 1; - - // Non-transactional: The mutations may not apply as all or none. - NON_TRANSACTIONAL = 2; - } - - // 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; - - // Must be set when mode is `TRANSACTIONAL`. - oneof transaction_selector { - // The identifier of the transaction associated with the commit. A - // transaction identifier is returned by a call to - // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. - bytes transaction = 1; - } - - // The mutations to perform. - // - // When mode is `TRANSACTIONAL`, mutations affecting a single entity are - // applied in order. The following sequences of mutations affecting a single - // entity are not permitted in a single `Commit` request: - // - // - `insert` followed by `insert` - // - `update` followed by `insert` - // - `upsert` followed by `insert` - // - `delete` followed by `update` - // - // When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single - // entity. - repeated Mutation mutations = 6; -} - -// 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. - repeated MutationResult mutation_results = 3; - - // The number of index entries updated during the commit, or zero if none were - // updated. - int32 index_updates = 4; - - // The transaction commit timestamp. Not set for non-transactional commits. - google.protobuf.Timestamp commit_time = 8; -} - -// The request for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. -message AllocateIdsRequest { - // Required. The ID of the project against which to make the request. - string project_id = 8 [(google.api.field_behavior) = REQUIRED]; - - // 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 [(google.api.field_behavior) = REQUIRED]; -} - -// 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]. -message ReserveIdsRequest { - // 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; - - // Required. A list of keys with complete key paths whose numeric IDs should not be - // auto-allocated. - repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// The response for [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. -message ReserveIdsResponse { - -} - -// A mutation to apply to an entity. -message Mutation { - // The mutation operation. - // - // For `insert`, `update`, and `upsert`: - // - The entity's key must not be reserved/read-only. - // - No property in the entity may have a reserved name, - // not even a property in an entity in a value. - // - No value in the entity may have meaning 18, - // not even a value in an entity in another value. - oneof operation { - // The entity to insert. The entity must not already exist. - // The entity key's final path element may be incomplete. - Entity insert = 4; - - // The entity to update. The entity must already exist. - // Must have a complete key path. - Entity update = 5; - - // The entity to upsert. The entity may or may not already exist. - // The entity key's final path element may be incomplete. - Entity upsert = 6; - - // The key of the entity to delete. The entity may or may not already exist. - // 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 update time of the entity that this mutation is being applied - // to. If this does not match the current update time on the server, the - // mutation conflicts. - google.protobuf.Timestamp update_time = 11; - } -} - -// 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; - - // The update time of the entity on the server after processing the mutation. - // If the mutation doesn't change anything on the server, then the timestamp - // will be the update timestamp of the current entity. This field will not be - // set after a 'delete'. - google.protobuf.Timestamp update_time = 6; - - // 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. -message ReadOptions { - // The possible values for read consistencies. - enum ReadConsistency { - // Unspecified. This value must not be used. - READ_CONSISTENCY_UNSPECIFIED = 0; - - // Strong consistency. - STRONG = 1; - - // Eventual consistency. - EVENTUAL = 2; - } - - // For Cloud Datastore, if read_consistency is not specified, then lookups and - // ancestor queries default to `read_consistency`=`STRONG`, global queries - // default to `read_consistency`=`EVENTUAL`. - // - // For Cloud Firestore in Datastore mode, if read_consistency is not specified - // then lookups and all queries default to `read_consistency`=`STRONG`. - // - // Explicitly setting `read_consistency`=`EVENTUAL` will result in eventually - // consistent lookups & queries in both Cloud Datastore & Cloud Firestore in - // Datastore mode. - oneof consistency_type { - // The non-transactional read consistency to use. - // Cannot be set to `STRONG` for global queries. - ReadConsistency read_consistency = 1; - - // 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; - - // Reads entities as they were at the given time. This may not be older - // than 270 seconds. This value is only supported for Cloud Firestore in - // Datastore mode. - google.protobuf.Timestamp read_time = 4; - } -} - -// 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. -message TransactionOptions { - // Options specific to read / write transactions. - message ReadWrite { - // The transaction identifier of the transaction being retried. - bytes previous_transaction = 1; - } - - // Options specific to read-only transactions. - message ReadOnly { - // Reads entities at the given time. - // This may not be older than 60 seconds. - google.protobuf.Timestamp read_time = 1; - } - - // The `mode` of the transaction, indicating whether write operations are - // supported. - oneof mode { - // The transaction should allow both reads and writes. - ReadWrite read_write = 1; - - // The transaction should only allow reads. - ReadOnly read_only = 2; - } -} diff --git a/owl-bot-staging/v1/protos/google/datastore/v1/entity.proto b/owl-bot-staging/v1/protos/google/datastore/v1/entity.proto deleted file mode 100644 index 55d7b64fe..000000000 --- a/owl-bot-staging/v1/protos/google/datastore/v1/entity.proto +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.datastore.v1; - -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; -import "google/type/latlng.proto"; - -option csharp_namespace = "Google.Cloud.Datastore.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; -option java_multiple_files = true; -option java_outer_classname = "EntityProto"; -option java_package = "com.google.datastore.v1"; -option php_namespace = "Google\\Cloud\\Datastore\\V1"; -option ruby_package = "Google::Cloud::Datastore::V1"; - -// A partition ID identifies a grouping of entities. The grouping is always -// by project and namespace, however the namespace ID may be empty. -// -// A partition ID contains several dimensions: -// project ID and namespace ID. -// -// Partition dimensions: -// -// - May be `""`. -// - Must be valid UTF-8 bytes. -// - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}` -// If the value of any dimension matches regex `__.*__`, the partition is -// reserved/read-only. -// A reserved/read-only partition ID is forbidden in certain documented -// contexts. -// -// Foreign partition IDs (in which the project ID does -// not match the context project ID ) are discouraged. -// Reads and writes of foreign partition IDs may fail if the project is not in an active state. -message PartitionId { - // The ID of the project to which the entities belong. - string project_id = 2; - - // If not empty, the ID of the namespace to which the entities belong. - string namespace_id = 4; -} - -// A unique identifier for an entity. -// If a key's partition ID or any of its path kinds or names are -// reserved/read-only, the key is reserved/read-only. -// A reserved/read-only key is forbidden in certain documented contexts. -message Key { - // A (kind, ID/name) pair used to construct a key path. - // - // If either name or ID is set, the element is complete. - // If neither is set, the element is incomplete. - message PathElement { - // The kind of the entity. - // - // A kind matching regex `__.*__` is reserved/read-only. - // A kind must not contain more than 1500 bytes when UTF-8 encoded. - // Cannot be `""`. - // - // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are - // encoded as `__bytes__` where `` is the base-64 encoding of the - // bytes. - string kind = 1; - - // The type of ID. - oneof id_type { - // The auto-allocated ID of the entity. - // - // Never equal to zero. Values less than zero are discouraged and may not - // be supported in the future. - int64 id = 2; - - // The name of the entity. - // - // A name matching regex `__.*__` is reserved/read-only. - // A name must not be more than 1500 bytes when UTF-8 encoded. - // Cannot be `""`. - // - // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are - // encoded as `__bytes__` where `` is the base-64 encoding of the - // bytes. - string name = 3; - } - } - - // Entities are partitioned into subsets, currently identified by a project - // ID and namespace ID. - // Queries are scoped to a single partition. - PartitionId partition_id = 1; - - // The entity path. - // An entity path consists of one or more elements composed of a kind and a - // string or numerical identifier, which identify entities. The first - // element identifies a _root entity_, the second element identifies - // a _child_ of the root entity, the third element identifies a child of the - // second entity, and so forth. The entities identified by all prefixes of - // the path are called the element's _ancestors_. - // - // An entity path is always fully complete: *all* of the entity's ancestors - // are required to be in the path along with the entity identifier itself. - // The only exception is that in some documented cases, the identifier in the - // last path element (for the entity) itself may be omitted. For example, - // the last path element of the key of `Mutation.insert` may have no - // identifier. - // - // A path can never be empty, and a path can have at most 100 elements. - repeated PathElement path = 2; -} - -// An array value. -message ArrayValue { - // Values in the array. - // 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; -} - -// A message that can hold any of the supported value types and associated -// metadata. -message Value { - // Must have a value set. - oneof value_type { - // A null value. - google.protobuf.NullValue null_value = 11; - - // A boolean value. - bool boolean_value = 1; - - // An integer value. - int64 integer_value = 2; - - // A double value. - double double_value = 3; - - // A timestamp value. - // When stored in the Datastore, precise only to microseconds; - // any additional precision is rounded down. - google.protobuf.Timestamp timestamp_value = 10; - - // A key 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 most 1,000,000 bytes. - string string_value = 17; - - // A blob value. - // May have at most 1,000,000 bytes. - // When `exclude_from_indexes` is false, may have at most 1500 bytes. - // In JSON requests, must be base64-encoded. - bytes blob_value = 18; - - // A geo point value representing a point on the surface of Earth. - google.type.LatLng geo_point_value = 8; - - // An entity value. - // - // - May have no key. - // - May have a key with an incomplete key path. - // - May have a reserved/read-only key. - Entity entity_value = 6; - - // An array value. - // Cannot contain another array value. - // A `Value` instance that sets field `array_value` must not set fields - // `meaning` or `exclude_from_indexes`. - ArrayValue array_value = 9; - } - - // The `meaning` field should only be populated for backwards compatibility. - int32 meaning = 14; - - // If the value should be excluded from all indexes including those defined - // explicitly. - bool exclude_from_indexes = 19; -} - -// A Datastore data object. -// -// An entity is limited to 1 megabyte when stored. That _roughly_ -// corresponds to a limit of 1 megabyte for the serialized form of this -// message. -message Entity { - // The entity's key. - // - // An entity must have a key, unless otherwise documented (for example, - // an entity in `Value.entity_value` may have no key). - // An entity's kind is its key path's last element's kind, - // or null if it has no key. - Key key = 1; - - // The entity's properties. - // The map's keys are property names. - // A property name matching regex `__.*__` is reserved. - // A reserved property name is forbidden in certain documented contexts. - // The name must not contain more than 500 characters. - // The name cannot be `""`. - map properties = 3; -} diff --git a/owl-bot-staging/v1/protos/google/datastore/v1/query.proto b/owl-bot-staging/v1/protos/google/datastore/v1/query.proto deleted file mode 100644 index 00c020021..000000000 --- a/owl-bot-staging/v1/protos/google/datastore/v1/query.proto +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.datastore.v1; - -import "google/datastore/v1/entity.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option csharp_namespace = "Google.Cloud.Datastore.V1"; -option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; -option java_multiple_files = true; -option java_outer_classname = "QueryProto"; -option java_package = "com.google.datastore.v1"; -option php_namespace = "Google\\Cloud\\Datastore\\V1"; -option ruby_package = "Google::Cloud::Datastore::V1"; - -// The result of fetching an entity from Datastore. -message EntityResult { - // Specifies what data the 'entity' field contains. - // A `ResultType` is either implied (for example, in `LookupResponse.missing` - // from `datastore.proto`, it is always `KEY_ONLY`) or specified by context - // (for example, in message `QueryResultBatch`, field `entity_result_type` - // specifies a `ResultType` for all the values in field `entity_results`). - enum ResultType { - // Unspecified. This value is never used. - RESULT_TYPE_UNSPECIFIED = 0; - - // The key and properties. - FULL = 1; - - // A projected subset of properties. The entity may have no key. - PROJECTION = 2; - - // Only the key. - KEY_ONLY = 3; - } - - // The resulting entity. - Entity entity = 1; - - // 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. - // - // 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; - - // The time at which the entity was last changed. - // This field is set for [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity - // results. - // If this entity is missing, this field will not be set. - google.protobuf.Timestamp update_time = 5; - - // A cursor that points to the position after the result entity. - // Set only when the `EntityResult` is part of a `QueryResultBatch` message. - bytes cursor = 3; -} - -// A query for entities. -message Query { - // The projection to return. Defaults to returning all properties. - repeated Projection projection = 2; - - // The kinds to query (if empty, returns entities of all kinds). - // Currently at most 1 kind may be specified. - repeated KindExpression kind = 3; - - // The filter to apply. - Filter filter = 4; - - // The order to apply to the query results (if empty, order is unspecified). - repeated PropertyOrder order = 5; - - // The properties to make distinct. The query results will contain the first - // result for each distinct combination of values for the given properties - // (if empty, all results are returned). - repeated PropertyReference distinct_on = 6; - - // A starting point for the query results. Query cursors are - // returned in query result batches and - // [can only be used to continue the same - // query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). - bytes start_cursor = 7; - - // An ending point for the query results. Query cursors are - // returned in query result batches and - // [can only be used to limit the same - // query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). - bytes end_cursor = 8; - - // The number of results to skip. Applies before limit, but after all other - // constraints. Optional. Must be >= 0 if specified. - int32 offset = 10; - - // The maximum number of results to return. Applies after all other - // constraints. Optional. - // Unspecified is interpreted as no limit. - // Must be >= 0 if specified. - google.protobuf.Int32Value limit = 12; -} - -// A representation of a kind. -message KindExpression { - // The name of the kind. - string name = 1; -} - -// A reference to a property relative to the kind expressions. -message PropertyReference { - // The name of the property. - // If name includes "."s, it may be interpreted as a property name path. - string name = 2; -} - -// A representation of a property in a projection. -message Projection { - // The property to project. - PropertyReference property = 1; -} - -// The desired order for a specific property. -message PropertyOrder { - // The sort direction. - enum Direction { - // Unspecified. This value must not be used. - DIRECTION_UNSPECIFIED = 0; - - // Ascending. - ASCENDING = 1; - - // Descending. - DESCENDING = 2; - } - - // The property to order by. - PropertyReference property = 1; - - // The direction to order by. Defaults to `ASCENDING`. - Direction direction = 2; -} - -// A holder for any type of filter. -message Filter { - // The type of filter. - oneof filter_type { - // A composite filter. - CompositeFilter composite_filter = 1; - - // A filter on a property. - PropertyFilter property_filter = 2; - } -} - -// A filter that merges multiple other filters using the given operator. -message CompositeFilter { - // A composite filter operator. - enum Operator { - // Unspecified. This value must not be used. - OPERATOR_UNSPECIFIED = 0; - - // The results are required to satisfy each of the combined filters. - AND = 1; - } - - // The operator for combining multiple filters. - Operator op = 1; - - // The list of filters to combine. - // Must contain at least one filter. - repeated Filter filters = 2; -} - -// A filter on a specific property. -message PropertyFilter { - // A property filter operator. - enum Operator { - // Unspecified. This value must not be used. - OPERATOR_UNSPECIFIED = 0; - - // The given `property` is less than the given `value`. - // - // Requires: - // - // * That `property` comes first in `order_by`. - LESS_THAN = 1; - - // The given `property` is less than or equal to the given `value`. - // - // Requires: - // - // * That `property` comes first in `order_by`. - LESS_THAN_OR_EQUAL = 2; - - // The given `property` is greater than the given `value`. - // - // Requires: - // - // * That `property` comes first in `order_by`. - GREATER_THAN = 3; - - // The given `property` is greater than or equal to the given `value`. - // - // Requires: - // - // * That `property` comes first in `order_by`. - GREATER_THAN_OR_EQUAL = 4; - - // The given `property` is equal to the given `value`. - EQUAL = 5; - - // The given `property` is equal to at least one value in the given array. - // - // Requires: - // - // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN` or `NOT_IN` is in the same query. - IN = 6; - - // The given `property` is not equal to the given `value`. - // - // Requires: - // - // * No other `NOT_EQUAL` or `NOT_IN` is in the same query. - // * That `property` comes first in the `order_by`. - NOT_EQUAL = 9; - - // Limit the result set to the given entity and its descendants. - // - // Requires: - // - // * That `value` is an entity key. - HAS_ANCESTOR = 11; - - // The value of the `property` is not in the given array. - // - // Requires: - // - // * That `value` is a non-empty `ArrayValue` with at most 10 values. - // * No other `IN`, `NOT_IN`, `NOT_EQUAL` is in the same query. - // * That `field` comes first in the `order_by`. - NOT_IN = 13; - } - - // The property to filter by. - PropertyReference property = 1; - - // The operator to filter by. - Operator op = 2; - - // The value to compare the property to. - Value value = 3; -} - -// A [GQL -// query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). -message GqlQuery { - // A string of the format described - // [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). - string query_string = 1; - - // When false, the query string must not contain any literals and instead must - // bind all values. For example, - // `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while - // `SELECT * FROM Kind WHERE a = @value` is. - bool allow_literals = 2; - - // For each non-reserved named binding site in the query string, there must be - // a named parameter with that name, but not necessarily the inverse. - // - // Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex - // `__.*__`, and must not be `""`. - map named_bindings = 5; - - // Numbered binding site @1 references the first numbered parameter, - // effectively using 1-based indexing, rather than the usual 0. - // - // For each binding site numbered i in `query_string`, there must be an i-th - // numbered parameter. The inverse must also be true. - repeated GqlQueryParameter positional_bindings = 4; -} - -// A binding parameter for a GQL query. -message GqlQueryParameter { - // The type of parameter. - oneof parameter_type { - // A value parameter. - Value value = 2; - - // A query cursor. Query cursors are returned in query - // result batches. - bytes cursor = 3; - } -} - -// A batch of results produced by a query. -message QueryResultBatch { - // The possible values for the `more_results` field. - enum MoreResultsType { - // Unspecified. This value is never used. - MORE_RESULTS_TYPE_UNSPECIFIED = 0; - - // There may be additional batches to fetch from this query. - NOT_FINISHED = 1; - - // The query is finished, but there may be more results after the limit. - MORE_RESULTS_AFTER_LIMIT = 2; - - // The query is finished, but there may be more results after the end - // cursor. - MORE_RESULTS_AFTER_CURSOR = 4; - - // The query is finished, and there are no more results. - NO_MORE_RESULTS = 3; - } - - // The number of results skipped, typically because of an offset. - int32 skipped_results = 6; - - // A cursor that points to the position after the last skipped result. - // Will be set when `skipped_results` != 0. - bytes skipped_cursor = 3; - - // The result type for every entity in `entity_results`. - EntityResult.ResultType entity_result_type = 1; - - // The results for this batch. - repeated EntityResult entity_results = 2; - - // A cursor that points to the position after the last result in the batch. - bytes end_cursor = 4; - - // The state of the query after the current batch. - MoreResultsType more_results = 5; - - // The version number of the snapshot this batch was returned from. - // This applies to the range of results from the query's `start_cursor` (or - // the beginning of the query if no cursor was given) to this batch's - // `end_cursor` (not the query's `end_cursor`). - // - // In a single transaction, subsequent query result batches for the same query - // can have a greater snapshot version number. Each batch's snapshot version - // is valid for all preceding batches. - // The value will be zero for eventually consistent queries. - int64 snapshot_version = 7; - - // Read timestamp this batch was returned from. - // This applies to the range of results from the query's `start_cursor` (or - // the beginning of the query if no cursor was given) to this batch's - // `end_cursor` (not the query's `end_cursor`). - // - // In a single transaction, subsequent query result batches for the same query - // can have a greater timestamp. Each batch's read timestamp - // is valid for all preceding batches. - // This value will not be set for eventually consistent queries in Cloud - // Datastore. - google.protobuf.Timestamp read_time = 8; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.allocate_ids.js b/owl-bot-staging/v1/samples/generated/v1/datastore.allocate_ids.js deleted file mode 100644 index 9700a2d52..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/datastore.allocate_ids.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(projectId, keys) { - // [START datastore_v1_generated_Datastore_AllocateIds_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ID of the project against which to make the request. - */ - // const projectId = 'abc123' - /** - * Required. A list of keys with incomplete key paths for which to allocate IDs. - * No key may be reserved/read-only. - */ - // const keys = 1234 - - // Imports the Datastore library - const {DatastoreClient} = require('@google-cloud/datastore').v1; - - // Instantiates a client - const datastoreClient = new DatastoreClient(); - - async function callAllocateIds() { - // Construct request - const request = { - projectId, - keys, - }; - - // Run request - const response = await datastoreClient.allocateIds(request); - console.log(response); - } - - callAllocateIds(); - // [END datastore_v1_generated_Datastore_AllocateIds_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.begin_transaction.js b/owl-bot-staging/v1/samples/generated/v1/datastore.begin_transaction.js deleted file mode 100644 index 81880be31..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/datastore.begin_transaction.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(projectId) { - // [START datastore_v1_generated_Datastore_BeginTransaction_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ID of the project against which to make the request. - */ - // const projectId = 'abc123' - /** - * Options for a new transaction. - */ - // const transactionOptions = {} - - // Imports the Datastore library - const {DatastoreClient} = require('@google-cloud/datastore').v1; - - // Instantiates a client - const datastoreClient = new DatastoreClient(); - - async function callBeginTransaction() { - // Construct request - const request = { - projectId, - }; - - // Run request - const response = await datastoreClient.beginTransaction(request); - console.log(response); - } - - callBeginTransaction(); - // [END datastore_v1_generated_Datastore_BeginTransaction_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.commit.js b/owl-bot-staging/v1/samples/generated/v1/datastore.commit.js deleted file mode 100644 index cf2309444..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/datastore.commit.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(projectId) { - // [START datastore_v1_generated_Datastore_Commit_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ID of the project against which to make the request. - */ - // const projectId = 'abc123' - /** - * The type of commit to perform. Defaults to `TRANSACTIONAL`. - */ - // const mode = {} - /** - * The identifier of the transaction associated with the commit. A - * transaction identifier is returned by a call to - * Datastore.BeginTransaction google.datastore.v1.Datastore.BeginTransaction. - */ - // const transaction = 'Buffer.from('string')' - /** - * The mutations to perform. - * When mode is `TRANSACTIONAL`, mutations affecting a single entity are - * applied in order. The following sequences of mutations affecting a single - * entity are not permitted in a single `Commit` request: - * - `insert` followed by `insert` - * - `update` followed by `insert` - * - `upsert` followed by `insert` - * - `delete` followed by `update` - * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single - * entity. - */ - // const mutations = 1234 - - // Imports the Datastore library - const {DatastoreClient} = require('@google-cloud/datastore').v1; - - // Instantiates a client - const datastoreClient = new DatastoreClient(); - - async function callCommit() { - // Construct request - const request = { - projectId, - }; - - // Run request - const response = await datastoreClient.commit(request); - console.log(response); - } - - callCommit(); - // [END datastore_v1_generated_Datastore_Commit_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.lookup.js b/owl-bot-staging/v1/samples/generated/v1/datastore.lookup.js deleted file mode 100644 index 2fe543be6..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/datastore.lookup.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(projectId, keys) { - // [START datastore_v1_generated_Datastore_Lookup_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ID of the project against which to make the request. - */ - // const projectId = 'abc123' - /** - * The options for this lookup request. - */ - // const readOptions = {} - /** - * Required. Keys of entities to look up. - */ - // const keys = 1234 - - // Imports the Datastore library - const {DatastoreClient} = require('@google-cloud/datastore').v1; - - // Instantiates a client - const datastoreClient = new DatastoreClient(); - - async function callLookup() { - // Construct request - const request = { - projectId, - keys, - }; - - // Run request - const response = await datastoreClient.lookup(request); - console.log(response); - } - - callLookup(); - // [END datastore_v1_generated_Datastore_Lookup_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.reserve_ids.js b/owl-bot-staging/v1/samples/generated/v1/datastore.reserve_ids.js deleted file mode 100644 index be7e91d6a..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/datastore.reserve_ids.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(projectId, keys) { - // [START datastore_v1_generated_Datastore_ReserveIds_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ID of the project against which to make the request. - */ - // const projectId = 'abc123' - /** - * If not empty, the ID of the database against which to make the request. - */ - // const databaseId = 'abc123' - /** - * Required. A list of keys with complete key paths whose numeric IDs should not be - * auto-allocated. - */ - // const keys = 1234 - - // Imports the Datastore library - const {DatastoreClient} = require('@google-cloud/datastore').v1; - - // Instantiates a client - const datastoreClient = new DatastoreClient(); - - async function callReserveIds() { - // Construct request - const request = { - projectId, - keys, - }; - - // Run request - const response = await datastoreClient.reserveIds(request); - console.log(response); - } - - callReserveIds(); - // [END datastore_v1_generated_Datastore_ReserveIds_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.rollback.js b/owl-bot-staging/v1/samples/generated/v1/datastore.rollback.js deleted file mode 100644 index 7cead96b5..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/datastore.rollback.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(projectId, transaction) { - // [START datastore_v1_generated_Datastore_Rollback_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ID of the project against which to make the request. - */ - // const projectId = 'abc123' - /** - * Required. The transaction identifier, returned by a call to - * Datastore.BeginTransaction google.datastore.v1.Datastore.BeginTransaction. - */ - // const transaction = 'Buffer.from('string')' - - // Imports the Datastore library - const {DatastoreClient} = require('@google-cloud/datastore').v1; - - // Instantiates a client - const datastoreClient = new DatastoreClient(); - - async function callRollback() { - // Construct request - const request = { - projectId, - transaction, - }; - - // Run request - const response = await datastoreClient.rollback(request); - console.log(response); - } - - callRollback(); - // [END datastore_v1_generated_Datastore_Rollback_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/datastore.run_query.js b/owl-bot-staging/v1/samples/generated/v1/datastore.run_query.js deleted file mode 100644 index d5995beff..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/datastore.run_query.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(projectId) { - // [START datastore_v1_generated_Datastore_RunQuery_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The ID of the project against which to make the request. - */ - // const projectId = 'abc123' - /** - * Entities are partitioned into subsets, identified by a partition ID. - * Queries are scoped to a single partition. - * This partition ID is normalized with the standard default context - * partition ID. - */ - // const partitionId = {} - /** - * The options for this query. - */ - // const readOptions = {} - /** - * The query to run. - */ - // const query = {} - /** - * The GQL query to run. - */ - // const gqlQuery = {} - - // Imports the Datastore library - const {DatastoreClient} = require('@google-cloud/datastore').v1; - - // Instantiates a client - const datastoreClient = new DatastoreClient(); - - async function callRunQuery() { - // Construct request - const request = { - projectId, - }; - - // Run request - const response = await datastoreClient.runQuery(request); - console.log(response); - } - - callRunQuery(); - // [END datastore_v1_generated_Datastore_RunQuery_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.datastore.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.datastore.v1.json deleted file mode 100644 index d41928b9c..000000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.datastore.v1.json +++ /dev/null @@ -1,351 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-datastore", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.datastore.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "datastore_v1_generated_Datastore_Lookup_async", - "title": "datastore lookup Sample", - "origin": "API_DEFINITION", - "description": " Looks up entities by key.", - "canonical": true, - "file": "datastore.lookup.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Lookup", - "fullName": "google.datastore.v1.Datastore.Lookup", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "read_options", - "type": ".google.datastore.v1.ReadOptions" - }, - { - "name": "keys", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.datastore.v1.LookupResponse", - "client": { - "shortName": "DatastoreClient", - "fullName": "google.datastore.v1.DatastoreClient" - }, - "method": { - "shortName": "Lookup", - "fullName": "google.datastore.v1.Datastore.Lookup", - "service": { - "shortName": "Datastore", - "fullName": "google.datastore.v1.Datastore" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_Datastore_RunQuery_async", - "title": "datastore runQuery Sample", - "origin": "API_DEFINITION", - "description": " Queries for entities.", - "canonical": true, - "file": "datastore.run_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 69, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RunQuery", - "fullName": "google.datastore.v1.Datastore.RunQuery", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "partition_id", - "type": ".google.datastore.v1.PartitionId" - }, - { - "name": "read_options", - "type": ".google.datastore.v1.ReadOptions" - }, - { - "name": "query", - "type": ".google.datastore.v1.Query" - }, - { - "name": "gql_query", - "type": ".google.datastore.v1.GqlQuery" - } - ], - "resultType": ".google.datastore.v1.RunQueryResponse", - "client": { - "shortName": "DatastoreClient", - "fullName": "google.datastore.v1.DatastoreClient" - }, - "method": { - "shortName": "RunQuery", - "fullName": "google.datastore.v1.Datastore.RunQuery", - "service": { - "shortName": "Datastore", - "fullName": "google.datastore.v1.Datastore" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_Datastore_BeginTransaction_async", - "title": "datastore beginTransaction Sample", - "origin": "API_DEFINITION", - "description": " Begins a new transaction.", - "canonical": true, - "file": "datastore.begin_transaction.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BeginTransaction", - "fullName": "google.datastore.v1.Datastore.BeginTransaction", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "transaction_options", - "type": ".google.datastore.v1.TransactionOptions" - } - ], - "resultType": ".google.datastore.v1.BeginTransactionResponse", - "client": { - "shortName": "DatastoreClient", - "fullName": "google.datastore.v1.DatastoreClient" - }, - "method": { - "shortName": "BeginTransaction", - "fullName": "google.datastore.v1.Datastore.BeginTransaction", - "service": { - "shortName": "Datastore", - "fullName": "google.datastore.v1.Datastore" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_Datastore_Commit_async", - "title": "datastore commit Sample", - "origin": "API_DEFINITION", - "description": " Commits a transaction, optionally creating, deleting or modifying some entities.", - "canonical": true, - "file": "datastore.commit.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 73, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Commit", - "fullName": "google.datastore.v1.Datastore.Commit", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "mode", - "type": ".google.datastore.v1.CommitRequest.Mode" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - }, - { - "name": "mutations", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.datastore.v1.CommitResponse", - "client": { - "shortName": "DatastoreClient", - "fullName": "google.datastore.v1.DatastoreClient" - }, - "method": { - "shortName": "Commit", - "fullName": "google.datastore.v1.Datastore.Commit", - "service": { - "shortName": "Datastore", - "fullName": "google.datastore.v1.Datastore" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_Datastore_Rollback_async", - "title": "datastore rollback Sample", - "origin": "API_DEFINITION", - "description": " Rolls back a transaction.", - "canonical": true, - "file": "datastore.rollback.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "Rollback", - "fullName": "google.datastore.v1.Datastore.Rollback", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "transaction", - "type": "TYPE_BYTES" - } - ], - "resultType": ".google.datastore.v1.RollbackResponse", - "client": { - "shortName": "DatastoreClient", - "fullName": "google.datastore.v1.DatastoreClient" - }, - "method": { - "shortName": "Rollback", - "fullName": "google.datastore.v1.Datastore.Rollback", - "service": { - "shortName": "Datastore", - "fullName": "google.datastore.v1.Datastore" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_Datastore_AllocateIds_async", - "title": "datastore allocateIds Sample", - "origin": "API_DEFINITION", - "description": " Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.", - "canonical": true, - "file": "datastore.allocate_ids.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AllocateIds", - "fullName": "google.datastore.v1.Datastore.AllocateIds", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "keys", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.datastore.v1.AllocateIdsResponse", - "client": { - "shortName": "DatastoreClient", - "fullName": "google.datastore.v1.DatastoreClient" - }, - "method": { - "shortName": "AllocateIds", - "fullName": "google.datastore.v1.Datastore.AllocateIds", - "service": { - "shortName": "Datastore", - "fullName": "google.datastore.v1.Datastore" - } - } - } - }, - { - "regionTag": "datastore_v1_generated_Datastore_ReserveIds_async", - "title": "datastore reserveIds Sample", - "origin": "API_DEFINITION", - "description": " Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.", - "canonical": true, - "file": "datastore.reserve_ids.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReserveIds", - "fullName": "google.datastore.v1.Datastore.ReserveIds", - "async": true, - "parameters": [ - { - "name": "project_id", - "type": "TYPE_STRING" - }, - { - "name": "database_id", - "type": "TYPE_STRING" - }, - { - "name": "keys", - "type": "TYPE_MESSAGE[]" - } - ], - "resultType": ".google.datastore.v1.ReserveIdsResponse", - "client": { - "shortName": "DatastoreClient", - "fullName": "google.datastore.v1.DatastoreClient" - }, - "method": { - "shortName": "ReserveIds", - "fullName": "google.datastore.v1.Datastore.ReserveIds", - "service": { - "shortName": "Datastore", - "fullName": "google.datastore.v1.Datastore" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 9dc4ec49b..000000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const DatastoreClient = v1.DatastoreClient; -type DatastoreClient = v1.DatastoreClient; -export {v1, DatastoreClient}; -export default {v1, DatastoreClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/datastore_client.ts b/owl-bot-staging/v1/src/v1/datastore_client.ts deleted file mode 100644 index 8147be899..000000000 --- a/owl-bot-staging/v1/src/v1/datastore_client.ts +++ /dev/null @@ -1,847 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/datastore_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './datastore_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Each RPC normalizes the partition IDs of the keys in its input entities, - * and always returns entities with keys with normalized partition IDs. - * This applies to all keys and entities, including those in values, except keys - * with both an empty path and an empty or unset partition ID. Normalization of - * input keys sets the project ID (if not already set) to the project ID from - * the request. - * - * @class - * @memberof v1 - */ -export class DatastoreClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - datastoreStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DatastoreClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DatastoreClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.datastore.v1.Datastore', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.datastoreStub) { - return this.datastoreStub; - } - - // Put together the "service stub" for - // google.datastore.v1.Datastore. - this.datastoreStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.datastore.v1.Datastore') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.datastore.v1.Datastore, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const datastoreStubMethods = - ['lookup', 'runQuery', 'beginTransaction', 'commit', 'rollback', 'allocateIds', 'reserveIds']; - for (const methodName of datastoreStubMethods) { - const callPromise = this.datastoreStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.datastoreStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'datastore.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'datastore.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/datastore' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Looks up entities by key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Required. The ID of the project against which to make the request. - * @param {google.datastore.v1.ReadOptions} request.readOptions - * The options for this lookup request. - * @param {number[]} request.keys - * Required. Keys of entities to look up. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [LookupResponse]{@link google.datastore.v1.LookupResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/datastore.lookup.js - * region_tag:datastore_v1_generated_Datastore_Lookup_async - */ - lookup( - request?: protos.google.datastore.v1.ILookupRequest, - options?: CallOptions): - Promise<[ - protos.google.datastore.v1.ILookupResponse, - protos.google.datastore.v1.ILookupRequest|undefined, {}|undefined - ]>; - lookup( - request: protos.google.datastore.v1.ILookupRequest, - options: CallOptions, - callback: Callback< - protos.google.datastore.v1.ILookupResponse, - protos.google.datastore.v1.ILookupRequest|null|undefined, - {}|null|undefined>): void; - lookup( - request: protos.google.datastore.v1.ILookupRequest, - callback: Callback< - protos.google.datastore.v1.ILookupResponse, - protos.google.datastore.v1.ILookupRequest|null|undefined, - {}|null|undefined>): void; - lookup( - request?: protos.google.datastore.v1.ILookupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.datastore.v1.ILookupResponse, - protos.google.datastore.v1.ILookupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.datastore.v1.ILookupResponse, - protos.google.datastore.v1.ILookupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.datastore.v1.ILookupResponse, - protos.google.datastore.v1.ILookupRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.lookup(request, options, callback); - } -/** - * Queries for entities. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Required. The ID of the project against which to make the request. - * @param {google.datastore.v1.PartitionId} request.partitionId - * Entities are partitioned into subsets, identified by a partition ID. - * Queries are scoped to a single partition. - * This partition ID is normalized with the standard default context - * partition ID. - * @param {google.datastore.v1.ReadOptions} request.readOptions - * The options for this query. - * @param {google.datastore.v1.Query} request.query - * The query to run. - * @param {google.datastore.v1.GqlQuery} request.gqlQuery - * The GQL query to run. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [RunQueryResponse]{@link google.datastore.v1.RunQueryResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/datastore.run_query.js - * region_tag:datastore_v1_generated_Datastore_RunQuery_async - */ - runQuery( - request?: protos.google.datastore.v1.IRunQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.datastore.v1.IRunQueryResponse, - protos.google.datastore.v1.IRunQueryRequest|undefined, {}|undefined - ]>; - runQuery( - request: protos.google.datastore.v1.IRunQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.datastore.v1.IRunQueryResponse, - protos.google.datastore.v1.IRunQueryRequest|null|undefined, - {}|null|undefined>): void; - runQuery( - request: protos.google.datastore.v1.IRunQueryRequest, - callback: Callback< - protos.google.datastore.v1.IRunQueryResponse, - protos.google.datastore.v1.IRunQueryRequest|null|undefined, - {}|null|undefined>): void; - runQuery( - request?: protos.google.datastore.v1.IRunQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.datastore.v1.IRunQueryResponse, - protos.google.datastore.v1.IRunQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.datastore.v1.IRunQueryResponse, - protos.google.datastore.v1.IRunQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.datastore.v1.IRunQueryResponse, - protos.google.datastore.v1.IRunQueryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.runQuery(request, options, callback); - } -/** - * Begins a new transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Required. The ID of the project against which to make the request. - * @param {google.datastore.v1.TransactionOptions} request.transactionOptions - * Options for a new transaction. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BeginTransactionResponse]{@link google.datastore.v1.BeginTransactionResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/datastore.begin_transaction.js - * region_tag:datastore_v1_generated_Datastore_BeginTransaction_async - */ - beginTransaction( - request?: protos.google.datastore.v1.IBeginTransactionRequest, - options?: CallOptions): - Promise<[ - protos.google.datastore.v1.IBeginTransactionResponse, - protos.google.datastore.v1.IBeginTransactionRequest|undefined, {}|undefined - ]>; - beginTransaction( - request: protos.google.datastore.v1.IBeginTransactionRequest, - options: CallOptions, - callback: Callback< - protos.google.datastore.v1.IBeginTransactionResponse, - protos.google.datastore.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): void; - beginTransaction( - request: protos.google.datastore.v1.IBeginTransactionRequest, - callback: Callback< - protos.google.datastore.v1.IBeginTransactionResponse, - protos.google.datastore.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): void; - beginTransaction( - request?: protos.google.datastore.v1.IBeginTransactionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.datastore.v1.IBeginTransactionResponse, - protos.google.datastore.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.datastore.v1.IBeginTransactionResponse, - protos.google.datastore.v1.IBeginTransactionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.datastore.v1.IBeginTransactionResponse, - protos.google.datastore.v1.IBeginTransactionRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.beginTransaction(request, options, callback); - } -/** - * Commits a transaction, optionally creating, deleting or modifying some - * entities. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Required. The ID of the project against which to make the request. - * @param {google.datastore.v1.CommitRequest.Mode} request.mode - * The type of commit to perform. Defaults to `TRANSACTIONAL`. - * @param {Buffer} request.transaction - * The identifier of the transaction associated with the commit. A - * transaction identifier is returned by a call to - * {@link google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}. - * @param {number[]} request.mutations - * The mutations to perform. - * - * When mode is `TRANSACTIONAL`, mutations affecting a single entity are - * applied in order. The following sequences of mutations affecting a single - * entity are not permitted in a single `Commit` request: - * - * - `insert` followed by `insert` - * - `update` followed by `insert` - * - `upsert` followed by `insert` - * - `delete` followed by `update` - * - * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single - * entity. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CommitResponse]{@link google.datastore.v1.CommitResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/datastore.commit.js - * region_tag:datastore_v1_generated_Datastore_Commit_async - */ - commit( - request?: protos.google.datastore.v1.ICommitRequest, - options?: CallOptions): - Promise<[ - protos.google.datastore.v1.ICommitResponse, - protos.google.datastore.v1.ICommitRequest|undefined, {}|undefined - ]>; - commit( - request: protos.google.datastore.v1.ICommitRequest, - options: CallOptions, - callback: Callback< - protos.google.datastore.v1.ICommitResponse, - protos.google.datastore.v1.ICommitRequest|null|undefined, - {}|null|undefined>): void; - commit( - request: protos.google.datastore.v1.ICommitRequest, - callback: Callback< - protos.google.datastore.v1.ICommitResponse, - protos.google.datastore.v1.ICommitRequest|null|undefined, - {}|null|undefined>): void; - commit( - request?: protos.google.datastore.v1.ICommitRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.datastore.v1.ICommitResponse, - protos.google.datastore.v1.ICommitRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.datastore.v1.ICommitResponse, - protos.google.datastore.v1.ICommitRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.datastore.v1.ICommitResponse, - protos.google.datastore.v1.ICommitRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.commit(request, options, callback); - } -/** - * Rolls back a transaction. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Required. The ID of the project against which to make the request. - * @param {Buffer} request.transaction - * Required. The transaction identifier, returned by a call to - * {@link google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [RollbackResponse]{@link google.datastore.v1.RollbackResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/datastore.rollback.js - * region_tag:datastore_v1_generated_Datastore_Rollback_async - */ - rollback( - request?: protos.google.datastore.v1.IRollbackRequest, - options?: CallOptions): - Promise<[ - protos.google.datastore.v1.IRollbackResponse, - protos.google.datastore.v1.IRollbackRequest|undefined, {}|undefined - ]>; - rollback( - request: protos.google.datastore.v1.IRollbackRequest, - options: CallOptions, - callback: Callback< - protos.google.datastore.v1.IRollbackResponse, - protos.google.datastore.v1.IRollbackRequest|null|undefined, - {}|null|undefined>): void; - rollback( - request: protos.google.datastore.v1.IRollbackRequest, - callback: Callback< - protos.google.datastore.v1.IRollbackResponse, - protos.google.datastore.v1.IRollbackRequest|null|undefined, - {}|null|undefined>): void; - rollback( - request?: protos.google.datastore.v1.IRollbackRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.datastore.v1.IRollbackResponse, - protos.google.datastore.v1.IRollbackRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.datastore.v1.IRollbackResponse, - protos.google.datastore.v1.IRollbackRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.datastore.v1.IRollbackResponse, - protos.google.datastore.v1.IRollbackRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.rollback(request, options, callback); - } -/** - * Allocates IDs for the given keys, which is useful for referencing an entity - * before it is inserted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Required. The ID of the project against which to make the request. - * @param {number[]} request.keys - * Required. A list of keys with incomplete key paths for which to allocate IDs. - * No key may be reserved/read-only. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AllocateIdsResponse]{@link google.datastore.v1.AllocateIdsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/datastore.allocate_ids.js - * region_tag:datastore_v1_generated_Datastore_AllocateIds_async - */ - allocateIds( - request?: protos.google.datastore.v1.IAllocateIdsRequest, - options?: CallOptions): - Promise<[ - protos.google.datastore.v1.IAllocateIdsResponse, - protos.google.datastore.v1.IAllocateIdsRequest|undefined, {}|undefined - ]>; - allocateIds( - request: protos.google.datastore.v1.IAllocateIdsRequest, - options: CallOptions, - callback: Callback< - protos.google.datastore.v1.IAllocateIdsResponse, - protos.google.datastore.v1.IAllocateIdsRequest|null|undefined, - {}|null|undefined>): void; - allocateIds( - request: protos.google.datastore.v1.IAllocateIdsRequest, - callback: Callback< - protos.google.datastore.v1.IAllocateIdsResponse, - protos.google.datastore.v1.IAllocateIdsRequest|null|undefined, - {}|null|undefined>): void; - allocateIds( - request?: protos.google.datastore.v1.IAllocateIdsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.datastore.v1.IAllocateIdsResponse, - protos.google.datastore.v1.IAllocateIdsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.datastore.v1.IAllocateIdsResponse, - protos.google.datastore.v1.IAllocateIdsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.datastore.v1.IAllocateIdsResponse, - protos.google.datastore.v1.IAllocateIdsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.allocateIds(request, options, callback); - } -/** - * Prevents the supplied keys' IDs from being auto-allocated by Cloud - * Datastore. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.projectId - * Required. The ID of the project against which to make the request. - * @param {string} request.databaseId - * If not empty, the ID of the database against which to make the request. - * @param {number[]} request.keys - * Required. A list of keys with complete key paths whose numeric IDs should not be - * auto-allocated. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ReserveIdsResponse]{@link google.datastore.v1.ReserveIdsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/datastore.reserve_ids.js - * region_tag:datastore_v1_generated_Datastore_ReserveIds_async - */ - reserveIds( - request?: protos.google.datastore.v1.IReserveIdsRequest, - options?: CallOptions): - Promise<[ - protos.google.datastore.v1.IReserveIdsResponse, - protos.google.datastore.v1.IReserveIdsRequest|undefined, {}|undefined - ]>; - reserveIds( - request: protos.google.datastore.v1.IReserveIdsRequest, - options: CallOptions, - callback: Callback< - protos.google.datastore.v1.IReserveIdsResponse, - protos.google.datastore.v1.IReserveIdsRequest|null|undefined, - {}|null|undefined>): void; - reserveIds( - request: protos.google.datastore.v1.IReserveIdsRequest, - callback: Callback< - protos.google.datastore.v1.IReserveIdsResponse, - protos.google.datastore.v1.IReserveIdsRequest|null|undefined, - {}|null|undefined>): void; - reserveIds( - request?: protos.google.datastore.v1.IReserveIdsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.datastore.v1.IReserveIdsResponse, - protos.google.datastore.v1.IReserveIdsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.datastore.v1.IReserveIdsResponse, - protos.google.datastore.v1.IReserveIdsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.datastore.v1.IReserveIdsResponse, - protos.google.datastore.v1.IReserveIdsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'project_id': request.projectId || '', - }); - this.initialize(); - return this.innerApiCalls.reserveIds(request, options, callback); - } - - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.datastoreStub && !this._terminated) { - return this.datastoreStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/datastore_client_config.json b/owl-bot-staging/v1/src/v1/datastore_client_config.json deleted file mode 100644 index 37bd1c737..000000000 --- a/owl-bot-staging/v1/src/v1/datastore_client_config.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "interfaces": { - "google.datastore.v1.Datastore": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "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": { - "Lookup": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "RunQuery": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "BeginTransaction": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "Commit": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "Rollback": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "AllocateIds": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ReserveIds": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/datastore_proto_list.json b/owl-bot-staging/v1/src/v1/datastore_proto_list.json deleted file mode 100644 index 0636f1215..000000000 --- a/owl-bot-staging/v1/src/v1/datastore_proto_list.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - "../../protos/google/datastore/v1/datastore.proto", - "../../protos/google/datastore/v1/entity.proto", - "../../protos/google/datastore/v1/query.proto" -] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index d5eb8d916..000000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.datastore.v1", - "libraryPackage": "@google-cloud/datastore", - "services": { - "Datastore": { - "clients": { - "grpc": { - "libraryClient": "DatastoreClient", - "rpcs": { - "Lookup": { - "methods": [ - "lookup" - ] - }, - "RunQuery": { - "methods": [ - "runQuery" - ] - }, - "BeginTransaction": { - "methods": [ - "beginTransaction" - ] - }, - "Commit": { - "methods": [ - "commit" - ] - }, - "Rollback": { - "methods": [ - "rollback" - ] - }, - "AllocateIds": { - "methods": [ - "allocateIds" - ] - }, - "ReserveIds": { - "methods": [ - "reserveIds" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DatastoreClient", - "rpcs": { - "Lookup": { - "methods": [ - "lookup" - ] - }, - "RunQuery": { - "methods": [ - "runQuery" - ] - }, - "BeginTransaction": { - "methods": [ - "beginTransaction" - ] - }, - "Commit": { - "methods": [ - "commit" - ] - }, - "Rollback": { - "methods": [ - "rollback" - ] - }, - "AllocateIds": { - "methods": [ - "allocateIds" - ] - }, - "ReserveIds": { - "methods": [ - "reserveIds" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 63381b364..000000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {DatastoreClient} from './datastore_client'; diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 5dbaf7a7b..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const datastore = require('@google-cloud/datastore'); - -function main() { - const datastoreClient = new datastore.DatastoreClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 28b7ce4d6..000000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {DatastoreClient} from '@google-cloud/datastore'; - -// check that the client class type name can be used -function doStuffWithDatastoreClient(client: DatastoreClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const datastoreClient = new DatastoreClient(); - doStuffWithDatastoreClient(datastoreClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 8ec452229..000000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1/test/gapic_datastore_v1.ts b/owl-bot-staging/v1/test/gapic_datastore_v1.ts deleted file mode 100644 index 4a4d331c6..000000000 --- a/owl-bot-staging/v1/test/gapic_datastore_v1.ts +++ /dev/null @@ -1,814 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as datastoreModule from '../src'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -describe('v1.DatastoreClient', () => { - it('has servicePath', () => { - const servicePath = datastoreModule.v1.DatastoreClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = datastoreModule.v1.DatastoreClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = datastoreModule.v1.DatastoreClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new datastoreModule.v1.DatastoreClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new datastoreModule.v1.DatastoreClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.datastoreStub, undefined); - await client.initialize(); - assert(client.datastoreStub); - }); - - it('has close method for the initialized client', done => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.datastoreStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.datastoreStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('lookup', () => { - it('invokes lookup without error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.LookupRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.LookupResponse()); - client.innerApiCalls.lookup = stubSimpleCall(expectedResponse); - const [response] = await client.lookup(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.lookup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes lookup without error using callback', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.LookupRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.LookupResponse()); - client.innerApiCalls.lookup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.lookup( - request, - (err?: Error|null, result?: protos.google.datastore.v1.ILookupResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.lookup as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes lookup with error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.LookupRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.lookup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.lookup(request), expectedError); - assert((client.innerApiCalls.lookup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes lookup with closed client', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.LookupRequest()); - request.projectId = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.lookup(request), expectedError); - }); - }); - - describe('runQuery', () => { - it('invokes runQuery without error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.RunQueryRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.RunQueryResponse()); - client.innerApiCalls.runQuery = stubSimpleCall(expectedResponse); - const [response] = await client.runQuery(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.runQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes runQuery without error using callback', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.RunQueryRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.RunQueryResponse()); - client.innerApiCalls.runQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runQuery( - request, - (err?: Error|null, result?: protos.google.datastore.v1.IRunQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.runQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes runQuery with error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.RunQueryRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.runQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.runQuery(request), expectedError); - assert((client.innerApiCalls.runQuery as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes runQuery with closed client', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.RunQueryRequest()); - request.projectId = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.runQuery(request), expectedError); - }); - }); - - describe('beginTransaction', () => { - it('invokes beginTransaction without error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionResponse()); - client.innerApiCalls.beginTransaction = stubSimpleCall(expectedResponse); - const [response] = await client.beginTransaction(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes beginTransaction without error using callback', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionResponse()); - client.innerApiCalls.beginTransaction = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.beginTransaction( - request, - (err?: Error|null, result?: protos.google.datastore.v1.IBeginTransactionResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes beginTransaction with error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.beginTransaction = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.beginTransaction(request), expectedError); - assert((client.innerApiCalls.beginTransaction as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes beginTransaction with closed client', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.BeginTransactionRequest()); - request.projectId = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.beginTransaction(request), expectedError); - }); - }); - - describe('commit', () => { - it('invokes commit without error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.CommitRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.CommitResponse()); - client.innerApiCalls.commit = stubSimpleCall(expectedResponse); - const [response] = await client.commit(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.commit as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes commit without error using callback', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.CommitRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.CommitResponse()); - client.innerApiCalls.commit = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.commit( - request, - (err?: Error|null, result?: protos.google.datastore.v1.ICommitResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.commit as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes commit with error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.CommitRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.commit = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.commit(request), expectedError); - assert((client.innerApiCalls.commit as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes commit with closed client', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.CommitRequest()); - request.projectId = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.commit(request), expectedError); - }); - }); - - describe('rollback', () => { - it('invokes rollback without error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.RollbackRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.RollbackResponse()); - client.innerApiCalls.rollback = stubSimpleCall(expectedResponse); - const [response] = await client.rollback(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rollback as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rollback without error using callback', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.RollbackRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.RollbackResponse()); - client.innerApiCalls.rollback = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rollback( - request, - (err?: Error|null, result?: protos.google.datastore.v1.IRollbackResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.rollback as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes rollback with error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.RollbackRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.rollback = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rollback(request), expectedError); - assert((client.innerApiCalls.rollback as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes rollback with closed client', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.RollbackRequest()); - request.projectId = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.rollback(request), expectedError); - }); - }); - - describe('allocateIds', () => { - it('invokes allocateIds without error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsResponse()); - client.innerApiCalls.allocateIds = stubSimpleCall(expectedResponse); - const [response] = await client.allocateIds(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.allocateIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes allocateIds without error using callback', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsResponse()); - client.innerApiCalls.allocateIds = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.allocateIds( - request, - (err?: Error|null, result?: protos.google.datastore.v1.IAllocateIdsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.allocateIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes allocateIds with error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.allocateIds = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.allocateIds(request), expectedError); - assert((client.innerApiCalls.allocateIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes allocateIds with closed client', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.AllocateIdsRequest()); - request.projectId = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.allocateIds(request), expectedError); - }); - }); - - describe('reserveIds', () => { - it('invokes reserveIds without error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsResponse()); - client.innerApiCalls.reserveIds = stubSimpleCall(expectedResponse); - const [response] = await client.reserveIds(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.reserveIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes reserveIds without error using callback', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsResponse()); - client.innerApiCalls.reserveIds = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reserveIds( - request, - (err?: Error|null, result?: protos.google.datastore.v1.IReserveIdsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.reserveIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes reserveIds with error', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsRequest()); - request.projectId = ''; - const expectedHeaderRequestParams = "project_id="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.reserveIds = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.reserveIds(request), expectedError); - assert((client.innerApiCalls.reserveIds as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes reserveIds with closed client', async () => { - const client = new datastoreModule.v1.DatastoreClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.datastore.v1.ReserveIdsRequest()); - request.projectId = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.reserveIds(request), expectedError); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c884..000000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index 6df22195e..000000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'datastore', - filename: './datastore.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/src/v1/datastore_admin_client.ts b/src/v1/datastore_admin_client.ts index 2ebe98405..8f52e460a 100644 --- a/src/v1/datastore_admin_client.ts +++ b/src/v1/datastore_admin_client.ts @@ -23,6 +23,7 @@ import { CallOptions, Descriptors, ClientOptions, + GrpcClientOptions, LROperation, PaginationCallback, GaxCall, @@ -131,7 +132,7 @@ export class DatastoreAdminClient { * * @param {object} [options] - The configuration object. * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] @@ -154,11 +155,10 @@ export class DatastoreAdminClient { * API remote host. * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. */ constructor(opts?: ClientOptions) { // Ensure that options include all the required fields. @@ -233,16 +233,36 @@ export class DatastoreAdminClient { }; const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. - + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [ + { + 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', + }, + ]; + } this.operationsClient = this._gaxModule - .lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }) + .lro(lroOptions) .operationsClient(opts); const exportEntitiesResponse = protoFilesRoot.lookup( '.google.datastore.admin.v1.ExportEntitiesResponse' diff --git a/src/v1/datastore_client.ts b/src/v1/datastore_client.ts index 0b332a977..d75cf5a15 100644 --- a/src/v1/datastore_client.ts +++ b/src/v1/datastore_client.ts @@ -66,7 +66,7 @@ export class DatastoreClient { * * @param {object} [options] - The configuration object. * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] @@ -89,11 +89,10 @@ export class DatastoreClient { * API remote host. * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. */ constructor(opts?: ClientOptions) { // Ensure that options include all the required fields.