From 99beb87f839c8780f2a12b078a5bdd73f280b4e6 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 24 Jun 2022 10:08:00 +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/v3/.eslintignore | 7 + owl-bot-staging/v3/.eslintrc.json | 3 + owl-bot-staging/v3/.gitignore | 14 + owl-bot-staging/v3/.jsdoc.js | 55 + owl-bot-staging/v3/.mocharc.js | 33 + owl-bot-staging/v3/.prettierrc.js | 22 + owl-bot-staging/v3/README.md | 1 + owl-bot-staging/v3/linkinator.config.json | 16 + owl-bot-staging/v3/package.json | 69 + .../cloud/resourcemanager/v3/folders.proto | 536 +++++ .../resourcemanager/v3/organizations.proto | 237 ++ .../cloud/resourcemanager/v3/projects.proto | 640 +++++ .../resourcemanager/v3/tag_bindings.proto | 177 ++ .../cloud/resourcemanager/v3/tag_keys.proto | 300 +++ .../cloud/resourcemanager/v3/tag_values.proto | 296 +++ .../generated/v3/folders.create_folder.js | 60 + .../generated/v3/folders.delete_folder.js | 60 + .../generated/v3/folders.get_folder.js | 59 + .../generated/v3/folders.get_iam_policy.js | 64 + .../generated/v3/folders.list_folders.js | 80 + .../generated/v3/folders.move_folder.js | 67 + .../generated/v3/folders.search_folders.js | 94 + .../generated/v3/folders.set_iam_policy.js | 74 + .../v3/folders.test_iam_permissions.js | 67 + .../generated/v3/folders.undelete_folder.js | 60 + .../generated/v3/folders.update_folder.js | 66 + .../v3/organizations.get_iam_policy.js | 64 + .../v3/organizations.get_organization.js | 60 + .../v3/organizations.search_organizations.js | 83 + .../v3/organizations.set_iam_policy.js | 74 + .../v3/organizations.test_iam_permissions.js | 67 + .../generated/v3/projects.create_project.js | 65 + .../generated/v3/projects.delete_project.js | 59 + .../generated/v3/projects.get_iam_policy.js | 64 + .../generated/v3/projects.get_project.js | 58 + .../generated/v3/projects.list_projects.js | 79 + .../generated/v3/projects.move_project.js | 64 + .../generated/v3/projects.search_projects.js | 104 + .../generated/v3/projects.set_iam_policy.js | 74 + .../v3/projects.test_iam_permissions.js | 67 + .../generated/v3/projects.undelete_project.js | 60 + .../generated/v3/projects.update_project.js | 63 + ...adata.google.cloud.resourcemanager.v3.json | 2067 +++++++++++++++++ .../v3/tag_bindings.create_tag_binding.js | 64 + .../v3/tag_bindings.delete_tag_binding.js | 61 + .../v3/tag_bindings.list_tag_bindings.js | 73 + .../generated/v3/tag_keys.create_tag_key.js | 65 + .../generated/v3/tag_keys.delete_tag_key.js | 71 + .../generated/v3/tag_keys.get_iam_policy.js | 64 + .../generated/v3/tag_keys.get_tag_key.js | 59 + .../generated/v3/tag_keys.list_tag_keys.js | 72 + .../generated/v3/tag_keys.set_iam_policy.js | 74 + .../v3/tag_keys.test_iam_permissions.js | 67 + .../generated/v3/tag_keys.update_tag_key.js | 73 + .../v3/tag_values.create_tag_value.js | 65 + .../v3/tag_values.delete_tag_value.js | 69 + .../generated/v3/tag_values.get_iam_policy.js | 64 + .../generated/v3/tag_values.get_tag_value.js | 58 + .../v3/tag_values.list_tag_values.js | 72 + .../generated/v3/tag_values.set_iam_policy.js | 74 + .../v3/tag_values.test_iam_permissions.js | 67 + .../v3/tag_values.update_tag_value.js | 71 + owl-bot-staging/v3/src/index.ts | 35 + owl-bot-staging/v3/src/v3/folders_client.ts | 1844 +++++++++++++++ .../v3/src/v3/folders_client_config.json | 83 + .../v3/src/v3/folders_proto_list.json | 8 + owl-bot-staging/v3/src/v3/gapic_metadata.json | 585 +++++ owl-bot-staging/v3/src/v3/index.ts | 24 + .../v3/src/v3/organizations_client.ts | 1013 ++++++++ .../src/v3/organizations_client_config.json | 53 + .../v3/src/v3/organizations_proto_list.json | 8 + owl-bot-staging/v3/src/v3/projects_client.ts | 1896 +++++++++++++++ .../v3/src/v3/projects_client_config.json | 83 + .../v3/src/v3/projects_proto_list.json | 8 + .../v3/src/v3/tag_bindings_client.ts | 867 +++++++ .../v3/src/v3/tag_bindings_client_config.json | 44 + .../v3/src/v3/tag_bindings_proto_list.json | 8 + owl-bot-staging/v3/src/v3/tag_keys_client.ts | 1299 +++++++++++ .../v3/src/v3/tag_keys_client_config.json | 68 + .../v3/src/v3/tag_keys_proto_list.json | 8 + .../v3/src/v3/tag_values_client.ts | 1295 +++++++++++ .../v3/src/v3/tag_values_client_config.json | 68 + .../v3/src/v3/tag_values_proto_list.json | 8 + .../system-test/fixtures/sample/src/index.js | 32 + .../system-test/fixtures/sample/src/index.ts | 62 + owl-bot-staging/v3/system-test/install.ts | 49 + owl-bot-staging/v3/test/gapic_folders_v3.ts | 1803 ++++++++++++++ .../v3/test/gapic_organizations_v3.ts | 924 ++++++++ owl-bot-staging/v3/test/gapic_projects_v3.ts | 1803 ++++++++++++++ .../v3/test/gapic_tag_bindings_v3.ts | 808 +++++++ owl-bot-staging/v3/test/gapic_tag_keys_v3.ts | 1344 +++++++++++ .../v3/test/gapic_tag_values_v3.ts | 1344 +++++++++++ owl-bot-staging/v3/tsconfig.json | 19 + owl-bot-staging/v3/webpack.config.js | 64 + 94 files changed, 25169 insertions(+) create mode 100644 owl-bot-staging/v3/.eslintignore create mode 100644 owl-bot-staging/v3/.eslintrc.json create mode 100644 owl-bot-staging/v3/.gitignore create mode 100644 owl-bot-staging/v3/.jsdoc.js create mode 100644 owl-bot-staging/v3/.mocharc.js create mode 100644 owl-bot-staging/v3/.prettierrc.js create mode 100644 owl-bot-staging/v3/README.md create mode 100644 owl-bot-staging/v3/linkinator.config.json create mode 100644 owl-bot-staging/v3/package.json create mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/folders.proto create mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/organizations.proto create mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/projects.proto create mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto create mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto create mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.create_folder.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.delete_folder.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.get_folder.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.get_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.list_folders.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.move_folder.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.search_folders.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.set_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.test_iam_permissions.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.undelete_folder.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.update_folder.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.get_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.get_organization.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.search_organizations.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.set_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.test_iam_permissions.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.create_project.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.delete_project.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.get_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.get_project.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.list_projects.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.move_project.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.search_projects.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.set_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.test_iam_permissions.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.undelete_project.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.update_project.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/snippet_metadata.google.cloud.resourcemanager.v3.json create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_bindings.create_tag_binding.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.create_tag_key.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.delete_tag_key.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.get_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.get_tag_key.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.list_tag_keys.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.set_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.test_iam_permissions.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.update_tag_key.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.create_tag_value.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.delete_tag_value.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.get_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.get_tag_value.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.list_tag_values.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.set_iam_policy.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.test_iam_permissions.js create mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.update_tag_value.js create mode 100644 owl-bot-staging/v3/src/index.ts create mode 100644 owl-bot-staging/v3/src/v3/folders_client.ts create mode 100644 owl-bot-staging/v3/src/v3/folders_client_config.json create mode 100644 owl-bot-staging/v3/src/v3/folders_proto_list.json create mode 100644 owl-bot-staging/v3/src/v3/gapic_metadata.json create mode 100644 owl-bot-staging/v3/src/v3/index.ts create mode 100644 owl-bot-staging/v3/src/v3/organizations_client.ts create mode 100644 owl-bot-staging/v3/src/v3/organizations_client_config.json create mode 100644 owl-bot-staging/v3/src/v3/organizations_proto_list.json create mode 100644 owl-bot-staging/v3/src/v3/projects_client.ts create mode 100644 owl-bot-staging/v3/src/v3/projects_client_config.json create mode 100644 owl-bot-staging/v3/src/v3/projects_proto_list.json create mode 100644 owl-bot-staging/v3/src/v3/tag_bindings_client.ts create mode 100644 owl-bot-staging/v3/src/v3/tag_bindings_client_config.json create mode 100644 owl-bot-staging/v3/src/v3/tag_bindings_proto_list.json create mode 100644 owl-bot-staging/v3/src/v3/tag_keys_client.ts create mode 100644 owl-bot-staging/v3/src/v3/tag_keys_client_config.json create mode 100644 owl-bot-staging/v3/src/v3/tag_keys_proto_list.json create mode 100644 owl-bot-staging/v3/src/v3/tag_values_client.ts create mode 100644 owl-bot-staging/v3/src/v3/tag_values_client_config.json create mode 100644 owl-bot-staging/v3/src/v3/tag_values_proto_list.json create mode 100644 owl-bot-staging/v3/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v3/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v3/system-test/install.ts create mode 100644 owl-bot-staging/v3/test/gapic_folders_v3.ts create mode 100644 owl-bot-staging/v3/test/gapic_organizations_v3.ts create mode 100644 owl-bot-staging/v3/test/gapic_projects_v3.ts create mode 100644 owl-bot-staging/v3/test/gapic_tag_bindings_v3.ts create mode 100644 owl-bot-staging/v3/test/gapic_tag_keys_v3.ts create mode 100644 owl-bot-staging/v3/test/gapic_tag_values_v3.ts create mode 100644 owl-bot-staging/v3/tsconfig.json create mode 100644 owl-bot-staging/v3/webpack.config.js diff --git a/owl-bot-staging/v3/.eslintignore b/owl-bot-staging/v3/.eslintignore new file mode 100644 index 0000000..cfc348e --- /dev/null +++ b/owl-bot-staging/v3/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v3/.eslintrc.json b/owl-bot-staging/v3/.eslintrc.json new file mode 100644 index 0000000..7821534 --- /dev/null +++ b/owl-bot-staging/v3/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v3/.gitignore b/owl-bot-staging/v3/.gitignore new file mode 100644 index 0000000..5d32b23 --- /dev/null +++ b/owl-bot-staging/v3/.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/v3/.jsdoc.js b/owl-bot-staging/v3/.jsdoc.js new file mode 100644 index 0000000..ccd2dc4 --- /dev/null +++ b/owl-bot-staging/v3/.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/resource-manager', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v3/.mocharc.js b/owl-bot-staging/v3/.mocharc.js new file mode 100644 index 0000000..481c522 --- /dev/null +++ b/owl-bot-staging/v3/.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/v3/.prettierrc.js b/owl-bot-staging/v3/.prettierrc.js new file mode 100644 index 0000000..494e147 --- /dev/null +++ b/owl-bot-staging/v3/.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/v3/README.md b/owl-bot-staging/v3/README.md new file mode 100644 index 0000000..3dd631a --- /dev/null +++ b/owl-bot-staging/v3/README.md @@ -0,0 +1 @@ +Resourcemanager: Nodejs Client diff --git a/owl-bot-staging/v3/linkinator.config.json b/owl-bot-staging/v3/linkinator.config.json new file mode 100644 index 0000000..befd23c --- /dev/null +++ b/owl-bot-staging/v3/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/v3/package.json b/owl-bot-staging/v3/package.json new file mode 100644 index 0000000..a440e2a --- /dev/null +++ b/owl-bot-staging/v3/package.json @@ -0,0 +1,69 @@ +{ + "name": "@google-cloud/resource-manager", + "version": "0.1.0", + "description": "Resourcemanager client for Node.js", + "repository": "googleapis/nodejs-resourcemanager", + "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 resourcemanager", + "resourcemanager", + "folders", + "organizations", + "projects", + "tag bindings", + "tag keys", + "tag values" + ], + "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/v3/protos/google/cloud/resourcemanager/v3/folders.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/folders.proto new file mode 100644 index 0000000..af87809 --- /dev/null +++ b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/folders.proto @@ -0,0 +1,536 @@ +// 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 +// +// 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.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; +option java_multiple_files = true; +option java_outer_classname = "FoldersProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Manages Cloud Platform folder resources. +// Folders can be used to organize the resources under an +// organization and to control the policies applied to groups of resources. +service Folders { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Retrieves a folder identified by the supplied resource name. + // Valid folder resource names have the format `folders/{folder_id}` + // (for example, `folders/1234`). + // The caller must have `resourcemanager.folders.get` permission on the + // identified folder. + rpc GetFolder(GetFolderRequest) returns (Folder) { + option (google.api.http) = { + get: "/v3/{name=folders/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists the folders that are direct descendants of supplied parent resource. + // `list()` provides a strongly consistent view of the folders underneath + // the specified parent resource. + // `list()` returns folders sorted based upon the (ascending) lexical ordering + // of their display_name. + // The caller must have `resourcemanager.folders.list` permission on the + // identified parent. + rpc ListFolders(ListFoldersRequest) returns (ListFoldersResponse) { + option (google.api.http) = { + get: "/v3/folders" + }; + option (google.api.method_signature) = "parent"; + } + + // Search for folders that match specific filter criteria. + // `search()` provides an eventually consistent view of the folders a user has + // access to which meet the specified filter criteria. + // + // This will only return folders on which the caller has the + // permission `resourcemanager.folders.get`. + rpc SearchFolders(SearchFoldersRequest) returns (SearchFoldersResponse) { + option (google.api.http) = { + get: "/v3/folders:search" + }; + option (google.api.method_signature) = "query"; + } + + // Creates a folder in the resource hierarchy. + // Returns an `Operation` which can be used to track the progress of the + // folder creation workflow. + // Upon success, the `Operation.response` field will be populated with the + // created Folder. + // + // In order to succeed, the addition of this new folder must not violate + // the folder naming, height, or fanout constraints. + // + // + The folder's `display_name` must be distinct from all other folders that + // share its parent. + // + The addition of the folder must not cause the active folder hierarchy + // to exceed a height of 10. Note, the full active + deleted folder hierarchy + // is allowed to reach a height of 20; this provides additional headroom when + // moving folders that contain deleted folders. + // + The addition of the folder must not cause the total number of folders + // under its parent to exceed 300. + // + // If the operation fails due to a folder constraint violation, some errors + // may be returned by the `CreateFolder` request, with status code + // `FAILED_PRECONDITION` and an error description. Other folder constraint + // violations will be communicated in the `Operation`, with the specific + // `PreconditionFailure` returned in the details list in the `Operation.error` + // field. + // + // The caller must have `resourcemanager.folders.create` permission on the + // identified parent. + rpc CreateFolder(CreateFolderRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/folders" + body: "folder" + }; + option (google.api.method_signature) = "folder"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "CreateFolderMetadata" + }; + } + + // Updates a folder, changing its `display_name`. + // Changes to the folder `display_name` will be rejected if they violate + // either the `display_name` formatting rules or the naming constraints + // described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. + // + // The folder's `display_name` must start and end with a letter or digit, + // may contain letters, digits, spaces, hyphens and underscores and can be + // between 3 and 30 characters. This is captured by the regular expression: + // `[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]`. + // The caller must have `resourcemanager.folders.update` permission on the + // identified folder. + // + // If the update fails due to the unique name constraint then a + // `PreconditionFailure` explaining this violation will be returned + // in the Status.details field. + rpc UpdateFolder(UpdateFolderRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v3/{folder.name=folders/*}" + body: "folder" + }; + option (google.api.method_signature) = "folder,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "UpdateFolderMetadata" + }; + } + + // Moves a folder under a new resource parent. + // Returns an `Operation` which can be used to track the progress of the + // folder move workflow. + // Upon success, the `Operation.response` field will be populated with the + // moved folder. + // Upon failure, a `FolderOperationError` categorizing the failure cause will + // be returned - if the failure occurs synchronously then the + // `FolderOperationError` will be returned in the `Status.details` field. + // If it occurs asynchronously, then the FolderOperation will be returned + // in the `Operation.error` field. + // In addition, the `Operation.metadata` field will be populated with a + // `FolderOperation` message as an aid to stateless clients. + // Folder moves will be rejected if they violate either the naming, height, + // or fanout constraints described in the + // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. + // The caller must have `resourcemanager.folders.move` permission on the + // folder's current and proposed new parent. + rpc MoveFolder(MoveFolderRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{name=folders/*}:move" + body: "*" + }; + option (google.api.method_signature) = "name,destination_parent"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "MoveFolderMetadata" + }; + } + + // Requests deletion of a folder. The folder is moved into the + // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state + // immediately, and is deleted approximately 30 days later. This method may + // only be called on an empty folder, where a folder is empty if it doesn't + // contain any folders or projects in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. + // If called on a folder in [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] + // state the operation will result in a no-op success. + // The caller must have `resourcemanager.folders.delete` permission on the + // identified folder. + rpc DeleteFolder(DeleteFolderRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=folders/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "DeleteFolderMetadata" + }; + } + + // Cancels the deletion request for a folder. This method may be called on a + // folder in any state. If the folder is in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] + // state the result will be a no-op success. In order to succeed, the folder's + // parent must be in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In addition, + // reintroducing the folder into the tree must not violate folder naming, + // height, and fanout constraints described in the + // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. + // The caller must have `resourcemanager.folders.undelete` permission on the + // identified folder. + rpc UndeleteFolder(UndeleteFolderRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{name=folders/*}:undelete" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Folder" + metadata_type: "UndeleteFolderMetadata" + }; + } + + // Gets the access control policy for a folder. The returned policy may be + // empty if no such policy or resource exists. The `resource` field should + // be the folder's resource name, for example: "folders/1234". + // The caller must have `resourcemanager.folders.getIamPolicy` permission + // on the identified folder. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=folders/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy on a folder, replacing any existing policy. + // The `resource` field should be the folder's resource name, for example: + // "folders/1234". + // The caller must have `resourcemanager.folders.setIamPolicy` permission + // on the identified folder. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=folders/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Returns permissions that a caller has on the specified folder. + // The `resource` field should be the folder's resource name, + // for example: "folders/1234". + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=folders/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// A folder in an organization's resource hierarchy, used to +// organize that organization's resources. +message Folder { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/Folder" + pattern: "folders/{folder}" + style: DECLARATIVE_FRIENDLY + }; + + // Folder lifecycle states. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 1; + + // The folder has been marked for deletion by the user. + DELETE_REQUESTED = 2; + } + + // Output only. The resource name of the folder. + // Its format is `folders/{folder_id}`, for example: "folders/1234". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The folder's parent's resource name. + // Updates to the folder's parent must be performed using + // [MoveFolder][google.cloud.resourcemanager.v3.Folders.MoveFolder]. + string parent = 2 [(google.api.field_behavior) = REQUIRED]; + + // The folder's display name. + // A folder's display name must be unique amongst its siblings. For example, + // no two folders with the same parent can share the same display name. + // The display name must start and end with a letter or digit, may contain + // letters, digits, spaces, hyphens and underscores and can be no longer + // than 30 characters. This is captured by the regular expression: + // `[\p{L}\p{N}]([\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?`. + string display_name = 3; + + // Output only. The lifecycle state of the folder. + // Updates to the state must be performed using + // [DeleteFolder][google.cloud.resourcemanager.v3.Folders.DeleteFolder] and + // [UndeleteFolder][google.cloud.resourcemanager.v3.Folders.UndeleteFolder]. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the folder was created. + google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the folder was last modified. + google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the folder was requested to be deleted. + google.protobuf.Timestamp delete_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A checksum computed by the server based on the current value of the folder + // resource. This may be sent on update and delete requests to ensure the + // client has an up-to-date value before proceeding. + string etag = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The GetFolder request message. +message GetFolderRequest { + // Required. The resource name of the folder to retrieve. + // Must be of the form `folders/{folder_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Folder" + } + ]; +} + +// The ListFolders request message. +message ListFoldersRequest { + // Required. The resource name of the organization or folder whose folders are + // being listed. + // Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + // Access to this method is controlled by checking the + // `resourcemanager.folders.list` permission on the `parent`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "*" + } + ]; + + // Optional. The maximum number of folders to return in the response. + // If unspecified, server picks an appropriate default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `ListFolders` + // that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Controls whether folders in the + // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] + // state should be returned. Defaults to false. + bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// The ListFolders response message. +message ListFoldersResponse { + // A possibly paginated list of folders that are direct descendants of + // the specified parent resource. + repeated Folder folders = 1; + + // A pagination token returned from a previous call to `ListFolders` + // that indicates from where listing should continue. + string next_page_token = 2; +} + +// The request message for searching folders. +message SearchFoldersRequest { + // Optional. The maximum number of folders to return in the response. + // If unspecified, server picks an appropriate default. + int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `SearchFolders` + // that indicates from where search should continue. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Search criteria used to select the folders to return. + // If no search criteria is specified then all accessible folders will be + // returned. + // + // Query expressions can be used to restrict results based upon displayName, + // state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + // can be used along with the suffix wildcard symbol `*`. + // + // The `displayName` field in a query expression should use escaped quotes + // for values that include whitespace to prevent unexpected behavior. + // + // ``` + // | Field | Description | + // |-------------------------|----------------------------------------| + // | displayName | Filters by displayName. | + // | parent | Filters by parent (for example: folders/123). | + // | state, lifecycleState | Filters by state. | + // ``` + // + // Some example queries are: + // + // * Query `displayName=Test*` returns Folder resources whose display name + // starts with "Test". + // * Query `state=ACTIVE` returns Folder resources with + // `state` set to `ACTIVE`. + // * Query `parent=folders/123` returns Folder resources that have + // `folders/123` as a parent resource. + // * Query `parent=folders/123 AND state=ACTIVE` returns active + // Folder resources that have `folders/123` as a parent resource. + // * Query `displayName=\\"Test String\\"` returns Folder resources with + // display names that include both "Test" and "String". + string query = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response message for searching folders. +message SearchFoldersResponse { + // A possibly paginated folder search results. + // the specified parent resource. + repeated Folder folders = 1; + + // A pagination token returned from a previous call to `SearchFolders` + // that indicates from where searching should continue. + string next_page_token = 2; +} + +// The CreateFolder request message. +message CreateFolderRequest { + // Required. The folder being created, only the display name and parent will be + // consulted. All other fields will be ignored. + Folder folder = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Metadata pertaining to the Folder creation process. +message CreateFolderMetadata { + // The display name of the folder. + string display_name = 1; + + // The resource name of the folder or organization we are creating the folder + // under. + string parent = 2; +} + +// The request sent to the +// [UpdateFolder][google.cloud.resourcemanager.v3.Folder.UpdateFolder] +// method. +// +// Only the `display_name` field can be changed. All other fields will be +// ignored. Use the +// [MoveFolder][google.cloud.resourcemanager.v3.Folders.MoveFolder] method to +// change the `parent` field. +message UpdateFolderRequest { + // Required. The new definition of the Folder. It must include the `name` field, which + // cannot be changed. + Folder folder = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Fields to be updated. + // Only the `display_name` can be updated. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by UpdateFolder. +message UpdateFolderMetadata { + +} + +// The MoveFolder request message. +message MoveFolderRequest { + // Required. The resource name of the Folder to move. + // Must be of the form folders/{folder_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Folder" + } + ]; + + // Required. The resource name of the folder or organization which should be the + // folder's new parent. + // Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + string destination_parent = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "*" + } + ]; +} + +// Metadata pertaining to the folder move process. +message MoveFolderMetadata { + // The display name of the folder. + string display_name = 1; + + // The resource name of the folder's parent. + string source_parent = 2; + + // The resource name of the folder or organization to move the folder to. + string destination_parent = 3; +} + +// The DeleteFolder request message. +message DeleteFolderRequest { + // Required. The resource name of the folder to be deleted. + // Must be of the form `folders/{folder_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Folder" + } + ]; +} + +// A status object which is used as the `metadata` field for the `Operation` +// returned by `DeleteFolder`. +message DeleteFolderMetadata { + +} + +// The UndeleteFolder request message. +message UndeleteFolderRequest { + // Required. The resource name of the folder to undelete. + // Must be of the form `folders/{folder_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Folder" + } + ]; +} + +// A status object which is used as the `metadata` field for the `Operation` +// returned by `UndeleteFolder`. +message UndeleteFolderMetadata { + +} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/organizations.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/organizations.proto new file mode 100644 index 0000000..0474ca2 --- /dev/null +++ b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/organizations.proto @@ -0,0 +1,237 @@ +// 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 +// +// 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.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; +option java_multiple_files = true; +option java_outer_classname = "OrganizationsProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Allows users to manage their organization resources. +service Organizations { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Fetches an organization resource identified by the specified resource name. + rpc GetOrganization(GetOrganizationRequest) returns (Organization) { + option (google.api.http) = { + get: "/v3/{name=organizations/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Searches organization resources that are visible to the user and satisfy + // the specified filter. This method returns organizations in an unspecified + // order. New organizations do not necessarily appear at the end of the + // results, and may take a small amount of time to appear. + // + // Search will only return organizations on which the user has the permission + // `resourcemanager.organizations.get` + rpc SearchOrganizations(SearchOrganizationsRequest) returns (SearchOrganizationsResponse) { + option (google.api.http) = { + get: "/v3/organizations:search" + }; + option (google.api.method_signature) = "query"; + } + + // Gets the access control policy for an organization resource. The policy may + // be empty if no such policy or resource exists. The `resource` field should + // be the organization's resource name, for example: "organizations/123". + // + // Authorization requires the IAM permission + // `resourcemanager.organizations.getIamPolicy` on the specified organization. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=organizations/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy on an organization resource. Replaces any + // existing policy. The `resource` field should be the organization's resource + // name, for example: "organizations/123". + // + // Authorization requires the IAM permission + // `resourcemanager.organizations.setIamPolicy` on the specified organization. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=organizations/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Returns the permissions that a caller has on the specified organization. + // The `resource` field should be the organization's resource name, + // for example: "organizations/123". + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=organizations/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// The root node in the resource hierarchy to which a particular entity's +// (a company, for example) resources belong. +message Organization { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/Organization" + pattern: "organizations/{organization}" + style: DECLARATIVE_FRIENDLY + }; + + // Organization lifecycle states. + enum State { + // Unspecified state. This is only useful for distinguishing unset values. + STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 1; + + // The organization has been marked for deletion by the user. + DELETE_REQUESTED = 2; + } + + // Output only. The resource name of the organization. This is the + // organization's relative path in the API. Its format is + // "organizations/[organization_id]". For example, "organizations/1234". + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A human-readable string that refers to the organization in the + // Google Cloud Console. This string is set by the server and cannot be + // changed. The string will be set to the primary domain (for example, + // "google.com") of the Google Workspace customer that owns the organization. + string display_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The owner of this organization. The owner should be specified on + // creation. Once set, it cannot be changed. + // + // The lifetime of the organization and all of its descendants are bound to + // the owner. If the owner is deleted, the organization and all its + // descendants will be deleted. + oneof owner { + // Immutable. The G Suite / Workspace customer id used in the Directory API. + string directory_customer_id = 3 [(google.api.field_behavior) = IMMUTABLE]; + } + + // Output only. The organization's current lifecycle state. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the Organization was created. + google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the Organization was last modified. + google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp when the Organization was requested for deletion. + google.protobuf.Timestamp delete_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A checksum computed by the server based on the current value of the + // Organization resource. This may be sent on update and delete requests to + // ensure the client has an up-to-date value before proceeding. + string etag = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The request sent to the `GetOrganization` method. The `name` field is +// required. `organization_id` is no longer accepted. +message GetOrganizationRequest { + // Required. The resource name of the Organization to fetch. This is the organization's + // relative path in the API, formatted as "organizations/[organizationId]". + // For example, "organizations/1234". + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Organization" + } + ]; +} + +// The request sent to the `SearchOrganizations` method. +message SearchOrganizationsRequest { + // Optional. The maximum number of organizations to return in the response. + // If unspecified, server picks an appropriate default. + int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `SearchOrganizations` + // that indicates from where listing should continue. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. An optional query string used to filter the Organizations to return in + // the response. Query rules are case-insensitive. + // + // ``` + // | Field | Description | + // |------------------|--------------------------------------------| + // | directoryCustomerId, owner.directoryCustomerId | Filters by directory + // customer id. | + // | domain | Filters by domain. | + // ``` + // + // Organizations may be queried by `directoryCustomerId` or by + // `domain`, where the domain is a G Suite domain, for example: + // + // * Query `directorycustomerid:123456789` returns Organization + // resources with `owner.directory_customer_id` equal to `123456789`. + // * Query `domain:google.com` returns Organization resources corresponding + // to the domain `google.com`. + string query = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response returned from the `SearchOrganizations` method. +message SearchOrganizationsResponse { + // The list of Organizations that matched the search query, possibly + // paginated. + repeated Organization organizations = 1; + + // A pagination token to be used to retrieve the next page of results. If the + // result is too large to fit within the page size specified in the request, + // this field will be set with a token that can be used to fetch the next page + // of results. If this field is empty, it indicates that this response + // contains the last page of results. + string next_page_token = 2; +} + +// A status object which is used as the `metadata` field for the operation +// returned by DeleteOrganization. +message DeleteOrganizationMetadata { + +} + +// A status object which is used as the `metadata` field for the Operation +// returned by UndeleteOrganization. +message UndeleteOrganizationMetadata { + +} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/projects.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/projects.proto new file mode 100644 index 0000000..3d2feb0 --- /dev/null +++ b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/projects.proto @@ -0,0 +1,640 @@ +// 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 +// +// 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.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; +option java_multiple_files = true; +option java_outer_classname = "ProjectsProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Manages Google Cloud Projects. +service Projects { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Retrieves the project identified by the specified `name` (for example, + // `projects/415104041262`). + // + // The caller must have `resourcemanager.projects.get` permission + // for this project. + rpc GetProject(GetProjectRequest) returns (Project) { + option (google.api.http) = { + get: "/v3/{name=projects/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists projects that are direct children of the specified folder or + // organization resource. `list()` provides a strongly consistent view of the + // projects underneath the specified parent resource. `list()` returns + // projects sorted based upon the (ascending) lexical ordering of their + // `display_name`. The caller must have `resourcemanager.projects.list` + // permission on the identified parent. + rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse) { + option (google.api.http) = { + get: "/v3/projects" + }; + option (google.api.method_signature) = "parent"; + } + + // Search for projects that the caller has both `resourcemanager.projects.get` + // permission on, and also satisfy the specified query. + // + // This method returns projects in an unspecified order. + // + // This method is eventually consistent with project mutations; this means + // that a newly created project may not appear in the results or recent + // updates to an existing project may not be reflected in the results. To + // retrieve the latest state of a project, use the + // [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method. + rpc SearchProjects(SearchProjectsRequest) returns (SearchProjectsResponse) { + option (google.api.http) = { + get: "/v3/projects:search" + }; + option (google.api.method_signature) = "query"; + } + + // Request that a new project be created. The result is an `Operation` which + // can be used to track the creation process. This process usually takes a few + // seconds, but can sometimes take much longer. The tracking `Operation` is + // automatically deleted after a few hours, so there is no need to call + // `DeleteOperation`. + rpc CreateProject(CreateProjectRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/projects" + body: "project" + }; + option (google.api.method_signature) = "project"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "CreateProjectMetadata" + }; + } + + // Updates the `display_name` and labels of the project identified by the + // specified `name` (for example, `projects/415104041262`). Deleting all + // labels requires an update mask for labels field. + // + // The caller must have `resourcemanager.projects.update` permission for this + // project. + rpc UpdateProject(UpdateProjectRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v3/{project.name=projects/*}" + body: "project" + }; + option (google.api.method_signature) = "project,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "UpdateProjectMetadata" + }; + } + + // Move a project to another place in your resource hierarchy, under a new + // resource parent. + // + // Returns an operation which can be used to track the process of the project + // move workflow. + // Upon success, the `Operation.response` field will be populated with the + // moved project. + // + // The caller must have `resourcemanager.projects.update` permission on the + // project and have `resourcemanager.projects.move` permission on the + // project's current and proposed new parent. + // + // + rpc MoveProject(MoveProjectRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{name=projects/*}:move" + body: "*" + }; + option (google.api.method_signature) = "name, destination_parent"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "MoveProjectMetadata" + }; + } + + // Marks the project identified by the specified + // `name` (for example, `projects/415104041262`) for deletion. + // + // This method will only affect the project if it has a lifecycle state of + // [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. + // + // This method changes the Project's lifecycle state from + // [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] + // to [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. + // The deletion starts at an unspecified time, + // at which point the Project is no longer accessible. + // + // Until the deletion completes, you can check the lifecycle state + // checked by retrieving the project with [GetProject] + // [google.cloud.resourcemanager.v3.Projects.GetProject], + // and the project remains visible to [ListProjects] + // [google.cloud.resourcemanager.v3.Projects.ListProjects]. + // However, you cannot update the project. + // + // After the deletion completes, the project is not retrievable by + // the [GetProject] + // [google.cloud.resourcemanager.v3.Projects.GetProject], + // [ListProjects] + // [google.cloud.resourcemanager.v3.Projects.ListProjects], and + // [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] + // methods. + // + // This method behaves idempotently, such that deleting a `DELETE_REQUESTED` + // project will not cause an error, but also won't do anything. + // + // The caller must have `resourcemanager.projects.delete` permissions for this + // project. + rpc DeleteProject(DeleteProjectRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=projects/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "DeleteProjectMetadata" + }; + } + + // Restores the project identified by the specified + // `name` (for example, `projects/415104041262`). + // You can only use this method for a project that has a lifecycle state of + // [DELETE_REQUESTED] + // [Projects.State.DELETE_REQUESTED]. + // After deletion starts, the project cannot be restored. + // + // The caller must have `resourcemanager.projects.undelete` permission for + // this project. + rpc UndeleteProject(UndeleteProjectRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/{name=projects/*}:undelete" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Project" + metadata_type: "UndeleteProjectMetadata" + }; + } + + // Returns the IAM access control policy for the specified project. + // Permission is denied if the policy or the resource do not exist. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=projects/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the IAM access control policy for the specified project. + // + // CAUTION: This method will replace the existing policy, and cannot be used + // to append additional IAM settings. + // + // Note: Removing service accounts from policies or changing their roles can + // render services completely inoperable. It is important to understand how + // the service account is being used before removing or updating its roles. + // + // The following constraints apply when using `setIamPolicy()`: + // + // + Project does not support `allUsers` and `allAuthenticatedUsers` as + // `members` in a `Binding` of a `Policy`. + // + // + The owner role can be granted to a `user`, `serviceAccount`, or a group + // that is part of an organization. For example, + // group@myownpersonaldomain.com could be added as an owner to a project in + // the myownpersonaldomain.com organization, but not the examplepetstore.com + // organization. + // + // + Service accounts can be made owners of a project directly + // without any restrictions. However, to be added as an owner, a user must be + // invited using the Cloud Platform console and must accept the invitation. + // + // + A user cannot be granted the owner role using `setIamPolicy()`. The user + // must be granted the owner role using the Cloud Platform Console and must + // explicitly accept the invitation. + // + // + Invitations to grant the owner role cannot be sent using + // `setIamPolicy()`; + // they must be sent only using the Cloud Platform Console. + // + // + Membership changes that leave the project without any owners that have + // accepted the Terms of Service (ToS) will be rejected. + // + // + If the project is not part of an organization, there must be at least + // one owner who has accepted the Terms of Service (ToS) agreement in the + // policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner + // from the policy will fail. This restriction also applies to legacy + // projects that no longer have owners who have accepted the ToS. Edits to + // IAM policies will be rejected until the lack of a ToS-accepting owner is + // rectified. + // + // + Calling this method requires enabling the App Engine Admin API. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=projects/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource, policy"; + } + + // Returns permissions that a caller has on the specified project. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=projects/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource, permissions"; + } +} + +// A project is a high-level Google Cloud entity. It is a +// container for ACLs, APIs, App Engine Apps, VMs, and other +// Google Cloud Platform resources. +message Project { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/Project" + pattern: "projects/{project}" + style: DECLARATIVE_FRIENDLY + }; + + // Project lifecycle states. + enum State { + // Unspecified state. This is only used/useful for distinguishing + // unset values. + STATE_UNSPECIFIED = 0; + + // The normal and active state. + ACTIVE = 1; + + // The project has been marked for deletion by the user + // (by invoking + // [DeleteProject][google.cloud.resourcemanager.v3.Projects.DeleteProject]) + // or by the system (Google Cloud Platform). + // This can generally be reversed by invoking [UndeleteProject] + // [google.cloud.resourcemanager.v3.Projects.UndeleteProject]. + DELETE_REQUESTED = 2; + } + + // Output only. The unique resource name of the project. It is an int64 generated number + // prefixed by "projects/". + // + // Example: `projects/415104041262` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. A reference to a parent Resource. eg., `organizations/123` or + // `folders/876`. + string parent = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Immutable. The unique, user-assigned id of the project. + // It must be 6 to 30 lowercase ASCII letters, digits, or hyphens. + // It must start with a letter. + // Trailing hyphens are prohibited. + // + // Example: `tokyo-rain-123` + string project_id = 3 [(google.api.field_behavior) = IMMUTABLE]; + + // Output only. The project lifecycle state. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. A user-assigned display name of the project. + // When present it must be between 4 to 30 characters. + // Allowed characters are: lowercase and uppercase letters, numbers, + // hyphen, single-quote, double-quote, space, and exclamation point. + // + // Example: `My Project` + string display_name = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Creation time. + google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The most recent time this resource was modified. + google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time at which this resource was requested for deletion. + google.protobuf.Timestamp delete_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. A checksum computed by the server based on the current value of the Project + // resource. This may be sent on update and delete requests to ensure the + // client has an up-to-date value before proceeding. + string etag = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. The labels associated with this project. + // + // Label keys must be between 1 and 63 characters long and must conform + // to the following regular expression: \[a-z\](\[-a-z0-9\]*\[a-z0-9\])?. + // + // Label values must be between 0 and 63 characters long and must conform + // to the regular expression (\[a-z\](\[-a-z0-9\]*\[a-z0-9\])?)?. + // + // No more than 256 labels can be associated with a given resource. + // + // Clients should store labels in a representation such as JSON that does not + // depend on specific characters being disallowed. + // + // Example: `"myBusinessDimension" : "businessValue"` + map labels = 10 [(google.api.field_behavior) = OPTIONAL]; +} + +// The request sent to the +// [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] +// method. +message GetProjectRequest { + // Required. The name of the project (for example, `projects/415104041262`). + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; +} + +// The request sent to the +// [ListProjects][google.cloud.resourcemanager.v3.Projects.ListProjects] +// method. +message ListProjectsRequest { + // Required. The name of the parent resource to list projects under. + // + // For example, setting this field to 'folders/1234' would list all projects + // directly under that folder. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "*" + } + ]; + + // Optional. A pagination token returned from a previous call to [ListProjects] + // [google.cloud.resourcemanager.v3.Projects.ListProjects] + // that indicates from where listing should continue. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of projects to return in the response. + // The server can return fewer projects than requested. + // If unspecified, server picks an appropriate default. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be + // returned. Normally only `ACTIVE` projects are returned. + bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// A page of the response received from the +// [ListProjects][google.cloud.resourcemanager.v3.Projects.ListProjects] +// method. +// +// A paginated response where more pages are available has +// `next_page_token` set. This token can be used in a subsequent request to +// retrieve the next request page. +// +// NOTE: A response may contain fewer elements than the request `page_size` and +// still have a `next_page_token`. +message ListProjectsResponse { + // The list of Projects under the parent. This list can be paginated. + repeated Project projects = 1; + + // Pagination token. + // + // If the result set is too large to fit in a single response, this token + // is returned. It encodes the position of the current result cursor. + // Feeding this value into a new list request with the `page_token` parameter + // gives the next page of the results. + // + // When `next_page_token` is not filled in, there is no next page and + // the list returned is the last page in the result set. + // + // Pagination tokens have a limited lifetime. + string next_page_token = 2; +} + +// The request sent to the +// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] +// method. +message SearchProjectsRequest { + // Optional. A query string for searching for projects that the caller has + // `resourcemanager.projects.get` permission to. If multiple fields are + // included in the query, the it will return results that match any of the + // fields. Some eligible fields are: + // + // ``` + // | Field | Description | + // |-------------------------|----------------------------------------------| + // | displayName, name | Filters by displayName. | + // | parent | Project's parent. (for example: folders/123, + // organizations/*) Prefer parent field over parent.type and parent.id. | + // | parent.type | Parent's type: `folder` or `organization`. | + // | parent.id | Parent's id number (for example: 123) | + // | id, projectId | Filters by projectId. | + // | state, lifecycleState | Filters by state. | + // | labels | Filters by label name or value. | + // | labels. (where *key* is the name of a label) | Filters by label + // name. | + // ``` + // + // Search expressions are case insensitive. + // + // Some examples queries: + // + // ``` + // | Query | Description | + // |------------------|-----------------------------------------------------| + // | name:how* | The project's name starts with "how". | + // | name:Howl | The project's name is `Howl` or `howl`. | + // | name:HOWL | Equivalent to above. | + // | NAME:howl | Equivalent to above. | + // | labels.color:* | The project has the label `color`. | + // | labels.color:red | The project's label `color` has the value `red`. | + // | labels.color:red labels.size:big | The project's label `color` has + // the value `red` and its label `size` has the value `big`. | + // ``` + // + // If no query is specified, the call will return projects for which the user + // has the `resourcemanager.projects.get` permission. + string query = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to [ListProjects] + // [google.cloud.resourcemanager.v3.Projects.ListProjects] + // that indicates from where listing should continue. + string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of projects to return in the response. + // The server can return fewer projects than requested. + // If unspecified, server picks an appropriate default. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A page of the response received from the +// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] +// method. +// +// A paginated response where more pages are available has +// `next_page_token` set. This token can be used in a subsequent request to +// retrieve the next request page. +message SearchProjectsResponse { + // The list of Projects that matched the list filter query. This list can + // be paginated. + repeated Project projects = 1; + + // Pagination token. + // + // If the result set is too large to fit in a single response, this token + // is returned. It encodes the position of the current result cursor. + // Feeding this value into a new list request with the `page_token` parameter + // gives the next page of the results. + // + // When `next_page_token` is not filled in, there is no next page and + // the list returned is the last page in the result set. + // + // Pagination tokens have a limited lifetime. + string next_page_token = 2; +} + +// The request sent to the +// [CreateProject][google.cloud.resourcemanager.v3.Projects.CreateProject] +// method. +message CreateProjectRequest { + // Required. The Project to create. + // + // Project ID is required. If the requested ID is unavailable, the request + // fails. + // + // If the `parent` field is set, the `resourcemanager.projects.create` + // permission is checked on the parent resource. If no parent is set and + // the authorization credentials belong to an Organziation, the parent + // will be set to that Organization. + Project project = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by CreateProject. It provides insight for when significant phases of +// Project creation have completed. +message CreateProjectMetadata { + // Creation time of the project creation workflow. + google.protobuf.Timestamp create_time = 1; + + // True if the project can be retrieved using `GetProject`. No other + // operations on the project are guaranteed to work until the project creation + // is complete. + bool gettable = 2; + + // True if the project creation process is complete. + bool ready = 3; +} + +// The request sent to the +// [UpdateProject][google.cloud.resourcemanager.v3.Projects.UpdateProject] +// method. +// +// Only the `display_name` and `labels` fields can be change. Use the +// [MoveProject][google.cloud.resourcemanager.v3.Projects.MoveProject] method to +// change the `parent` field. +message UpdateProjectRequest { + // Required. The new definition of the project. + Project project = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. An update mask to selectively update fields. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by UpdateProject. +message UpdateProjectMetadata { + +} + +// The request sent to +// [MoveProject][google.cloud.resourcemanager.v3.Projects.MoveProject] +// method. +message MoveProjectRequest { + // Required. The name of the project to move. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; + + // Required. The new parent to move the Project under. + string destination_parent = 2 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "*" + } + ]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by MoveProject. +message MoveProjectMetadata { + +} + +// [DeleteProject][google.cloud.resourcemanager.v3.Projects.DeleteProject] +// method. +message DeleteProjectRequest { + // Required. The name of the Project (for example, `projects/415104041262`). + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by `DeleteProject`. +message DeleteProjectMetadata { + +} + +// The request sent to the [UndeleteProject] +// [google.cloud.resourcemanager.v3.Projects.UndeleteProject] +// method. +message UndeleteProjectRequest { + // Required. The name of the project (for example, `projects/415104041262`). + // + // Required. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/Project" + } + ]; +} + +// A status object which is used as the `metadata` field for the Operation +// returned by `UndeleteProject`. +message UndeleteProjectMetadata { + +} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto new file mode 100644 index 0000000..6c8f260 --- /dev/null +++ b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto @@ -0,0 +1,177 @@ +// 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 +// +// 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.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; +option java_multiple_files = true; +option java_outer_classname = "TagBindingsProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Allow users to create and manage TagBindings between TagValues and +// different cloud resources throughout the GCP resource hierarchy. +service TagBindings { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Lists the TagBindings for the given cloud resource, as specified with + // `parent`. + // + // NOTE: The `parent` field is expected to be a full resource name: + // https://cloud.google.com/apis/design/resource_names#full_resource_name + rpc ListTagBindings(ListTagBindingsRequest) returns (ListTagBindingsResponse) { + option (google.api.http) = { + get: "/v3/tagBindings" + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a TagBinding between a TagValue and a cloud resource + // (currently project, folder, or organization). + rpc CreateTagBinding(CreateTagBindingRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/tagBindings" + body: "tag_binding" + }; + option (google.api.method_signature) = "tag_binding"; + option (google.longrunning.operation_info) = { + response_type: "TagBinding" + metadata_type: "CreateTagBindingMetadata" + }; + } + + // Deletes a TagBinding. + rpc DeleteTagBinding(DeleteTagBindingRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=tagBindings/**}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "DeleteTagBindingMetadata" + }; + } +} + +// A TagBinding represents a connection between a TagValue and a cloud +// resource (currently project, folder, or organization). Once a TagBinding is +// created, the TagValue is applied to all the descendants of the cloud +// resource. +message TagBinding { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/TagBinding" + pattern: "tagBindings/{tag_binding}" + }; + + // Output only. The name of the TagBinding. This is a String of the form: + // `tagBindings/{full-resource-name}/{tag-value-name}` (e.g. + // `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The full resource name of the resource the TagValue is bound to. + // E.g. `//cloudresourcemanager.googleapis.com/projects/123` + string parent = 2; + + // The TagValue of the TagBinding. + // Must be of the form `tagValues/456`. + string tag_value = 3; +} + +// Runtime operation information for creating a TagValue. +message CreateTagBindingMetadata { + +} + +// The request message to create a TagBinding. +message CreateTagBindingRequest { + // Required. The TagBinding to be created. + TagBinding tag_binding = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Set to true to perform the validations necessary for creating the resource, + // but not actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for deleting a TagBinding. +message DeleteTagBindingMetadata { + +} + +// The request message to delete a TagBinding. +message DeleteTagBindingRequest { + // Required. The name of the TagBinding. This is a String of the form: + // `tagBindings/{id}` (e.g. + // `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagBinding" + } + ]; +} + +// The request message to list all TagBindings for a parent. +message ListTagBindingsRequest { + // Required. The full resource name of a resource for which you want to list existing + // TagBindings. + // E.g. "//cloudresourcemanager.googleapis.com/projects/123" + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "*" + } + ]; + + // Optional. The maximum number of TagBindings to return in the response. The server + // allows a maximum of 300 TagBindings to return. If unspecified, the server + // will use 100 as the default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `ListTagBindings` + // that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The ListTagBindings response. +message ListTagBindingsResponse { + // A possibly paginated list of TagBindings for the specified TagValue or + // resource. + repeated TagBinding tag_bindings = 1; + + // Pagination token. + // + // If the result set is too large to fit in a single response, this token + // is returned. It encodes the position of the current result cursor. + // Feeding this value into a new list request with the `page_token` parameter + // gives the next page of the results. + // + // When `next_page_token` is not filled in, there is no next page and + // the list returned is the last page in the result set. + // + // Pagination tokens have a limited lifetime. + string next_page_token = 2; +} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto new file mode 100644 index 0000000..5ecf0b4 --- /dev/null +++ b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto @@ -0,0 +1,300 @@ +// 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 +// +// 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.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; +option java_multiple_files = true; +option java_outer_classname = "TagKeysProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Allow users to create and manage tag keys. +service TagKeys { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Lists all TagKeys for a parent resource. + rpc ListTagKeys(ListTagKeysRequest) returns (ListTagKeysResponse) { + option (google.api.http) = { + get: "/v3/tagKeys" + }; + option (google.api.method_signature) = "parent"; + } + + // Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the + // key does not exist or the user does not have permission to view it. + rpc GetTagKey(GetTagKeyRequest) returns (TagKey) { + option (google.api.http) = { + get: "/v3/{name=tagKeys/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new TagKey. If another request with the same parameters is + // sent while the original request is in process, the second request + // will receive an error. A maximum of 300 TagKeys can exist under a parent at + // any given time. + rpc CreateTagKey(CreateTagKeyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/tagKeys" + body: "tag_key" + }; + option (google.api.method_signature) = "tag_key"; + option (google.longrunning.operation_info) = { + response_type: "TagKey" + metadata_type: "CreateTagKeyMetadata" + }; + } + + // Updates the attributes of the TagKey resource. + rpc UpdateTagKey(UpdateTagKeyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v3/{tag_key.name=tagKeys/*}" + body: "tag_key" + }; + option (google.api.method_signature) = "tag_key,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "TagKey" + metadata_type: "UpdateTagKeyMetadata" + }; + } + + // Deletes a TagKey. The TagKey cannot be deleted if it has any child + // TagValues. + rpc DeleteTagKey(DeleteTagKeyRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=tagKeys/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "TagKey" + metadata_type: "DeleteTagKeyMetadata" + }; + } + + // Gets the access control policy for a TagKey. The returned policy may be + // empty if no such policy or resource exists. The `resource` field should + // be the TagKey's resource name. For example, "tagKeys/1234". + // The caller must have + // `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on + // the specified TagKey. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=tagKeys/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy on a TagKey, replacing any existing + // policy. The `resource` field should be the TagKey's resource name. + // For example, "tagKeys/1234". + // The caller must have `resourcemanager.tagKeys.setIamPolicy` permission + // on the identified tagValue. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=tagKeys/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Returns permissions that a caller has on the specified TagKey. + // The `resource` field should be the TagKey's resource name. + // For example, "tagKeys/1234". + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=tagKeys/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// A TagKey, used to group a set of TagValues. +message TagKey { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/TagKey" + pattern: "tagKeys/{tag_key}" + style: DECLARATIVE_FRIENDLY + }; + + // Immutable. The resource name for a TagKey. Must be in the format + // `tagKeys/{tag_key_id}`, where `tag_key_id` is the generated numeric id for + // the TagKey. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The resource name of the new TagKey's parent. + // Must be of the form `organizations/{org_id}`. + string parent = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. Immutable. The user friendly name for a TagKey. The short name should be + // unique for TagKeys within the same tag namespace. + // + // The short name must be 1-63 characters, beginning and ending with + // an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), + // dots (.), and alphanumerics between. + string short_name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Output only. Immutable. Namespaced name of the TagKey. + string namespaced_name = 4 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Optional. User-assigned description of the TagKey. Must not exceed 256 characters. + // + // Read-write. + string description = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Creation time. + google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Update time. + google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Entity tag which users can pass to prevent race conditions. This field is + // always set in server responses. See UpdateTagKeyRequest for details. + string etag = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// The request message for listing all TagKeys under a parent resource. +message ListTagKeysRequest { + // Required. The resource name of the new TagKey's parent. + // Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "*" + } + ]; + + // Optional. The maximum number of TagKeys to return in the response. The server allows + // a maximum of 300 TagKeys to return. If unspecified, the server will use 100 + // as the default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `ListTagKey` + // that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The ListTagKeys response message. +message ListTagKeysResponse { + // List of TagKeys that live under the specified parent in the request. + repeated TagKey tag_keys = 1; + + // A pagination token returned from a previous call to `ListTagKeys` + // that indicates from where listing should continue. + string next_page_token = 2; +} + +// The request message for getting a TagKey. +message GetTagKeyRequest { + // Required. A resource name in the format `tagKeys/{id}`, such as + // `tagKeys/123`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagKey" + } + ]; +} + +// The request message for creating a TagKey. +message CreateTagKeyRequest { + // Required. The TagKey to be created. Only fields `short_name`, `description`, + // and `parent` are considered during the creation request. + TagKey tag_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Set to true to perform validations necessary for creating the resource, but + // not actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for creating a TagKey. +message CreateTagKeyMetadata { + +} + +// The request message for updating a TagKey. +message UpdateTagKeyRequest { + // Required. The new definition of the TagKey. Only the `description` and `etag` fields + // can be updated by this request. If the `etag` field is not empty, it + // must match the `etag` field of the existing tag key. Otherwise, + // `FAILED_PRECONDITION` will be returned. + TagKey tag_key = 1 [(google.api.field_behavior) = REQUIRED]; + + // Fields to be updated. The mask may only contain `description` or + // `etag`. If omitted entirely, both `description` and `etag` are assumed to + // be significant. + google.protobuf.FieldMask update_mask = 2; + + // Set as true to perform validations necessary for updating the resource, but + // not actually perform the action. + bool validate_only = 3; +} + +// Runtime operation information for updating a TagKey. +message UpdateTagKeyMetadata { + +} + +// The request message for deleting a TagKey. +message DeleteTagKeyRequest { + // Required. The resource name of a TagKey to be deleted in the format `tagKeys/123`. + // The TagKey cannot be a parent of any existing TagValues or it will not be + // deleted successfully. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagKey" + } + ]; + + // Optional. Set as true to perform validations necessary for deletion, but not actually + // perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The etag known to the client for the expected state of the TagKey. This is + // to be used for optimistic concurrency. + string etag = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for deleting a TagKey. +message DeleteTagKeyMetadata { + +} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto new file mode 100644 index 0000000..86ba701 --- /dev/null +++ b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto @@ -0,0 +1,296 @@ +// 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 +// +// 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.cloud.resourcemanager.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.ResourceManager.V3"; +option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; +option java_multiple_files = true; +option java_outer_classname = "TagValuesProto"; +option java_package = "com.google.cloud.resourcemanager.v3"; +option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; +option ruby_package = "Google::Cloud::ResourceManager::V3"; + +// Allow users to create and manage tag values. +service TagValues { + option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloud-platform.read-only"; + + // Lists all TagValues for a specific TagKey. + rpc ListTagValues(ListTagValuesRequest) returns (ListTagValuesResponse) { + option (google.api.http) = { + get: "/v3/tagValues" + }; + option (google.api.method_signature) = "parent"; + } + + // Retrieves TagValue. If the TagValue or namespaced name does not exist, or + // if the user does not have permission to view it, this method will return + // `PERMISSION_DENIED`. + rpc GetTagValue(GetTagValueRequest) returns (TagValue) { + option (google.api.http) = { + get: "/v3/{name=tagValues/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a TagValue as a child of the specified TagKey. If a another + // request with the same parameters is sent while the original request is in + // process the second request will receive an error. A maximum of 300 + // TagValues can exist under a TagKey at any given time. + rpc CreateTagValue(CreateTagValueRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v3/tagValues" + body: "tag_value" + }; + option (google.api.method_signature) = "tag_value"; + option (google.longrunning.operation_info) = { + response_type: "TagValue" + metadata_type: "CreateTagValueMetadata" + }; + } + + // Updates the attributes of the TagValue resource. + rpc UpdateTagValue(UpdateTagValueRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v3/{tag_value.name=tagValues/*}" + body: "tag_value" + }; + option (google.api.method_signature) = "tag_value,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "TagValue" + metadata_type: "UpdateTagValueMetadata" + }; + } + + // Deletes a TagValue. The TagValue cannot have any bindings when it is + // deleted. + rpc DeleteTagValue(DeleteTagValueRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v3/{name=tagValues/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "TagValue" + metadata_type: "DeleteTagValueMetadata" + }; + } + + // Gets the access control policy for a TagValue. The returned policy may be + // empty if no such policy or resource exists. The `resource` field should + // be the TagValue's resource name. For example: `tagValues/1234`. + // The caller must have the + // `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on + // the identified TagValue to get the access control policy. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=tagValues/*}:getIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource"; + } + + // Sets the access control policy on a TagValue, replacing any existing + // policy. The `resource` field should be the TagValue's resource name. + // For example: `tagValues/1234`. + // The caller must have `resourcemanager.tagValues.setIamPolicy` permission + // on the identified tagValue. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v3/{resource=tagValues/*}:setIamPolicy" + body: "*" + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Returns permissions that a caller has on the specified TagValue. + // The `resource` field should be the TagValue's resource name. For example: + // `tagValues/1234`. + // + // There are no permissions required for making this API call. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v3/{resource=tagValues/*}:testIamPermissions" + body: "*" + }; + option (google.api.method_signature) = "resource,permissions"; + } +} + +// A TagValue is a child of a particular TagKey. This is used to group +// cloud resources for the purpose of controlling them using policies. +message TagValue { + option (google.api.resource) = { + type: "cloudresourcemanager.googleapis.com/TagValue" + pattern: "tagValues/{tag_value}" + style: DECLARATIVE_FRIENDLY + }; + + // Immutable. Resource name for TagValue in the format `tagValues/456`. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The resource name of the new TagValue's parent TagKey. + // Must be of the form `tagKeys/{tag_key_id}`. + string parent = 2 [(google.api.field_behavior) = IMMUTABLE]; + + // Required. Immutable. User-assigned short name for TagValue. The short name should be + // unique for TagValues within the same parent TagKey. + // + // The short name must be 63 characters or less, beginning and ending with + // an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), + // dots (.), and alphanumerics between. + string short_name = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // Output only. Namespaced name of the TagValue. Must be in the format + // `{organization_id}/{tag_key_short_name}/{short_name}`. + string namespaced_name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. User-assigned description of the TagValue. + // Must not exceed 256 characters. + // + // Read-write. + string description = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. Creation time. + google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Update time. + google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Entity tag which users can pass to prevent race conditions. This field is + // always set in server responses. See UpdateTagValueRequest for details. + string etag = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// The request message for listing TagValues for the specified TagKey. +message ListTagValuesRequest { + // Required. Resource name for TagKey, parent of the TagValues to be listed, + // in the format `tagKeys/123`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "*" + } + ]; + + // Optional. The maximum number of TagValues to return in the response. The server + // allows a maximum of 300 TagValues to return. If unspecified, the server + // will use 100 as the default. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A pagination token returned from a previous call to `ListTagValues` + // that indicates where this listing should continue from. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The ListTagValues response. +message ListTagValuesResponse { + // A possibly paginated list of TagValues that are direct descendants of + // the specified parent TagKey. + repeated TagValue tag_values = 1; + + // A pagination token returned from a previous call to `ListTagValues` + // that indicates from where listing should continue. This is currently not + // used, but the server may at any point start supplying a valid token. + string next_page_token = 2; +} + +// The request message for getting a TagValue. +message GetTagValueRequest { + // Required. Resource name for TagValue to be fetched in the format `tagValues/456`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagValue" + } + ]; +} + +// The request message for creating a TagValue. +message CreateTagValueRequest { + // Required. The TagValue to be created. Only fields `short_name`, `description`, + // and `parent` are considered during the creation request. + TagValue tag_value = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Set as true to perform the validations necessary for creating the resource, + // but not actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for creating a TagValue. +message CreateTagValueMetadata { + +} + +// The request message for updating a TagValue. +message UpdateTagValueRequest { + // Required. The new definition of the TagValue. Only fields `description` and `etag` + // fields can be updated by this request. If the `etag` field is nonempty, it + // must match the `etag` field of the existing ControlGroup. Otherwise, + // `FAILED_PRECONDITION` will be returned. + TagValue tag_value = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Fields to be updated. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. True to perform validations necessary for updating the resource, but not + // actually perform the action. + bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for updating a TagValue. +message UpdateTagValueMetadata { + +} + +// The request message for deleting a TagValue. +message DeleteTagValueRequest { + // Required. Resource name for TagValue to be deleted in the format tagValues/456. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudresourcemanager.googleapis.com/TagValue" + } + ]; + + // Optional. Set as true to perform the validations necessary for deletion, but not + // actually perform the action. + bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The etag known to the client for the expected state of the TagValue. This + // is to be used for optimistic concurrency. + string etag = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Runtime operation information for deleting a TagValue. +message DeleteTagValueMetadata { + +} diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.create_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.create_folder.js new file mode 100644 index 0000000..c243825 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.create_folder.js @@ -0,0 +1,60 @@ +// 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(folder) { + // [START cloudresourcemanager_v3_generated_Folders_CreateFolder_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The folder being created, only the display name and parent will be + * consulted. All other fields will be ignored. + */ + // const folder = {} + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callCreateFolder() { + // Construct request + const request = { + folder, + }; + + // Run request + const [operation] = await resourcemanagerClient.createFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateFolder(); + // [END cloudresourcemanager_v3_generated_Folders_CreateFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.delete_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.delete_folder.js new file mode 100644 index 0000000..e6517a9 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.delete_folder.js @@ -0,0 +1,60 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_Folders_DeleteFolder_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the folder to be deleted. + * Must be of the form `folders/{folder_id}`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callDeleteFolder() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteFolder(); + // [END cloudresourcemanager_v3_generated_Folders_DeleteFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.get_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.get_folder.js new file mode 100644 index 0000000..a448f44 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.get_folder.js @@ -0,0 +1,59 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_Folders_GetFolder_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the folder to retrieve. + * Must be of the form `folders/{folder_id}`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callGetFolder() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getFolder(request); + console.log(response); + } + + callGetFolder(); + // [END cloudresourcemanager_v3_generated_Folders_GetFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/folders.get_iam_policy.js new file mode 100644 index 0000000..049a601 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.list_folders.js b/owl-bot-staging/v3/samples/generated/v3/folders.list_folders.js new file mode 100644 index 0000000..daf26e6 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.list_folders.js @@ -0,0 +1,80 @@ +// 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(parent) { + // [START cloudresourcemanager_v3_generated_Folders_ListFolders_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the organization or folder whose folders are + * being listed. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + * Access to this method is controlled by checking the + * `resourcemanager.folders.list` permission on the `parent`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of folders to return in the response. + * If unspecified, server picks an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to `ListFolders` + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + /** + * Optional. Controls whether folders in the + * DELETE_REQUESTED google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED + * state should be returned. Defaults to false. + */ + // const showDeleted = true + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callListFolders() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listFoldersAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListFolders(); + // [END cloudresourcemanager_v3_generated_Folders_ListFolders_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.move_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.move_folder.js new file mode 100644 index 0000000..bd90af4 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.move_folder.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(name, destinationParent) { + // [START cloudresourcemanager_v3_generated_Folders_MoveFolder_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Folder to move. + * Must be of the form folders/{folder_id} + */ + // const name = 'abc123' + /** + * Required. The resource name of the folder or organization which should be the + * folder's new parent. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + */ + // const destinationParent = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callMoveFolder() { + // Construct request + const request = { + name, + destinationParent, + }; + + // Run request + const [operation] = await resourcemanagerClient.moveFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callMoveFolder(); + // [END cloudresourcemanager_v3_generated_Folders_MoveFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.search_folders.js b/owl-bot-staging/v3/samples/generated/v3/folders.search_folders.js new file mode 100644 index 0000000..5670775 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.search_folders.js @@ -0,0 +1,94 @@ +// 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 cloudresourcemanager_v3_generated_Folders_SearchFolders_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. The maximum number of folders to return in the response. + * If unspecified, server picks an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to `SearchFolders` + * that indicates from where search should continue. + */ + // const pageToken = 'abc123' + /** + * Optional. Search criteria used to select the folders to return. + * If no search criteria is specified then all accessible folders will be + * returned. + * Query expressions can be used to restrict results based upon displayName, + * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + * can be used along with the suffix wildcard symbol `*`. + * The `displayName` field in a query expression should use escaped quotes + * for values that include whitespace to prevent unexpected behavior. + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------| + * | displayName | Filters by displayName. | + * | parent | Filters by parent (for example: folders/123). | + * | state, lifecycleState | Filters by state. | + * ``` + * Some example queries are: + * * Query `displayName=Test*` returns Folder resources whose display name + * starts with "Test". + * * Query `state=ACTIVE` returns Folder resources with + * `state` set to `ACTIVE`. + * * Query `parent=folders/123` returns Folder resources that have + * `folders/123` as a parent resource. + * * Query `parent=folders/123 AND state=ACTIVE` returns active + * Folder resources that have `folders/123` as a parent resource. + * * Query `displayName=\\"Test String\\"` returns Folder resources with + * display names that include both "Test" and "String". + */ + // const query = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callSearchFolders() { + // Construct request + const request = { + }; + + // Run request + const iterable = await resourcemanagerClient.searchFoldersAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchFolders(); + // [END cloudresourcemanager_v3_generated_Folders_SearchFolders_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/folders.set_iam_policy.js new file mode 100644 index 0000000..7d94806 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.set_iam_policy.js @@ -0,0 +1,74 @@ +// 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(resource, policy) { + // [START cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/folders.test_iam_permissions.js new file mode 100644 index 0000000..c016fc1 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.undelete_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.undelete_folder.js new file mode 100644 index 0000000..1ecf3de --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.undelete_folder.js @@ -0,0 +1,60 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the folder to undelete. + * Must be of the form `folders/{folder_id}`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callUndeleteFolder() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.undeleteFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUndeleteFolder(); + // [END cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.update_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.update_folder.js new file mode 100644 index 0000000..b16522d --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/folders.update_folder.js @@ -0,0 +1,66 @@ +// 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(folder, updateMask) { + // [START cloudresourcemanager_v3_generated_Folders_UpdateFolder_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new definition of the Folder. It must include the `name` field, which + * cannot be changed. + */ + // const folder = {} + /** + * Required. Fields to be updated. + * Only the `display_name` can be updated. + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {FoldersClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new FoldersClient(); + + async function callUpdateFolder() { + // Construct request + const request = { + folder, + updateMask, + }; + + // Run request + const [operation] = await resourcemanagerClient.updateFolder(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateFolder(); + // [END cloudresourcemanager_v3_generated_Folders_UpdateFolder_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/organizations.get_iam_policy.js new file mode 100644 index 0000000..fbcdf88 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/organizations.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.get_organization.js b/owl-bot-staging/v3/samples/generated/v3/organizations.get_organization.js new file mode 100644 index 0000000..a520198 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/organizations.get_organization.js @@ -0,0 +1,60 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_Organizations_GetOrganization_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Organization to fetch. This is the organization's + * relative path in the API, formatted as "organizations/[organizationId]". + * For example, "organizations/1234". + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callGetOrganization() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getOrganization(request); + console.log(response); + } + + callGetOrganization(); + // [END cloudresourcemanager_v3_generated_Organizations_GetOrganization_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.search_organizations.js b/owl-bot-staging/v3/samples/generated/v3/organizations.search_organizations.js new file mode 100644 index 0000000..eb719e3 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/organizations.search_organizations.js @@ -0,0 +1,83 @@ +// 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 cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. The maximum number of organizations to return in the response. + * If unspecified, server picks an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to `SearchOrganizations` + * that indicates from where listing should continue. + */ + // const pageToken = 'abc123' + /** + * Optional. An optional query string used to filter the Organizations to return in + * the response. Query rules are case-insensitive. + * ``` + * | Field | Description | + * |------------------|--------------------------------------------| + * | directoryCustomerId, owner.directoryCustomerId | Filters by directory + * customer id. | + * | domain | Filters by domain. | + * ``` + * Organizations may be queried by `directoryCustomerId` or by + * `domain`, where the domain is a G Suite domain, for example: + * * Query `directorycustomerid:123456789` returns Organization + * resources with `owner.directory_customer_id` equal to `123456789`. + * * Query `domain:google.com` returns Organization resources corresponding + * to the domain `google.com`. + */ + // const query = 'abc123' + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callSearchOrganizations() { + // Construct request + const request = { + }; + + // Run request + const iterable = await resourcemanagerClient.searchOrganizationsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchOrganizations(); + // [END cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/organizations.set_iam_policy.js new file mode 100644 index 0000000..86ed152 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/organizations.set_iam_policy.js @@ -0,0 +1,74 @@ +// 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(resource, policy) { + // [START cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/organizations.test_iam_permissions.js new file mode 100644 index 0000000..f807e41 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/organizations.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Resourcemanager library + const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new OrganizationsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.create_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.create_project.js new file mode 100644 index 0000000..c9da418 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.create_project.js @@ -0,0 +1,65 @@ +// 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(project) { + // [START cloudresourcemanager_v3_generated_Projects_CreateProject_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The Project to create. + * Project ID is required. If the requested ID is unavailable, the request + * fails. + * If the `parent` field is set, the `resourcemanager.projects.create` + * permission is checked on the parent resource. If no parent is set and + * the authorization credentials belong to an Organziation, the parent + * will be set to that Organization. + */ + // const project = 'my-project' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callCreateProject() { + // Construct request + const request = { + project, + }; + + // Run request + const [operation] = await resourcemanagerClient.createProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateProject(); + // [END cloudresourcemanager_v3_generated_Projects_CreateProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.delete_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.delete_project.js new file mode 100644 index 0000000..c8ec405 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.delete_project.js @@ -0,0 +1,59 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_Projects_DeleteProject_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the Project (for example, `projects/415104041262`). + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callDeleteProject() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteProject(); + // [END cloudresourcemanager_v3_generated_Projects_DeleteProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/projects.get_iam_policy.js new file mode 100644 index 0000000..c8b3347 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.get_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.get_project.js new file mode 100644 index 0000000..fc9dfdf --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.get_project.js @@ -0,0 +1,58 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_Projects_GetProject_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project (for example, `projects/415104041262`). + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callGetProject() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getProject(request); + console.log(response); + } + + callGetProject(); + // [END cloudresourcemanager_v3_generated_Projects_GetProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.list_projects.js b/owl-bot-staging/v3/samples/generated/v3/projects.list_projects.js new file mode 100644 index 0000000..49c3c59 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.list_projects.js @@ -0,0 +1,79 @@ +// 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(parent) { + // [START cloudresourcemanager_v3_generated_Projects_ListProjects_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the parent resource to list projects under. + * For example, setting this field to 'folders/1234' would list all projects + * directly under that folder. + */ + // const parent = 'abc123' + /** + * Optional. A pagination token returned from a previous call to ListProjects + * google.cloud.resourcemanager.v3.Projects.ListProjects + * that indicates from where listing should continue. + */ + // const pageToken = 'abc123' + /** + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + */ + // const pageSize = 1234 + /** + * Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be + * returned. Normally only `ACTIVE` projects are returned. + */ + // const showDeleted = true + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callListProjects() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listProjectsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListProjects(); + // [END cloudresourcemanager_v3_generated_Projects_ListProjects_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.move_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.move_project.js new file mode 100644 index 0000000..3c443ab --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.move_project.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(name, destinationParent) { + // [START cloudresourcemanager_v3_generated_Projects_MoveProject_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project to move. + */ + // const name = 'abc123' + /** + * Required. The new parent to move the Project under. + */ + // const destinationParent = 'abc123' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callMoveProject() { + // Construct request + const request = { + name, + destinationParent, + }; + + // Run request + const [operation] = await resourcemanagerClient.moveProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callMoveProject(); + // [END cloudresourcemanager_v3_generated_Projects_MoveProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.search_projects.js b/owl-bot-staging/v3/samples/generated/v3/projects.search_projects.js new file mode 100644 index 0000000..dd711a8 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.search_projects.js @@ -0,0 +1,104 @@ +// 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 cloudresourcemanager_v3_generated_Projects_SearchProjects_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Optional. A query string for searching for projects that the caller has + * `resourcemanager.projects.get` permission to. If multiple fields are + * included in the query, the it will return results that match any of the + * fields. Some eligible fields are: + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------------| + * | displayName, name | Filters by displayName. | + * | parent | Project's parent. (for example: folders/123, + * organizations/*) Prefer parent field over parent.type and parent.id. | + * | parent.type | Parent's type: `folder` or `organization`. | + * | parent.id | Parent's id number (for example: 123) | + * | id, projectId | Filters by projectId. | + * | state, lifecycleState | Filters by state. | + * | labels | Filters by label name or value. | + * | labels. (where *key* is the name of a label) | Filters by label + * name. | + * ``` + * Search expressions are case insensitive. + * Some examples queries: + * ``` + * | Query | Description | + * |------------------|-----------------------------------------------------| + * | name:how* | The project's name starts with "how". | + * | name:Howl | The project's name is `Howl` or `howl`. | + * | name:HOWL | Equivalent to above. | + * | NAME:howl | Equivalent to above. | + * | labels.color:* | The project has the label `color`. | + * | labels.color:red | The project's label `color` has the value `red`. | + * | labels.color:red labels.size:big | The project's label `color` has + * the value `red` and its label `size` has the value `big`. | + * ``` + * If no query is specified, the call will return projects for which the user + * has the `resourcemanager.projects.get` permission. + */ + // const query = 'abc123' + /** + * Optional. A pagination token returned from a previous call to ListProjects + * google.cloud.resourcemanager.v3.Projects.ListProjects + * that indicates from where listing should continue. + */ + // const pageToken = 'abc123' + /** + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + */ + // const pageSize = 1234 + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callSearchProjects() { + // Construct request + const request = { + }; + + // Run request + const iterable = await resourcemanagerClient.searchProjectsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callSearchProjects(); + // [END cloudresourcemanager_v3_generated_Projects_SearchProjects_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/projects.set_iam_policy.js new file mode 100644 index 0000000..19d61d3 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.set_iam_policy.js @@ -0,0 +1,74 @@ +// 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(resource, policy) { + // [START cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/projects.test_iam_permissions.js new file mode 100644 index 0000000..7d56e8b --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.undelete_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.undelete_project.js new file mode 100644 index 0000000..8ecca17 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.undelete_project.js @@ -0,0 +1,60 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_Projects_UndeleteProject_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the project (for example, `projects/415104041262`). + * Required. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callUndeleteProject() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.undeleteProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUndeleteProject(); + // [END cloudresourcemanager_v3_generated_Projects_UndeleteProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.update_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.update_project.js new file mode 100644 index 0000000..ed97372 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/projects.update_project.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(project) { + // [START cloudresourcemanager_v3_generated_Projects_UpdateProject_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new definition of the project. + */ + // const project = 'my-project' + /** + * Optional. An update mask to selectively update fields. + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {ProjectsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new ProjectsClient(); + + async function callUpdateProject() { + // Construct request + const request = { + project, + }; + + // Run request + const [operation] = await resourcemanagerClient.updateProject(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateProject(); + // [END cloudresourcemanager_v3_generated_Projects_UpdateProject_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/snippet_metadata.google.cloud.resourcemanager.v3.json b/owl-bot-staging/v3/samples/generated/v3/snippet_metadata.google.cloud.resourcemanager.v3.json new file mode 100644 index 0000000..67a3c2f --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/snippet_metadata.google.cloud.resourcemanager.v3.json @@ -0,0 +1,2067 @@ +{ + "clientLibrary": { + "name": "nodejs-resourcemanager", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.resourcemanager.v3", + "version": "v3" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_GetFolder_async", + "title": "Folders getFolder Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a folder identified by the supplied resource name. Valid folder resource names have the format `folders/{folder_id}` (for example, `folders/1234`). The caller must have `resourcemanager.folders.get` permission on the identified folder.", + "canonical": true, + "file": "folders.get_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.GetFolder", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.Folder", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "GetFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.GetFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_ListFolders_async", + "title": "Folders listFolders Sample", + "origin": "API_DEFINITION", + "description": " Lists the folders that are direct descendants of supplied parent resource. `list()` provides a strongly consistent view of the folders underneath the specified parent resource. `list()` returns folders sorted based upon the (ascending) lexical ordering of their display_name. The caller must have `resourcemanager.folders.list` permission on the identified parent.", + "canonical": true, + "file": "folders.list_folders.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 72, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListFolders", + "fullName": "google.cloud.resourcemanager.v3.Folders.ListFolders", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListFoldersResponse", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "ListFolders", + "fullName": "google.cloud.resourcemanager.v3.Folders.ListFolders", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_SearchFolders_async", + "title": "Folders searchFolders Sample", + "origin": "API_DEFINITION", + "description": " Search for folders that match specific filter criteria. `search()` provides an eventually consistent view of the folders a user has access to which meet the specified filter criteria. This will only return folders on which the caller has the permission `resourcemanager.folders.get`.", + "canonical": true, + "file": "folders.search_folders.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 86, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchFolders", + "fullName": "google.cloud.resourcemanager.v3.Folders.SearchFolders", + "async": true, + "parameters": [ + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.SearchFoldersResponse", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "SearchFolders", + "fullName": "google.cloud.resourcemanager.v3.Folders.SearchFolders", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_CreateFolder_async", + "title": "Folders createFolder Sample", + "origin": "API_DEFINITION", + "description": " Creates a folder in the resource hierarchy. Returns an `Operation` which can be used to track the progress of the folder creation workflow. Upon success, the `Operation.response` field will be populated with the created Folder. In order to succeed, the addition of this new folder must not violate the folder naming, height, or fanout constraints. + The folder's `display_name` must be distinct from all other folders that share its parent. + The addition of the folder must not cause the active folder hierarchy to exceed a height of 10. Note, the full active + deleted folder hierarchy is allowed to reach a height of 20; this provides additional headroom when moving folders that contain deleted folders. + The addition of the folder must not cause the total number of folders under its parent to exceed 300. If the operation fails due to a folder constraint violation, some errors may be returned by the `CreateFolder` request, with status code `FAILED_PRECONDITION` and an error description. Other folder constraint violations will be communicated in the `Operation`, with the specific `PreconditionFailure` returned in the details list in the `Operation.error` field. The caller must have `resourcemanager.folders.create` permission on the identified parent.", + "canonical": true, + "file": "folders.create_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 52, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.CreateFolder", + "async": true, + "parameters": [ + { + "name": "folder", + "type": ".google.cloud.resourcemanager.v3.Folder" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "CreateFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.CreateFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_UpdateFolder_async", + "title": "Folders updateFolder Sample", + "origin": "API_DEFINITION", + "description": " Updates a folder, changing its `display_name`. Changes to the folder `display_name` will be rejected if they violate either the `display_name` formatting rules or the naming constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The folder's `display_name` must start and end with a letter or digit, may contain letters, digits, spaces, hyphens and underscores and can be between 3 and 30 characters. This is captured by the regular expression: `[\\p{L}\\p{N}][\\p{L}\\p{N}_- ]{1,28}[\\p{L}\\p{N}]`. The caller must have `resourcemanager.folders.update` permission on the identified folder. If the update fails due to the unique name constraint then a `PreconditionFailure` explaining this violation will be returned in the Status.details field.", + "canonical": true, + "file": "folders.update_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.UpdateFolder", + "async": true, + "parameters": [ + { + "name": "folder", + "type": ".google.cloud.resourcemanager.v3.Folder" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "UpdateFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.UpdateFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_MoveFolder_async", + "title": "Folders moveFolder Sample", + "origin": "API_DEFINITION", + "description": " Moves a folder under a new resource parent. Returns an `Operation` which can be used to track the progress of the folder move workflow. Upon success, the `Operation.response` field will be populated with the moved folder. Upon failure, a `FolderOperationError` categorizing the failure cause will be returned - if the failure occurs synchronously then the `FolderOperationError` will be returned in the `Status.details` field. If it occurs asynchronously, then the FolderOperation will be returned in the `Operation.error` field. In addition, the `Operation.metadata` field will be populated with a `FolderOperation` message as an aid to stateless clients. Folder moves will be rejected if they violate either the naming, height, or fanout constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The caller must have `resourcemanager.folders.move` permission on the folder's current and proposed new parent.", + "canonical": true, + "file": "folders.move_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MoveFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.MoveFolder", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "destination_parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "MoveFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.MoveFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_DeleteFolder_async", + "title": "Folders deleteFolder Sample", + "origin": "API_DEFINITION", + "description": " Requests deletion of a folder. The folder is moved into the [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state immediately, and is deleted approximately 30 days later. This method may only be called on an empty folder, where a folder is empty if it doesn't contain any folders or projects in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If called on a folder in [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state the operation will result in a no-op success. The caller must have `resourcemanager.folders.delete` permission on the identified folder.", + "canonical": true, + "file": "folders.delete_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 52, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.DeleteFolder", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "DeleteFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.DeleteFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async", + "title": "Folders undeleteFolder Sample", + "origin": "API_DEFINITION", + "description": " Cancels the deletion request for a folder. This method may be called on a folder in any state. If the folder is in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the result will be a no-op success. In order to succeed, the folder's parent must be in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In addition, reintroducing the folder into the tree must not violate folder naming, height, and fanout constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The caller must have `resourcemanager.folders.undelete` permission on the identified folder.", + "canonical": true, + "file": "folders.undelete_folder.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 52, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UndeleteFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.UndeleteFolder", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "UndeleteFolder", + "fullName": "google.cloud.resourcemanager.v3.Folders.UndeleteFolder", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a folder. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the folder's resource name, for example: \"folders/1234\". The caller must have `resourcemanager.folders.getIamPolicy` permission on the identified folder.", + "canonical": true, + "file": "folders.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Folders.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Folders.GetIamPolicy", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on a folder, replacing any existing policy. The `resource` field should be the folder's resource name, for example: \"folders/1234\". The caller must have `resourcemanager.folders.setIamPolicy` permission on the identified folder.", + "canonical": true, + "file": "folders.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Folders.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Folders.SetIamPolicy", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified folder. The `resource` field should be the folder's resource name, for example: \"folders/1234\". There are no permissions required for making this API call.", + "canonical": true, + "file": "folders.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Folders.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "FoldersClient", + "fullName": "google.cloud.resourcemanager.v3.FoldersClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Folders.TestIamPermissions", + "service": { + "shortName": "Folders", + "fullName": "google.cloud.resourcemanager.v3.Folders" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_GetOrganization_async", + "title": "Folders getOrganization Sample", + "origin": "API_DEFINITION", + "description": " Fetches an organization resource identified by the specified resource name.", + "canonical": true, + "file": "organizations.get_organization.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 52, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetOrganization", + "fullName": "google.cloud.resourcemanager.v3.Organizations.GetOrganization", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.Organization", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "GetOrganization", + "fullName": "google.cloud.resourcemanager.v3.Organizations.GetOrganization", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async", + "title": "Folders searchOrganizations Sample", + "origin": "API_DEFINITION", + "description": " Searches organization resources that are visible to the user and satisfy the specified filter. This method returns organizations in an unspecified order. New organizations do not necessarily appear at the end of the results, and may take a small amount of time to appear. Search will only return organizations on which the user has the permission `resourcemanager.organizations.get`", + "canonical": true, + "file": "organizations.search_organizations.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchOrganizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations.SearchOrganizations", + "async": true, + "parameters": [ + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "query", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.SearchOrganizationsResponse", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "SearchOrganizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations.SearchOrganizations", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for an organization resource. The policy may be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, for example: \"organizations/123\". Authorization requires the IAM permission `resourcemanager.organizations.getIamPolicy` on the specified organization.", + "canonical": true, + "file": "organizations.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Organizations.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Organizations.GetIamPolicy", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on an organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, for example: \"organizations/123\". Authorization requires the IAM permission `resourcemanager.organizations.setIamPolicy` on the specified organization.", + "canonical": true, + "file": "organizations.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Organizations.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Organizations.SetIamPolicy", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns the permissions that a caller has on the specified organization. The `resource` field should be the organization's resource name, for example: \"organizations/123\". There are no permissions required for making this API call.", + "canonical": true, + "file": "organizations.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Organizations.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "OrganizationsClient", + "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Organizations.TestIamPermissions", + "service": { + "shortName": "Organizations", + "fullName": "google.cloud.resourcemanager.v3.Organizations" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_GetProject_async", + "title": "Folders getProject Sample", + "origin": "API_DEFINITION", + "description": " Retrieves the project identified by the specified `name` (for example, `projects/415104041262`). The caller must have `resourcemanager.projects.get` permission for this project.", + "canonical": true, + "file": "projects.get_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.GetProject", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.Project", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "GetProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.GetProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_ListProjects_async", + "title": "Folders listProjects Sample", + "origin": "API_DEFINITION", + "description": " Lists projects that are direct children of the specified folder or organization resource. `list()` provides a strongly consistent view of the projects underneath the specified parent resource. `list()` returns projects sorted based upon the (ascending) lexical ordering of their `display_name`. The caller must have `resourcemanager.projects.list` permission on the identified parent.", + "canonical": true, + "file": "projects.list_projects.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 71, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListProjects", + "fullName": "google.cloud.resourcemanager.v3.Projects.ListProjects", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "show_deleted", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListProjectsResponse", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "ListProjects", + "fullName": "google.cloud.resourcemanager.v3.Projects.ListProjects", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_SearchProjects_async", + "title": "Folders searchProjects Sample", + "origin": "API_DEFINITION", + "description": " Search for projects that the caller has both `resourcemanager.projects.get` permission on, and also satisfy the specified query. This method returns projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method.", + "canonical": true, + "file": "projects.search_projects.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 96, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SearchProjects", + "fullName": "google.cloud.resourcemanager.v3.Projects.SearchProjects", + "async": true, + "parameters": [ + { + "name": "query", + "type": "TYPE_STRING" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.SearchProjectsResponse", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "SearchProjects", + "fullName": "google.cloud.resourcemanager.v3.Projects.SearchProjects", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_CreateProject_async", + "title": "Folders createProject Sample", + "origin": "API_DEFINITION", + "description": " Request that a new project be created. The result is an `Operation` which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking `Operation` is automatically deleted after a few hours, so there is no need to call `DeleteOperation`.", + "canonical": true, + "file": "projects.create_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.CreateProject", + "async": true, + "parameters": [ + { + "name": "project", + "type": ".google.cloud.resourcemanager.v3.Project" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "CreateProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.CreateProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_UpdateProject_async", + "title": "Folders updateProject Sample", + "origin": "API_DEFINITION", + "description": " Updates the `display_name` and labels of the project identified by the specified `name` (for example, `projects/415104041262`). Deleting all labels requires an update mask for labels field. The caller must have `resourcemanager.projects.update` permission for this project.", + "canonical": true, + "file": "projects.update_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.UpdateProject", + "async": true, + "parameters": [ + { + "name": "project", + "type": ".google.cloud.resourcemanager.v3.Project" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "UpdateProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.UpdateProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_MoveProject_async", + "title": "Folders moveProject Sample", + "origin": "API_DEFINITION", + "description": " Move a project to another place in your resource hierarchy, under a new resource parent. Returns an operation which can be used to track the process of the project move workflow. Upon success, the `Operation.response` field will be populated with the moved project. The caller must have `resourcemanager.projects.update` permission on the project and have `resourcemanager.projects.move` permission on the project's current and proposed new parent.", + "canonical": true, + "file": "projects.move_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MoveProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.MoveProject", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "destination_parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "MoveProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.MoveProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_DeleteProject_async", + "title": "Folders deleteProject Sample", + "origin": "API_DEFINITION", + "description": " Marks the project identified by the specified `name` (for example, `projects/415104041262`) for deletion. This method will only affect the project if it has a lifecycle state of [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. This method changes the Project's lifecycle state from [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] to [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the project with [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], and the project remains visible to [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects]. However, you cannot update the project. After the deletion completes, the project is not retrievable by the [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects], and [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] methods. This method behaves idempotently, such that deleting a `DELETE_REQUESTED` project will not cause an error, but also won't do anything. The caller must have `resourcemanager.projects.delete` permissions for this project.", + "canonical": true, + "file": "projects.delete_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.DeleteProject", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "DeleteProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.DeleteProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_UndeleteProject_async", + "title": "Folders undeleteProject Sample", + "origin": "API_DEFINITION", + "description": " Restores the project identified by the specified `name` (for example, `projects/415104041262`). You can only use this method for a project that has a lifecycle state of [DELETE_REQUESTED] [Projects.State.DELETE_REQUESTED]. After deletion starts, the project cannot be restored. The caller must have `resourcemanager.projects.undelete` permission for this project.", + "canonical": true, + "file": "projects.undelete_project.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 52, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UndeleteProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.UndeleteProject", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "UndeleteProject", + "fullName": "google.cloud.resourcemanager.v3.Projects.UndeleteProject", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Returns the IAM access control policy for the specified project. Permission is denied if the policy or the resource do not exist.", + "canonical": true, + "file": "projects.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Projects.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Projects.GetIamPolicy", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the IAM access control policy for the specified project. CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted to a `user`, `serviceAccount`, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited using the Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + Membership changes that leave the project without any owners that have accepted the Terms of Service (ToS) will be rejected. + If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. + Calling this method requires enabling the App Engine Admin API.", + "canonical": true, + "file": "projects.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Projects.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.Projects.SetIamPolicy", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified project.", + "canonical": true, + "file": "projects.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Projects.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "ProjectsClient", + "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.Projects.TestIamPermissions", + "service": { + "shortName": "Projects", + "fullName": "google.cloud.resourcemanager.v3.Projects" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async", + "title": "Folders listTagBindings Sample", + "origin": "API_DEFINITION", + "description": " Lists the TagBindings for the given cloud resource, as specified with `parent`. NOTE: The `parent` field is expected to be a full resource name: https://cloud.google.com/apis/design/resource_names#full_resource_name", + "canonical": true, + "file": "tag_bindings.list_tag_bindings.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListTagBindings", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListTagBindingsResponse", + "client": { + "shortName": "TagBindingsClient", + "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" + }, + "method": { + "shortName": "ListTagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListTagBindings", + "service": { + "shortName": "TagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async", + "title": "Folders createTagBinding Sample", + "origin": "API_DEFINITION", + "description": " Creates a TagBinding between a TagValue and a cloud resource (currently project, folder, or organization).", + "canonical": true, + "file": "tag_bindings.create_tag_binding.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateTagBinding", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.CreateTagBinding", + "async": true, + "parameters": [ + { + "name": "tag_binding", + "type": ".google.cloud.resourcemanager.v3.TagBinding" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagBindingsClient", + "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" + }, + "method": { + "shortName": "CreateTagBinding", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.CreateTagBinding", + "service": { + "shortName": "TagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async", + "title": "Folders deleteTagBinding Sample", + "origin": "API_DEFINITION", + "description": " Deletes a TagBinding.", + "canonical": true, + "file": "tag_bindings.delete_tag_binding.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteTagBinding", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.DeleteTagBinding", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagBindingsClient", + "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" + }, + "method": { + "shortName": "DeleteTagBinding", + "fullName": "google.cloud.resourcemanager.v3.TagBindings.DeleteTagBinding", + "service": { + "shortName": "TagBindings", + "fullName": "google.cloud.resourcemanager.v3.TagBindings" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async", + "title": "Folders listTagKeys Sample", + "origin": "API_DEFINITION", + "description": " Lists all TagKeys for a parent resource.", + "canonical": true, + "file": "tag_keys.list_tag_keys.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.ListTagKeys", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListTagKeysResponse", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "ListTagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.ListTagKeys", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async", + "title": "Folders getTagKey Sample", + "origin": "API_DEFINITION", + "description": " Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the key does not exist or the user does not have permission to view it.", + "canonical": true, + "file": "tag_keys.get_tag_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetTagKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.TagKey", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "GetTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetTagKey", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async", + "title": "Folders createTagKey Sample", + "origin": "API_DEFINITION", + "description": " Creates a new TagKey. If another request with the same parameters is sent while the original request is in process, the second request will receive an error. A maximum of 300 TagKeys can exist under a parent at any given time.", + "canonical": true, + "file": "tag_keys.create_tag_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.CreateTagKey", + "async": true, + "parameters": [ + { + "name": "tag_key", + "type": ".google.cloud.resourcemanager.v3.TagKey" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "CreateTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.CreateTagKey", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async", + "title": "Folders updateTagKey Sample", + "origin": "API_DEFINITION", + "description": " Updates the attributes of the TagKey resource.", + "canonical": true, + "file": "tag_keys.update_tag_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.UpdateTagKey", + "async": true, + "parameters": [ + { + "name": "tag_key", + "type": ".google.cloud.resourcemanager.v3.TagKey" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "UpdateTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.UpdateTagKey", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async", + "title": "Folders deleteTagKey Sample", + "origin": "API_DEFINITION", + "description": " Deletes a TagKey. The TagKey cannot be deleted if it has any child TagValues.", + "canonical": true, + "file": "tag_keys.delete_tag_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.DeleteTagKey", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "DeleteTagKey", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.DeleteTagKey", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a TagKey. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". The caller must have `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on the specified TagKey.", + "canonical": true, + "file": "tag_keys.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetIamPolicy", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on a TagKey, replacing any existing policy. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". The caller must have `resourcemanager.tagKeys.setIamPolicy` permission on the identified tagValue.", + "canonical": true, + "file": "tag_keys.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.SetIamPolicy", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified TagKey. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". There are no permissions required for making this API call.", + "canonical": true, + "file": "tag_keys.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "TagKeysClient", + "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.TagKeys.TestIamPermissions", + "service": { + "shortName": "TagKeys", + "fullName": "google.cloud.resourcemanager.v3.TagKeys" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_ListTagValues_async", + "title": "Folders listTagValues Sample", + "origin": "API_DEFINITION", + "description": " Lists all TagValues for a specific TagKey.", + "canonical": true, + "file": "tag_values.list_tag_values.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListTagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues.ListTagValues", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.ListTagValuesResponse", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "ListTagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues.ListTagValues", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetTagValue_async", + "title": "Folders getTagValue Sample", + "origin": "API_DEFINITION", + "description": " Retrieves TagValue. If the TagValue or namespaced name does not exist, or if the user does not have permission to view it, this method will return `PERMISSION_DENIED`.", + "canonical": true, + "file": "tag_values.get_tag_value.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 50, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetTagValue", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.resourcemanager.v3.TagValue", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "GetTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetTagValue", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async", + "title": "Folders createTagValue Sample", + "origin": "API_DEFINITION", + "description": " Creates a TagValue as a child of the specified TagKey. If a another request with the same parameters is sent while the original request is in process the second request will receive an error. A maximum of 300 TagValues can exist under a TagKey at any given time.", + "canonical": true, + "file": "tag_values.create_tag_value.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.CreateTagValue", + "async": true, + "parameters": [ + { + "name": "tag_value", + "type": ".google.cloud.resourcemanager.v3.TagValue" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "CreateTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.CreateTagValue", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async", + "title": "Folders updateTagValue Sample", + "origin": "API_DEFINITION", + "description": " Updates the attributes of the TagValue resource.", + "canonical": true, + "file": "tag_values.update_tag_value.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.UpdateTagValue", + "async": true, + "parameters": [ + { + "name": "tag_value", + "type": ".google.cloud.resourcemanager.v3.TagValue" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "UpdateTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.UpdateTagValue", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async", + "title": "Folders deleteTagValue Sample", + "origin": "API_DEFINITION", + "description": " Deletes a TagValue. The TagValue cannot have any bindings when it is deleted.", + "canonical": true, + "file": "tag_values.delete_tag_value.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.DeleteTagValue", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "validate_only", + "type": "TYPE_BOOL" + }, + { + "name": "etag", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "DeleteTagValue", + "fullName": "google.cloud.resourcemanager.v3.TagValues.DeleteTagValue", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async", + "title": "Folders getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a TagValue. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. The caller must have the `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on the identified TagValue to get the access control policy.", + "canonical": true, + "file": "tag_values.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagValues.GetIamPolicy", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async", + "title": "Folders setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on a TagValue, replacing any existing policy. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. The caller must have `resourcemanager.tagValues.setIamPolicy` permission on the identified tagValue.", + "canonical": true, + "file": "tag_values.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagValues.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.resourcemanager.v3.TagValues.SetIamPolicy", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + }, + { + "regionTag": "cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async", + "title": "Folders testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified TagValue. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. There are no permissions required for making this API call.", + "canonical": true, + "file": "tag_values.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.TagValues.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "TagValuesClient", + "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.resourcemanager.v3.TagValues.TestIamPermissions", + "service": { + "shortName": "TagValues", + "fullName": "google.cloud.resourcemanager.v3.TagValues" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_bindings.create_tag_binding.js b/owl-bot-staging/v3/samples/generated/v3/tag_bindings.create_tag_binding.js new file mode 100644 index 0000000..d04c57e --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_bindings.create_tag_binding.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(tagBinding) { + // [START cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The TagBinding to be created. + */ + // const tagBinding = {} + /** + * Optional. Set to true to perform the validations necessary for creating the resource, + * but not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagBindingsClient(); + + async function callCreateTagBinding() { + // Construct request + const request = { + tagBinding, + }; + + // Run request + const [operation] = await resourcemanagerClient.createTagBinding(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateTagBinding(); + // [END cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js b/owl-bot-staging/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js new file mode 100644 index 0000000..511ff1d --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_bindings.delete_tag_binding.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(name) { + // [START cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the TagBinding. This is a String of the form: + * `tagBindings/{id}` (e.g. + * `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagBindingsClient(); + + async function callDeleteTagBinding() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteTagBinding(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteTagBinding(); + // [END cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js b/owl-bot-staging/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js new file mode 100644 index 0000000..faa55a2 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js @@ -0,0 +1,73 @@ +// 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(parent) { + // [START cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The full resource name of a resource for which you want to list existing + * TagBindings. + * E.g. "//cloudresourcemanager.googleapis.com/projects/123" + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of TagBindings to return in the response. The server + * allows a maximum of 300 TagBindings to return. If unspecified, the server + * will use 100 as the default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to `ListTagBindings` + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Resourcemanager library + const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagBindingsClient(); + + async function callListTagBindings() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listTagBindingsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTagBindings(); + // [END cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.create_tag_key.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.create_tag_key.js new file mode 100644 index 0000000..270f21a --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_keys.create_tag_key.js @@ -0,0 +1,65 @@ +// 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(tagKey) { + // [START cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The TagKey to be created. Only fields `short_name`, `description`, + * and `parent` are considered during the creation request. + */ + // const tagKey = {} + /** + * Optional. Set to true to perform validations necessary for creating the resource, but + * not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callCreateTagKey() { + // Construct request + const request = { + tagKey, + }; + + // Run request + const [operation] = await resourcemanagerClient.createTagKey(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateTagKey(); + // [END cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.delete_tag_key.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.delete_tag_key.js new file mode 100644 index 0000000..f27a8e5 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_keys.delete_tag_key.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(name) { + // [START cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of a TagKey to be deleted in the format `tagKeys/123`. + * The TagKey cannot be a parent of any existing TagValues or it will not be + * deleted successfully. + */ + // const name = 'abc123' + /** + * Optional. Set as true to perform validations necessary for deletion, but not actually + * perform the action. + */ + // const validateOnly = true + /** + * Optional. The etag known to the client for the expected state of the TagKey. This is + * to be used for optimistic concurrency. + */ + // const etag = 'abc123' + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callDeleteTagKey() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteTagKey(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteTagKey(); + // [END cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_iam_policy.js new file mode 100644 index 0000000..23f6fc8 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_tag_key.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_tag_key.js new file mode 100644 index 0000000..22b41f5 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_tag_key.js @@ -0,0 +1,59 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. A resource name in the format `tagKeys/{id}`, such as + * `tagKeys/123`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callGetTagKey() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getTagKey(request); + console.log(response); + } + + callGetTagKey(); + // [END cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.list_tag_keys.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.list_tag_keys.js new file mode 100644 index 0000000..71be42c --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_keys.list_tag_keys.js @@ -0,0 +1,72 @@ +// 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(parent) { + // [START cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the new TagKey's parent. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of TagKeys to return in the response. The server allows + * a maximum of 300 TagKeys to return. If unspecified, the server will use 100 + * as the default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to `ListTagKey` + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callListTagKeys() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listTagKeysAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTagKeys(); + // [END cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.set_iam_policy.js new file mode 100644 index 0000000..1442ba4 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_keys.set_iam_policy.js @@ -0,0 +1,74 @@ +// 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(resource, policy) { + // [START cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.test_iam_permissions.js new file mode 100644 index 0000000..1927d00 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_keys.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.update_tag_key.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.update_tag_key.js new file mode 100644 index 0000000..b21cf23 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_keys.update_tag_key.js @@ -0,0 +1,73 @@ +// 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(tagKey) { + // [START cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new definition of the TagKey. Only the `description` and `etag` fields + * can be updated by this request. If the `etag` field is not empty, it + * must match the `etag` field of the existing tag key. Otherwise, + * `FAILED_PRECONDITION` will be returned. + */ + // const tagKey = {} + /** + * Fields to be updated. The mask may only contain `description` or + * `etag`. If omitted entirely, both `description` and `etag` are assumed to + * be significant. + */ + // const updateMask = {} + /** + * Set as true to perform validations necessary for updating the resource, but + * not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagKeysClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagKeysClient(); + + async function callUpdateTagKey() { + // Construct request + const request = { + tagKey, + }; + + // Run request + const [operation] = await resourcemanagerClient.updateTagKey(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateTagKey(); + // [END cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.create_tag_value.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.create_tag_value.js new file mode 100644 index 0000000..5ae067c --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_values.create_tag_value.js @@ -0,0 +1,65 @@ +// 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(tagValue) { + // [START cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The TagValue to be created. Only fields `short_name`, `description`, + * and `parent` are considered during the creation request. + */ + // const tagValue = {} + /** + * Optional. Set as true to perform the validations necessary for creating the resource, + * but not actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callCreateTagValue() { + // Construct request + const request = { + tagValue, + }; + + // Run request + const [operation] = await resourcemanagerClient.createTagValue(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateTagValue(); + // [END cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.delete_tag_value.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.delete_tag_value.js new file mode 100644 index 0000000..62feff2 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_values.delete_tag_value.js @@ -0,0 +1,69 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name for TagValue to be deleted in the format tagValues/456. + */ + // const name = 'abc123' + /** + * Optional. Set as true to perform the validations necessary for deletion, but not + * actually perform the action. + */ + // const validateOnly = true + /** + * Optional. The etag known to the client for the expected state of the TagValue. This + * is to be used for optimistic concurrency. + */ + // const etag = 'abc123' + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callDeleteTagValue() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await resourcemanagerClient.deleteTagValue(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteTagValue(); + // [END cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.get_iam_policy.js new file mode 100644 index 0000000..43370c2 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_values.get_iam_policy.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(resource) { + // [START cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await resourcemanagerClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.get_tag_value.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.get_tag_value.js new file mode 100644 index 0000000..b4fe6e3 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_values.get_tag_value.js @@ -0,0 +1,58 @@ +// 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(name) { + // [START cloudresourcemanager_v3_generated_TagValues_GetTagValue_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name for TagValue to be fetched in the format `tagValues/456`. + */ + // const name = 'abc123' + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callGetTagValue() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await resourcemanagerClient.getTagValue(request); + console.log(response); + } + + callGetTagValue(); + // [END cloudresourcemanager_v3_generated_TagValues_GetTagValue_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.list_tag_values.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.list_tag_values.js new file mode 100644 index 0000000..2523356 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_values.list_tag_values.js @@ -0,0 +1,72 @@ +// 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(parent) { + // [START cloudresourcemanager_v3_generated_TagValues_ListTagValues_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Resource name for TagKey, parent of the TagValues to be listed, + * in the format `tagKeys/123`. + */ + // const parent = 'abc123' + /** + * Optional. The maximum number of TagValues to return in the response. The server + * allows a maximum of 300 TagValues to return. If unspecified, the server + * will use 100 as the default. + */ + // const pageSize = 1234 + /** + * Optional. A pagination token returned from a previous call to `ListTagValues` + * that indicates where this listing should continue from. + */ + // const pageToken = 'abc123' + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callListTagValues() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await resourcemanagerClient.listTagValuesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListTagValues(); + // [END cloudresourcemanager_v3_generated_TagValues_ListTagValues_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.set_iam_policy.js new file mode 100644 index 0000000..6911eb8 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_values.set_iam_policy.js @@ -0,0 +1,74 @@ +// 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(resource, policy) { + // [START cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await resourcemanagerClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.test_iam_permissions.js new file mode 100644 index 0000000..7843a70 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_values.test_iam_permissions.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(resource, permissions) { + // [START cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await resourcemanagerClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.update_tag_value.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.update_tag_value.js new file mode 100644 index 0000000..8cd1194 --- /dev/null +++ b/owl-bot-staging/v3/samples/generated/v3/tag_values.update_tag_value.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(tagValue) { + // [START cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new definition of the TagValue. Only fields `description` and `etag` + * fields can be updated by this request. If the `etag` field is nonempty, it + * must match the `etag` field of the existing ControlGroup. Otherwise, + * `FAILED_PRECONDITION` will be returned. + */ + // const tagValue = {} + /** + * Optional. Fields to be updated. + */ + // const updateMask = {} + /** + * Optional. True to perform validations necessary for updating the resource, but not + * actually perform the action. + */ + // const validateOnly = true + + // Imports the Resourcemanager library + const {TagValuesClient} = require('@google-cloud/resource-manager').v3; + + // Instantiates a client + const resourcemanagerClient = new TagValuesClient(); + + async function callUpdateTagValue() { + // Construct request + const request = { + tagValue, + }; + + // Run request + const [operation] = await resourcemanagerClient.updateTagValue(request); + const [response] = await operation.promise(); + console.log(response); + } + + callUpdateTagValue(); + // [END cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/src/index.ts b/owl-bot-staging/v3/src/index.ts new file mode 100644 index 0000000..6ba6f62 --- /dev/null +++ b/owl-bot-staging/v3/src/index.ts @@ -0,0 +1,35 @@ +// 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 v3 from './v3'; +const FoldersClient = v3.FoldersClient; +type FoldersClient = v3.FoldersClient; +const OrganizationsClient = v3.OrganizationsClient; +type OrganizationsClient = v3.OrganizationsClient; +const ProjectsClient = v3.ProjectsClient; +type ProjectsClient = v3.ProjectsClient; +const TagBindingsClient = v3.TagBindingsClient; +type TagBindingsClient = v3.TagBindingsClient; +const TagKeysClient = v3.TagKeysClient; +type TagKeysClient = v3.TagKeysClient; +const TagValuesClient = v3.TagValuesClient; +type TagValuesClient = v3.TagValuesClient; +export {v3, FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagKeysClient, TagValuesClient}; +export default {v3, FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagKeysClient, TagValuesClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v3/src/v3/folders_client.ts b/owl-bot-staging/v3/src/v3/folders_client.ts new file mode 100644 index 0000000..4de30ae --- /dev/null +++ b/owl-bot-staging/v3/src/v3/folders_client.ts @@ -0,0 +1,1844 @@ +// 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/v3/folders_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './folders_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Manages Cloud Platform folder resources. + * Folders can be used to organize the resources under an + * organization and to control the policies applied to groups of resources. + * @class + * @memberof v3 + */ +export class FoldersClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + foldersStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of FoldersClient. + * + * @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 FoldersClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listFolders: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'folders'), + searchFolders: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'folders') + }; + + 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.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const createFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateFolderMetadata') as gax.protobuf.Type; + const updateFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const updateFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UpdateFolderMetadata') as gax.protobuf.Type; + const moveFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const moveFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.MoveFolderMetadata') as gax.protobuf.Type; + const deleteFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const deleteFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteFolderMetadata') as gax.protobuf.Type; + const undeleteFolderResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; + const undeleteFolderMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UndeleteFolderMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createFolderResponse.decode.bind(createFolderResponse), + createFolderMetadata.decode.bind(createFolderMetadata)), + updateFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateFolderResponse.decode.bind(updateFolderResponse), + updateFolderMetadata.decode.bind(updateFolderMetadata)), + moveFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + moveFolderResponse.decode.bind(moveFolderResponse), + moveFolderMetadata.decode.bind(moveFolderMetadata)), + deleteFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteFolderResponse.decode.bind(deleteFolderResponse), + deleteFolderMetadata.decode.bind(deleteFolderMetadata)), + undeleteFolder: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + undeleteFolderResponse.decode.bind(undeleteFolderResponse), + undeleteFolderMetadata.decode.bind(undeleteFolderMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.Folders', 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.foldersStub) { + return this.foldersStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.Folders. + this.foldersStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Folders') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.Folders, + 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 foldersStubMethods = + ['getFolder', 'listFolders', 'searchFolders', 'createFolder', 'updateFolder', 'moveFolder', 'deleteFolder', 'undeleteFolder', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of foldersStubMethods) { + const callPromise = this.foldersStub.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.foldersStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Retrieves a folder identified by the supplied resource name. + * Valid folder resource names have the format `folders/{folder_id}` + * (for example, `folders/1234`). + * The caller must have `resourcemanager.folders.get` permission on the + * identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the folder to retrieve. + * Must be of the form `folders/{folder_id}`. + * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder}. + * 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/v3/folders.get_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_GetFolder_async + */ + getFolder( + request?: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|undefined, {}|undefined + ]>; + getFolder( + request: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, + {}|null|undefined>): void; + getFolder( + request: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, + {}|null|undefined>): void; + getFolder( + request?: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder, + protos.google.cloud.resourcemanager.v3.IGetFolderRequest|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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getFolder(request, options, callback); + } +/** + * Gets the access control policy for a folder. The returned policy may be + * empty if no such policy or resource exists. The `resource` field should + * be the folder's resource name, for example: "folders/1234". + * The caller must have `resourcemanager.folders.getIamPolicy` permission + * on the identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/folders.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the access control policy on a folder, replacing any existing policy. + * The `resource` field should be the folder's resource name, for example: + * "folders/1234". + * The caller must have `resourcemanager.folders.setIamPolicy` permission + * on the identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/folders.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified folder. + * The `resource` field should be the folder's resource name, + * for example: "folders/1234". + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * 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/v3/folders.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a folder in the resource hierarchy. + * Returns an `Operation` which can be used to track the progress of the + * folder creation workflow. + * Upon success, the `Operation.response` field will be populated with the + * created Folder. + * + * In order to succeed, the addition of this new folder must not violate + * the folder naming, height, or fanout constraints. + * + * + The folder's `display_name` must be distinct from all other folders that + * share its parent. + * + The addition of the folder must not cause the active folder hierarchy + * to exceed a height of 10. Note, the full active + deleted folder hierarchy + * is allowed to reach a height of 20; this provides additional headroom when + * moving folders that contain deleted folders. + * + The addition of the folder must not cause the total number of folders + * under its parent to exceed 300. + * + * If the operation fails due to a folder constraint violation, some errors + * may be returned by the `CreateFolder` request, with status code + * `FAILED_PRECONDITION` and an error description. Other folder constraint + * violations will be communicated in the `Operation`, with the specific + * `PreconditionFailure` returned in the details list in the `Operation.error` + * field. + * + * The caller must have `resourcemanager.folders.create` permission on the + * identified parent. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.Folder} request.folder + * Required. The folder being created, only the display name and parent will be + * consulted. All other fields will be ignored. + * @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/v3/folders.create_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_CreateFolder_async + */ + createFolder( + request?: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createFolder( + request: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createFolder( + request: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createFolder( + request?: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.createFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createFolder()`. + * @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/v3/folders.create_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_CreateFolder_async + */ + async checkCreateFolderProgress(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.createFolder, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates a folder, changing its `display_name`. + * Changes to the folder `display_name` will be rejected if they violate + * either the `display_name` formatting rules or the naming constraints + * described in the {@link google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} documentation. + * + * The folder's `display_name` must start and end with a letter or digit, + * may contain letters, digits, spaces, hyphens and underscores and can be + * between 3 and 30 characters. This is captured by the regular expression: + * `{@link \p{L}\p{N}_- |\p{L}\p{N}}{1,28}[\p{L}\p{N}]`. + * The caller must have `resourcemanager.folders.update` permission on the + * identified folder. + * + * If the update fails due to the unique name constraint then a + * `PreconditionFailure` explaining this violation will be returned + * in the Status.details field. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.Folder} request.folder + * Required. The new definition of the Folder. It must include the `name` field, which + * cannot be changed. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Fields to be updated. + * Only the `display_name` can be updated. + * @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/v3/folders.update_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_UpdateFolder_async + */ + updateFolder( + request?: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateFolder( + request: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateFolder( + request: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateFolder( + request?: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, + 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({ + 'folder.name': request.folder!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateFolder()`. + * @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/v3/folders.update_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_UpdateFolder_async + */ + async checkUpdateFolderProgress(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.updateFolder, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Moves a folder under a new resource parent. + * Returns an `Operation` which can be used to track the progress of the + * folder move workflow. + * Upon success, the `Operation.response` field will be populated with the + * moved folder. + * Upon failure, a `FolderOperationError` categorizing the failure cause will + * be returned - if the failure occurs synchronously then the + * `FolderOperationError` will be returned in the `Status.details` field. + * If it occurs asynchronously, then the FolderOperation will be returned + * in the `Operation.error` field. + * In addition, the `Operation.metadata` field will be populated with a + * `FolderOperation` message as an aid to stateless clients. + * Folder moves will be rejected if they violate either the naming, height, + * or fanout constraints described in the + * {@link google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} documentation. + * The caller must have `resourcemanager.folders.move` permission on the + * folder's current and proposed new parent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Folder to move. + * Must be of the form folders/{folder_id} + * @param {string} request.destinationParent + * Required. The resource name of the folder or organization which should be the + * folder's new parent. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + * @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/v3/folders.move_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_MoveFolder_async + */ + moveFolder( + request?: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + moveFolder( + request: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + moveFolder( + request: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + moveFolder( + request?: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, + 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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.moveFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `moveFolder()`. + * @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/v3/folders.move_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_MoveFolder_async + */ + async checkMoveFolderProgress(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.moveFolder, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Requests deletion of a folder. The folder is moved into the + * {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} state + * immediately, and is deleted approximately 30 days later. This method may + * only be called on an empty folder, where a folder is empty if it doesn't + * contain any folders or projects in the {@link google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state. + * If called on a folder in {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} + * state the operation will result in a no-op success. + * The caller must have `resourcemanager.folders.delete` permission on the + * identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the folder to be deleted. + * Must be of the form `folders/{folder_id}`. + * @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/v3/folders.delete_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_DeleteFolder_async + */ + deleteFolder( + request?: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteFolder( + request: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteFolder( + request: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteFolder( + request?: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, + 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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteFolder()`. + * @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/v3/folders.delete_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_DeleteFolder_async + */ + async checkDeleteFolderProgress(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.deleteFolder, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Cancels the deletion request for a folder. This method may be called on a + * folder in any state. If the folder is in the {@link google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} + * state the result will be a no-op success. In order to succeed, the folder's + * parent must be in the {@link google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state. In addition, + * reintroducing the folder into the tree must not violate folder naming, + * height, and fanout constraints described in the + * {@link google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} documentation. + * The caller must have `resourcemanager.folders.undelete` permission on the + * identified folder. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the folder to undelete. + * Must be of the form `folders/{folder_id}`. + * @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/v3/folders.undelete_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async + */ + undeleteFolder( + request?: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + undeleteFolder( + request: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeleteFolder( + request: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeleteFolder( + request?: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, + 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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.undeleteFolder(request, options, callback); + } +/** + * Check the status of the long running operation returned by `undeleteFolder()`. + * @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/v3/folders.undelete_folder.js + * region_tag:cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async + */ + async checkUndeleteFolderProgress(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.undeleteFolder, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists the folders that are direct descendants of supplied parent resource. + * `list()` provides a strongly consistent view of the folders underneath + * the specified parent resource. + * `list()` returns folders sorted based upon the (ascending) lexical ordering + * of their display_name. + * The caller must have `resourcemanager.folders.list` permission on the + * identified parent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the organization or folder whose folders are + * being listed. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + * Access to this method is controlled by checking the + * `resourcemanager.folders.list` permission on the `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. + * If unspecified, server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListFolders` + * that indicates where this listing should continue from. + * @param {boolean} [request.showDeleted] + * Optional. Controls whether folders in the + * {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} + * state should be returned. Defaults to false. + * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder}. + * 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 `listFoldersAsync()` + * 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. + */ + listFolders( + request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder[], + protos.google.cloud.resourcemanager.v3.IListFoldersRequest|null, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse + ]>; + listFolders( + request: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): void; + listFolders( + request: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): void; + listFolders( + request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder[], + protos.google.cloud.resourcemanager.v3.IListFoldersRequest|null, + protos.google.cloud.resourcemanager.v3.IListFoldersResponse + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.listFolders(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.parent + * Required. The resource name of the organization or folder whose folders are + * being listed. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + * Access to this method is controlled by checking the + * `resourcemanager.folders.list` permission on the `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. + * If unspecified, server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListFolders` + * that indicates where this listing should continue from. + * @param {boolean} [request.showDeleted] + * Optional. Controls whether folders in the + * {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} + * state should be returned. Defaults to false. + * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder} 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 `listFoldersAsync()` + * 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. + */ + listFoldersStream( + request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listFolders']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listFolders.createStream( + this.innerApiCalls.listFolders as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listFolders`, 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.parent + * Required. The resource name of the organization or folder whose folders are + * being listed. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + * Access to this method is controlled by checking the + * `resourcemanager.folders.list` permission on the `parent`. + * @param {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. + * If unspecified, server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListFolders` + * that indicates where this listing should continue from. + * @param {boolean} [request.showDeleted] + * Optional. Controls whether folders in the + * {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} + * state should be returned. Defaults to false. + * @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 + * [Folder]{@link google.cloud.resourcemanager.v3.Folder}. 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/v3/folders.list_folders.js + * region_tag:cloudresourcemanager_v3_generated_Folders_ListFolders_async + */ + listFoldersAsync( + request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listFolders']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listFolders.asyncIterate( + this.innerApiCalls['listFolders'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Search for folders that match specific filter criteria. + * `search()` provides an eventually consistent view of the folders a user has + * access to which meet the specified filter criteria. + * + * This will only return folders on which the caller has the + * permission `resourcemanager.folders.get`. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. + * If unspecified, server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `SearchFolders` + * that indicates from where search should continue. + * @param {string} [request.query] + * Optional. Search criteria used to select the folders to return. + * If no search criteria is specified then all accessible folders will be + * returned. + * + * Query expressions can be used to restrict results based upon displayName, + * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + * can be used along with the suffix wildcard symbol `*`. + * + * The `displayName` field in a query expression should use escaped quotes + * for values that include whitespace to prevent unexpected behavior. + * + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------| + * | displayName | Filters by displayName. | + * | parent | Filters by parent (for example: folders/123). | + * | state, lifecycleState | Filters by state. | + * ``` + * + * Some example queries are: + * + * * Query `displayName=Test*` returns Folder resources whose display name + * starts with "Test". + * * Query `state=ACTIVE` returns Folder resources with + * `state` set to `ACTIVE`. + * * Query `parent=folders/123` returns Folder resources that have + * `folders/123` as a parent resource. + * * Query `parent=folders/123 AND state=ACTIVE` returns active + * Folder resources that have `folders/123` as a parent resource. + * * Query `displayName=\\"Test String\\"` returns Folder resources with + * display names that include both "Test" and "String". + * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder}. + * 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 `searchFoldersAsync()` + * 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. + */ + searchFolders( + request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder[], + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse + ]>; + searchFolders( + request: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): void; + searchFolders( + request: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): void; + searchFolders( + request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IFolder>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IFolder[], + protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.searchFolders(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 {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. + * If unspecified, server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `SearchFolders` + * that indicates from where search should continue. + * @param {string} [request.query] + * Optional. Search criteria used to select the folders to return. + * If no search criteria is specified then all accessible folders will be + * returned. + * + * Query expressions can be used to restrict results based upon displayName, + * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + * can be used along with the suffix wildcard symbol `*`. + * + * The `displayName` field in a query expression should use escaped quotes + * for values that include whitespace to prevent unexpected behavior. + * + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------| + * | displayName | Filters by displayName. | + * | parent | Filters by parent (for example: folders/123). | + * | state, lifecycleState | Filters by state. | + * ``` + * + * Some example queries are: + * + * * Query `displayName=Test*` returns Folder resources whose display name + * starts with "Test". + * * Query `state=ACTIVE` returns Folder resources with + * `state` set to `ACTIVE`. + * * Query `parent=folders/123` returns Folder resources that have + * `folders/123` as a parent resource. + * * Query `parent=folders/123 AND state=ACTIVE` returns active + * Folder resources that have `folders/123` as a parent resource. + * * Query `displayName=\\"Test String\\"` returns Folder resources with + * display names that include both "Test" and "String". + * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder} 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 `searchFoldersAsync()` + * 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. + */ + searchFoldersStream( + request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchFolders']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchFolders.createStream( + this.innerApiCalls.searchFolders as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchFolders`, 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 {number} [request.pageSize] + * Optional. The maximum number of folders to return in the response. + * If unspecified, server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `SearchFolders` + * that indicates from where search should continue. + * @param {string} [request.query] + * Optional. Search criteria used to select the folders to return. + * If no search criteria is specified then all accessible folders will be + * returned. + * + * Query expressions can be used to restrict results based upon displayName, + * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` + * can be used along with the suffix wildcard symbol `*`. + * + * The `displayName` field in a query expression should use escaped quotes + * for values that include whitespace to prevent unexpected behavior. + * + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------| + * | displayName | Filters by displayName. | + * | parent | Filters by parent (for example: folders/123). | + * | state, lifecycleState | Filters by state. | + * ``` + * + * Some example queries are: + * + * * Query `displayName=Test*` returns Folder resources whose display name + * starts with "Test". + * * Query `state=ACTIVE` returns Folder resources with + * `state` set to `ACTIVE`. + * * Query `parent=folders/123` returns Folder resources that have + * `folders/123` as a parent resource. + * * Query `parent=folders/123 AND state=ACTIVE` returns active + * Folder resources that have `folders/123` as a parent resource. + * * Query `displayName=\\"Test String\\"` returns Folder resources with + * display names that include both "Test" and "String". + * @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 + * [Folder]{@link google.cloud.resourcemanager.v3.Folder}. 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/v3/folders.search_folders.js + * region_tag:cloudresourcemanager_v3_generated_Folders_SearchFolders_async + */ + searchFoldersAsync( + request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchFolders']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchFolders.asyncIterate( + this.innerApiCalls['searchFolders'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.foldersStub && !this._terminated) { + return this.foldersStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v3/src/v3/folders_client_config.json b/owl-bot-staging/v3/src/v3/folders_client_config.json new file mode 100644 index 0000000..a2bed85 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/folders_client_config.json @@ -0,0 +1,83 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.Folders": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "GetFolder": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "ListFolders": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SearchFolders": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MoveFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UndeleteFolder": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v3/src/v3/folders_proto_list.json b/owl-bot-staging/v3/src/v3/folders_proto_list.json new file mode 100644 index 0000000..0c00660 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/folders_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/v3/src/v3/gapic_metadata.json b/owl-bot-staging/v3/src/v3/gapic_metadata.json new file mode 100644 index 0000000..066fbe7 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/gapic_metadata.json @@ -0,0 +1,585 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.resourcemanager.v3", + "libraryPackage": "@google-cloud/resource-manager", + "services": { + "Folders": { + "clients": { + "grpc": { + "libraryClient": "FoldersClient", + "rpcs": { + "GetFolder": { + "methods": [ + "getFolder" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateFolder": { + "methods": [ + "createFolder" + ] + }, + "UpdateFolder": { + "methods": [ + "updateFolder" + ] + }, + "MoveFolder": { + "methods": [ + "moveFolder" + ] + }, + "DeleteFolder": { + "methods": [ + "deleteFolder" + ] + }, + "UndeleteFolder": { + "methods": [ + "undeleteFolder" + ] + }, + "ListFolders": { + "methods": [ + "listFolders", + "listFoldersStream", + "listFoldersAsync" + ] + }, + "SearchFolders": { + "methods": [ + "searchFolders", + "searchFoldersStream", + "searchFoldersAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "FoldersClient", + "rpcs": { + "GetFolder": { + "methods": [ + "getFolder" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateFolder": { + "methods": [ + "createFolder" + ] + }, + "UpdateFolder": { + "methods": [ + "updateFolder" + ] + }, + "MoveFolder": { + "methods": [ + "moveFolder" + ] + }, + "DeleteFolder": { + "methods": [ + "deleteFolder" + ] + }, + "UndeleteFolder": { + "methods": [ + "undeleteFolder" + ] + }, + "ListFolders": { + "methods": [ + "listFolders", + "listFoldersStream", + "listFoldersAsync" + ] + }, + "SearchFolders": { + "methods": [ + "searchFolders", + "searchFoldersStream", + "searchFoldersAsync" + ] + } + } + } + } + }, + "Organizations": { + "clients": { + "grpc": { + "libraryClient": "OrganizationsClient", + "rpcs": { + "GetOrganization": { + "methods": [ + "getOrganization" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "SearchOrganizations": { + "methods": [ + "searchOrganizations", + "searchOrganizationsStream", + "searchOrganizationsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "OrganizationsClient", + "rpcs": { + "GetOrganization": { + "methods": [ + "getOrganization" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "SearchOrganizations": { + "methods": [ + "searchOrganizations", + "searchOrganizationsStream", + "searchOrganizationsAsync" + ] + } + } + } + } + }, + "Projects": { + "clients": { + "grpc": { + "libraryClient": "ProjectsClient", + "rpcs": { + "GetProject": { + "methods": [ + "getProject" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateProject": { + "methods": [ + "createProject" + ] + }, + "UpdateProject": { + "methods": [ + "updateProject" + ] + }, + "MoveProject": { + "methods": [ + "moveProject" + ] + }, + "DeleteProject": { + "methods": [ + "deleteProject" + ] + }, + "UndeleteProject": { + "methods": [ + "undeleteProject" + ] + }, + "ListProjects": { + "methods": [ + "listProjects", + "listProjectsStream", + "listProjectsAsync" + ] + }, + "SearchProjects": { + "methods": [ + "searchProjects", + "searchProjectsStream", + "searchProjectsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ProjectsClient", + "rpcs": { + "GetProject": { + "methods": [ + "getProject" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateProject": { + "methods": [ + "createProject" + ] + }, + "UpdateProject": { + "methods": [ + "updateProject" + ] + }, + "MoveProject": { + "methods": [ + "moveProject" + ] + }, + "DeleteProject": { + "methods": [ + "deleteProject" + ] + }, + "UndeleteProject": { + "methods": [ + "undeleteProject" + ] + }, + "ListProjects": { + "methods": [ + "listProjects", + "listProjectsStream", + "listProjectsAsync" + ] + }, + "SearchProjects": { + "methods": [ + "searchProjects", + "searchProjectsStream", + "searchProjectsAsync" + ] + } + } + } + } + }, + "TagBindings": { + "clients": { + "grpc": { + "libraryClient": "TagBindingsClient", + "rpcs": { + "CreateTagBinding": { + "methods": [ + "createTagBinding" + ] + }, + "DeleteTagBinding": { + "methods": [ + "deleteTagBinding" + ] + }, + "ListTagBindings": { + "methods": [ + "listTagBindings", + "listTagBindingsStream", + "listTagBindingsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TagBindingsClient", + "rpcs": { + "CreateTagBinding": { + "methods": [ + "createTagBinding" + ] + }, + "DeleteTagBinding": { + "methods": [ + "deleteTagBinding" + ] + }, + "ListTagBindings": { + "methods": [ + "listTagBindings", + "listTagBindingsStream", + "listTagBindingsAsync" + ] + } + } + } + } + }, + "TagKeys": { + "clients": { + "grpc": { + "libraryClient": "TagKeysClient", + "rpcs": { + "GetTagKey": { + "methods": [ + "getTagKey" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateTagKey": { + "methods": [ + "createTagKey" + ] + }, + "UpdateTagKey": { + "methods": [ + "updateTagKey" + ] + }, + "DeleteTagKey": { + "methods": [ + "deleteTagKey" + ] + }, + "ListTagKeys": { + "methods": [ + "listTagKeys", + "listTagKeysStream", + "listTagKeysAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TagKeysClient", + "rpcs": { + "GetTagKey": { + "methods": [ + "getTagKey" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateTagKey": { + "methods": [ + "createTagKey" + ] + }, + "UpdateTagKey": { + "methods": [ + "updateTagKey" + ] + }, + "DeleteTagKey": { + "methods": [ + "deleteTagKey" + ] + }, + "ListTagKeys": { + "methods": [ + "listTagKeys", + "listTagKeysStream", + "listTagKeysAsync" + ] + } + } + } + } + }, + "TagValues": { + "clients": { + "grpc": { + "libraryClient": "TagValuesClient", + "rpcs": { + "GetTagValue": { + "methods": [ + "getTagValue" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateTagValue": { + "methods": [ + "createTagValue" + ] + }, + "UpdateTagValue": { + "methods": [ + "updateTagValue" + ] + }, + "DeleteTagValue": { + "methods": [ + "deleteTagValue" + ] + }, + "ListTagValues": { + "methods": [ + "listTagValues", + "listTagValuesStream", + "listTagValuesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "TagValuesClient", + "rpcs": { + "GetTagValue": { + "methods": [ + "getTagValue" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "CreateTagValue": { + "methods": [ + "createTagValue" + ] + }, + "UpdateTagValue": { + "methods": [ + "updateTagValue" + ] + }, + "DeleteTagValue": { + "methods": [ + "deleteTagValue" + ] + }, + "ListTagValues": { + "methods": [ + "listTagValues", + "listTagValuesStream", + "listTagValuesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v3/src/v3/index.ts b/owl-bot-staging/v3/src/v3/index.ts new file mode 100644 index 0000000..dc937f5 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/index.ts @@ -0,0 +1,24 @@ +// 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 {FoldersClient} from './folders_client'; +export {OrganizationsClient} from './organizations_client'; +export {ProjectsClient} from './projects_client'; +export {TagBindingsClient} from './tag_bindings_client'; +export {TagKeysClient} from './tag_keys_client'; +export {TagValuesClient} from './tag_values_client'; diff --git a/owl-bot-staging/v3/src/v3/organizations_client.ts b/owl-bot-staging/v3/src/v3/organizations_client.ts new file mode 100644 index 0000000..af9b810 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/organizations_client.ts @@ -0,0 +1,1013 @@ +// 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, 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/v3/organizations_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './organizations_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Allows users to manage their organization resources. + * @class + * @memberof v3 + */ +export class OrganizationsClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + organizationsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of OrganizationsClient. + * + * @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 OrganizationsClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + searchOrganizations: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'organizations') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.Organizations', 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.organizationsStub) { + return this.organizationsStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.Organizations. + this.organizationsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Organizations') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.Organizations, + 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 organizationsStubMethods = + ['getOrganization', 'searchOrganizations', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of organizationsStubMethods) { + const callPromise = this.organizationsStub.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] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.organizationsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Fetches an organization resource identified by the specified resource name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the Organization to fetch. This is the organization's + * relative path in the API, formatted as "organizations/[organizationId]". + * For example, "organizations/1234". + * @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 [Organization]{@link google.cloud.resourcemanager.v3.Organization}. + * 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/v3/organizations.get_organization.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_GetOrganization_async + */ + getOrganization( + request?: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|undefined, {}|undefined + ]>; + getOrganization( + request: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, + {}|null|undefined>): void; + getOrganization( + request: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, + {}|null|undefined>): void; + getOrganization( + request?: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IOrganization, + protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getOrganization(request, options, callback); + } +/** + * Gets the access control policy for an organization resource. The policy may + * be empty if no such policy or resource exists. The `resource` field should + * be the organization's resource name, for example: "organizations/123". + * + * Authorization requires the IAM permission + * `resourcemanager.organizations.getIamPolicy` on the specified organization. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/organizations.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the access control policy on an organization resource. Replaces any + * existing policy. The `resource` field should be the organization's resource + * name, for example: "organizations/123". + * + * Authorization requires the IAM permission + * `resourcemanager.organizations.setIamPolicy` on the specified organization. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/organizations.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns the permissions that a caller has on the specified organization. + * The `resource` field should be the organization's resource name, + * for example: "organizations/123". + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * 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/v3/organizations.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + + /** + * Searches organization resources that are visible to the user and satisfy + * the specified filter. This method returns organizations in an unspecified + * order. New organizations do not necessarily appear at the end of the + * results, and may take a small amount of time to appear. + * + * Search will only return organizations on which the user has the permission + * `resourcemanager.organizations.get` + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of organizations to return in the response. + * If unspecified, server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `SearchOrganizations` + * that indicates from where listing should continue. + * @param {string} [request.query] + * Optional. An optional query string used to filter the Organizations to return in + * the response. Query rules are case-insensitive. + * + * ``` + * | Field | Description | + * |------------------|--------------------------------------------| + * | directoryCustomerId, owner.directoryCustomerId | Filters by directory + * customer id. | + * | domain | Filters by domain. | + * ``` + * + * Organizations may be queried by `directoryCustomerId` or by + * `domain`, where the domain is a G Suite domain, for example: + * + * * Query `directorycustomerid:123456789` returns Organization + * resources with `owner.directory_customer_id` equal to `123456789`. + * * Query `domain:google.com` returns Organization resources corresponding + * to the domain `google.com`. + * @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 [Organization]{@link google.cloud.resourcemanager.v3.Organization}. + * 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 `searchOrganizationsAsync()` + * 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. + */ + searchOrganizations( + request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IOrganization[], + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse + ]>; + searchOrganizations( + request: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IOrganization>): void; + searchOrganizations( + request: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IOrganization>): void; + searchOrganizations( + request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IOrganization>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IOrganization>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IOrganization[], + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.searchOrganizations(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 {number} [request.pageSize] + * Optional. The maximum number of organizations to return in the response. + * If unspecified, server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `SearchOrganizations` + * that indicates from where listing should continue. + * @param {string} [request.query] + * Optional. An optional query string used to filter the Organizations to return in + * the response. Query rules are case-insensitive. + * + * ``` + * | Field | Description | + * |------------------|--------------------------------------------| + * | directoryCustomerId, owner.directoryCustomerId | Filters by directory + * customer id. | + * | domain | Filters by domain. | + * ``` + * + * Organizations may be queried by `directoryCustomerId` or by + * `domain`, where the domain is a G Suite domain, for example: + * + * * Query `directorycustomerid:123456789` returns Organization + * resources with `owner.directory_customer_id` equal to `123456789`. + * * Query `domain:google.com` returns Organization resources corresponding + * to the domain `google.com`. + * @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 [Organization]{@link google.cloud.resourcemanager.v3.Organization} 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 `searchOrganizationsAsync()` + * 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. + */ + searchOrganizationsStream( + request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchOrganizations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchOrganizations.createStream( + this.innerApiCalls.searchOrganizations as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchOrganizations`, 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 {number} [request.pageSize] + * Optional. The maximum number of organizations to return in the response. + * If unspecified, server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `SearchOrganizations` + * that indicates from where listing should continue. + * @param {string} [request.query] + * Optional. An optional query string used to filter the Organizations to return in + * the response. Query rules are case-insensitive. + * + * ``` + * | Field | Description | + * |------------------|--------------------------------------------| + * | directoryCustomerId, owner.directoryCustomerId | Filters by directory + * customer id. | + * | domain | Filters by domain. | + * ``` + * + * Organizations may be queried by `directoryCustomerId` or by + * `domain`, where the domain is a G Suite domain, for example: + * + * * Query `directorycustomerid:123456789` returns Organization + * resources with `owner.directory_customer_id` equal to `123456789`. + * * Query `domain:google.com` returns Organization resources corresponding + * to the domain `google.com`. + * @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 + * [Organization]{@link google.cloud.resourcemanager.v3.Organization}. 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/v3/organizations.search_organizations.js + * region_tag:cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async + */ + searchOrganizationsAsync( + request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchOrganizations']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchOrganizations.asyncIterate( + this.innerApiCalls['searchOrganizations'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.organizationsStub && !this._terminated) { + return this.organizationsStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v3/src/v3/organizations_client_config.json b/owl-bot-staging/v3/src/v3/organizations_client_config.json new file mode 100644 index 0000000..ca62d91 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/organizations_client_config.json @@ -0,0 +1,53 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.Organizations": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "GetOrganization": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SearchOrganizations": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v3/src/v3/organizations_proto_list.json b/owl-bot-staging/v3/src/v3/organizations_proto_list.json new file mode 100644 index 0000000..0c00660 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/organizations_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/v3/src/v3/projects_client.ts b/owl-bot-staging/v3/src/v3/projects_client.ts new file mode 100644 index 0000000..4dcb4cd --- /dev/null +++ b/owl-bot-staging/v3/src/v3/projects_client.ts @@ -0,0 +1,1896 @@ +// 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/v3/projects_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './projects_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Manages Google Cloud Projects. + * @class + * @memberof v3 + */ +export class ProjectsClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + projectsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ProjectsClient. + * + * @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 ProjectsClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listProjects: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projects'), + searchProjects: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projects') + }; + + 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.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const createProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateProjectMetadata') as gax.protobuf.Type; + const updateProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const updateProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UpdateProjectMetadata') as gax.protobuf.Type; + const moveProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const moveProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.MoveProjectMetadata') as gax.protobuf.Type; + const deleteProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const deleteProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteProjectMetadata') as gax.protobuf.Type; + const undeleteProjectResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; + const undeleteProjectMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UndeleteProjectMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createProjectResponse.decode.bind(createProjectResponse), + createProjectMetadata.decode.bind(createProjectMetadata)), + updateProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateProjectResponse.decode.bind(updateProjectResponse), + updateProjectMetadata.decode.bind(updateProjectMetadata)), + moveProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + moveProjectResponse.decode.bind(moveProjectResponse), + moveProjectMetadata.decode.bind(moveProjectMetadata)), + deleteProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteProjectResponse.decode.bind(deleteProjectResponse), + deleteProjectMetadata.decode.bind(deleteProjectMetadata)), + undeleteProject: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + undeleteProjectResponse.decode.bind(undeleteProjectResponse), + undeleteProjectMetadata.decode.bind(undeleteProjectMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.Projects', 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.projectsStub) { + return this.projectsStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.Projects. + this.projectsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Projects') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.Projects, + 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 projectsStubMethods = + ['getProject', 'listProjects', 'searchProjects', 'createProject', 'updateProject', 'moveProject', 'deleteProject', 'undeleteProject', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of projectsStubMethods) { + const callPromise = this.projectsStub.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.projectsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Retrieves the project identified by the specified `name` (for example, + * `projects/415104041262`). + * + * The caller must have `resourcemanager.projects.get` permission + * for this project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the project (for example, `projects/415104041262`). + * @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 [Project]{@link google.cloud.resourcemanager.v3.Project}. + * 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/v3/projects.get_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_GetProject_async + */ + getProject( + request?: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|undefined, {}|undefined + ]>; + getProject( + request: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, + {}|null|undefined>): void; + getProject( + request: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, + {}|null|undefined>): void; + getProject( + request?: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject, + protos.google.cloud.resourcemanager.v3.IGetProjectRequest|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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getProject(request, options, callback); + } +/** + * Returns the IAM access control policy for the specified project. + * Permission is denied if the policy or the resource do not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/projects.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the IAM access control policy for the specified project. + * + * CAUTION: This method will replace the existing policy, and cannot be used + * to append additional IAM settings. + * + * Note: Removing service accounts from policies or changing their roles can + * render services completely inoperable. It is important to understand how + * the service account is being used before removing or updating its roles. + * + * The following constraints apply when using `setIamPolicy()`: + * + * + Project does not support `allUsers` and `allAuthenticatedUsers` as + * `members` in a `Binding` of a `Policy`. + * + * + The owner role can be granted to a `user`, `serviceAccount`, or a group + * that is part of an organization. For example, + * group@myownpersonaldomain.com could be added as an owner to a project in + * the myownpersonaldomain.com organization, but not the examplepetstore.com + * organization. + * + * + Service accounts can be made owners of a project directly + * without any restrictions. However, to be added as an owner, a user must be + * invited using the Cloud Platform console and must accept the invitation. + * + * + A user cannot be granted the owner role using `setIamPolicy()`. The user + * must be granted the owner role using the Cloud Platform Console and must + * explicitly accept the invitation. + * + * + Invitations to grant the owner role cannot be sent using + * `setIamPolicy()`; + * they must be sent only using the Cloud Platform Console. + * + * + Membership changes that leave the project without any owners that have + * accepted the Terms of Service (ToS) will be rejected. + * + * + If the project is not part of an organization, there must be at least + * one owner who has accepted the Terms of Service (ToS) agreement in the + * policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner + * from the policy will fail. This restriction also applies to legacy + * projects that no longer have owners who have accepted the ToS. Edits to + * IAM policies will be rejected until the lack of a ToS-accepting owner is + * rectified. + * + * + Calling this method requires enabling the App Engine Admin API. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/projects.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * 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/v3/projects.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Request that a new project be created. The result is an `Operation` which + * can be used to track the creation process. This process usually takes a few + * seconds, but can sometimes take much longer. The tracking `Operation` is + * automatically deleted after a few hours, so there is no need to call + * `DeleteOperation`. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.Project} request.project + * Required. The Project to create. + * + * Project ID is required. If the requested ID is unavailable, the request + * fails. + * + * If the `parent` field is set, the `resourcemanager.projects.create` + * permission is checked on the parent resource. If no parent is set and + * the authorization credentials belong to an Organziation, the parent + * will be set to that Organization. + * @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/v3/projects.create_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_CreateProject_async + */ + createProject( + request?: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createProject( + request: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createProject( + request: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createProject( + request?: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.createProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createProject()`. + * @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/v3/projects.create_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_CreateProject_async + */ + async checkCreateProjectProgress(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.createProject, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the `display_name` and labels of the project identified by the + * specified `name` (for example, `projects/415104041262`). Deleting all + * labels requires an update mask for labels field. + * + * The caller must have `resourcemanager.projects.update` permission for this + * project. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.Project} request.project + * Required. The new definition of the project. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. An update mask to selectively update fields. + * @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/v3/projects.update_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_UpdateProject_async + */ + updateProject( + request?: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateProject( + request: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateProject( + request: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateProject( + request?: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, + 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.name': request.project!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateProject()`. + * @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/v3/projects.update_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_UpdateProject_async + */ + async checkUpdateProjectProgress(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.updateProject, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Move a project to another place in your resource hierarchy, under a new + * resource parent. + * + * Returns an operation which can be used to track the process of the project + * move workflow. + * Upon success, the `Operation.response` field will be populated with the + * moved project. + * + * The caller must have `resourcemanager.projects.update` permission on the + * project and have `resourcemanager.projects.move` permission on the + * project's current and proposed new parent. + * + * + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the project to move. + * @param {string} request.destinationParent + * Required. The new parent to move the Project under. + * @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/v3/projects.move_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_MoveProject_async + */ + moveProject( + request?: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + moveProject( + request: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + moveProject( + request: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + moveProject( + request?: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, + 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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.moveProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `moveProject()`. + * @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/v3/projects.move_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_MoveProject_async + */ + async checkMoveProjectProgress(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.moveProject, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Marks the project identified by the specified + * `name` (for example, `projects/415104041262`) for deletion. + * + * This method will only affect the project if it has a lifecycle state of + * {@link google.cloud.resourcemanager.v3.Project.State.ACTIVE|ACTIVE}. + * + * This method changes the Project's lifecycle state from + * {@link google.cloud.resourcemanager.v3.Project.State.ACTIVE|ACTIVE} + * to {@link google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED|DELETE_REQUESTED}. + * The deletion starts at an unspecified time, + * at which point the Project is no longer accessible. + * + * Until the deletion completes, you can check the lifecycle state + * checked by retrieving the project with [GetProject] + * [google.cloud.resourcemanager.v3.Projects.GetProject], + * and the project remains visible to [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects]. + * However, you cannot update the project. + * + * After the deletion completes, the project is not retrievable by + * the [GetProject] + * [google.cloud.resourcemanager.v3.Projects.GetProject], + * [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects], and + * {@link google.cloud.resourcemanager.v3.Projects.SearchProjects|SearchProjects} + * methods. + * + * This method behaves idempotently, such that deleting a `DELETE_REQUESTED` + * project will not cause an error, but also won't do anything. + * + * The caller must have `resourcemanager.projects.delete` permissions for this + * project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Project (for example, `projects/415104041262`). + * @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/v3/projects.delete_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_DeleteProject_async + */ + deleteProject( + request?: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteProject( + request: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProject( + request: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteProject( + request?: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, + 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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteProject()`. + * @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/v3/projects.delete_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_DeleteProject_async + */ + async checkDeleteProjectProgress(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.deleteProject, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Restores the project identified by the specified + * `name` (for example, `projects/415104041262`). + * You can only use this method for a project that has a lifecycle state of + * [DELETE_REQUESTED] + * [Projects.State.DELETE_REQUESTED]. + * After deletion starts, the project cannot be restored. + * + * The caller must have `resourcemanager.projects.undelete` permission for + * this project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the project (for example, `projects/415104041262`). + * + * Required. + * @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/v3/projects.undelete_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_UndeleteProject_async + */ + undeleteProject( + request?: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + undeleteProject( + request: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeleteProject( + request: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + undeleteProject( + request?: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, + 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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.undeleteProject(request, options, callback); + } +/** + * Check the status of the long running operation returned by `undeleteProject()`. + * @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/v3/projects.undelete_project.js + * region_tag:cloudresourcemanager_v3_generated_Projects_UndeleteProject_async + */ + async checkUndeleteProjectProgress(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.undeleteProject, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists projects that are direct children of the specified folder or + * organization resource. `list()` provides a strongly consistent view of the + * projects underneath the specified parent resource. `list()` returns + * projects sorted based upon the (ascending) lexical ordering of their + * `display_name`. The caller must have `resourcemanager.projects.list` + * permission on the identified parent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent resource to list projects under. + * + * For example, setting this field to 'folders/1234' would list all projects + * directly under that folder. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects] + * that indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @param {boolean} [request.showDeleted] + * Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be + * returned. Normally only `ACTIVE` projects are returned. + * @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 [Project]{@link google.cloud.resourcemanager.v3.Project}. + * 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 `listProjectsAsync()` + * 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. + */ + listProjects( + request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject[], + protos.google.cloud.resourcemanager.v3.IListProjectsRequest|null, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse + ]>; + listProjects( + request: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): void; + listProjects( + request: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): void; + listProjects( + request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject[], + protos.google.cloud.resourcemanager.v3.IListProjectsRequest|null, + protos.google.cloud.resourcemanager.v3.IListProjectsResponse + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.listProjects(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.parent + * Required. The name of the parent resource to list projects under. + * + * For example, setting this field to 'folders/1234' would list all projects + * directly under that folder. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects] + * that indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @param {boolean} [request.showDeleted] + * Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be + * returned. Normally only `ACTIVE` projects are returned. + * @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 [Project]{@link google.cloud.resourcemanager.v3.Project} 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 `listProjectsAsync()` + * 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. + */ + listProjectsStream( + request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listProjects']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProjects.createStream( + this.innerApiCalls.listProjects as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProjects`, 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.parent + * Required. The name of the parent resource to list projects under. + * + * For example, setting this field to 'folders/1234' would list all projects + * directly under that folder. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects] + * that indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @param {boolean} [request.showDeleted] + * Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be + * returned. Normally only `ACTIVE` projects are returned. + * @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 + * [Project]{@link google.cloud.resourcemanager.v3.Project}. 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/v3/projects.list_projects.js + * region_tag:cloudresourcemanager_v3_generated_Projects_ListProjects_async + */ + listProjectsAsync( + request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listProjects']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProjects.asyncIterate( + this.innerApiCalls['listProjects'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * Search for projects that the caller has both `resourcemanager.projects.get` + * permission on, and also satisfy the specified query. + * + * This method returns projects in an unspecified order. + * + * This method is eventually consistent with project mutations; this means + * that a newly created project may not appear in the results or recent + * updates to an existing project may not be reflected in the results. To + * retrieve the latest state of a project, use the + * {@link google.cloud.resourcemanager.v3.Projects.GetProject|GetProject} method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.query] + * Optional. A query string for searching for projects that the caller has + * `resourcemanager.projects.get` permission to. If multiple fields are + * included in the query, the it will return results that match any of the + * fields. Some eligible fields are: + * + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------------| + * | displayName, name | Filters by displayName. | + * | parent | Project's parent. (for example: folders/123, + * organizations/*) Prefer parent field over parent.type and parent.id. | + * | parent.type | Parent's type: `folder` or `organization`. | + * | parent.id | Parent's id number (for example: 123) | + * | id, projectId | Filters by projectId. | + * | state, lifecycleState | Filters by state. | + * | labels | Filters by label name or value. | + * | labels. (where *key* is the name of a label) | Filters by label + * name. | + * ``` + * + * Search expressions are case insensitive. + * + * Some examples queries: + * + * ``` + * | Query | Description | + * |------------------|-----------------------------------------------------| + * | name:how* | The project's name starts with "how". | + * | name:Howl | The project's name is `Howl` or `howl`. | + * | name:HOWL | Equivalent to above. | + * | NAME:howl | Equivalent to above. | + * | labels.color:* | The project has the label `color`. | + * | labels.color:red | The project's label `color` has the value `red`. | + * | labels.color:red labels.size:big | The project's label `color` has + * the value `red` and its label `size` has the value `big`. | + * ``` + * + * If no query is specified, the call will return projects for which the user + * has the `resourcemanager.projects.get` permission. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects] + * that indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @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 [Project]{@link google.cloud.resourcemanager.v3.Project}. + * 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 `searchProjectsAsync()` + * 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. + */ + searchProjects( + request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject[], + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse + ]>; + searchProjects( + request: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): void; + searchProjects( + request: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): void; + searchProjects( + request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.IProject>): + Promise<[ + protos.google.cloud.resourcemanager.v3.IProject[], + protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest|null, + protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.searchProjects(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.query] + * Optional. A query string for searching for projects that the caller has + * `resourcemanager.projects.get` permission to. If multiple fields are + * included in the query, the it will return results that match any of the + * fields. Some eligible fields are: + * + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------------| + * | displayName, name | Filters by displayName. | + * | parent | Project's parent. (for example: folders/123, + * organizations/*) Prefer parent field over parent.type and parent.id. | + * | parent.type | Parent's type: `folder` or `organization`. | + * | parent.id | Parent's id number (for example: 123) | + * | id, projectId | Filters by projectId. | + * | state, lifecycleState | Filters by state. | + * | labels | Filters by label name or value. | + * | labels. (where *key* is the name of a label) | Filters by label + * name. | + * ``` + * + * Search expressions are case insensitive. + * + * Some examples queries: + * + * ``` + * | Query | Description | + * |------------------|-----------------------------------------------------| + * | name:how* | The project's name starts with "how". | + * | name:Howl | The project's name is `Howl` or `howl`. | + * | name:HOWL | Equivalent to above. | + * | NAME:howl | Equivalent to above. | + * | labels.color:* | The project has the label `color`. | + * | labels.color:red | The project's label `color` has the value `red`. | + * | labels.color:red labels.size:big | The project's label `color` has + * the value `red` and its label `size` has the value `big`. | + * ``` + * + * If no query is specified, the call will return projects for which the user + * has the `resourcemanager.projects.get` permission. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects] + * that indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @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 [Project]{@link google.cloud.resourcemanager.v3.Project} 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 `searchProjectsAsync()` + * 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. + */ + searchProjectsStream( + request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchProjects']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchProjects.createStream( + this.innerApiCalls.searchProjects as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `searchProjects`, 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.query] + * Optional. A query string for searching for projects that the caller has + * `resourcemanager.projects.get` permission to. If multiple fields are + * included in the query, the it will return results that match any of the + * fields. Some eligible fields are: + * + * ``` + * | Field | Description | + * |-------------------------|----------------------------------------------| + * | displayName, name | Filters by displayName. | + * | parent | Project's parent. (for example: folders/123, + * organizations/*) Prefer parent field over parent.type and parent.id. | + * | parent.type | Parent's type: `folder` or `organization`. | + * | parent.id | Parent's id number (for example: 123) | + * | id, projectId | Filters by projectId. | + * | state, lifecycleState | Filters by state. | + * | labels | Filters by label name or value. | + * | labels. (where *key* is the name of a label) | Filters by label + * name. | + * ``` + * + * Search expressions are case insensitive. + * + * Some examples queries: + * + * ``` + * | Query | Description | + * |------------------|-----------------------------------------------------| + * | name:how* | The project's name starts with "how". | + * | name:Howl | The project's name is `Howl` or `howl`. | + * | name:HOWL | Equivalent to above. | + * | NAME:howl | Equivalent to above. | + * | labels.color:* | The project has the label `color`. | + * | labels.color:red | The project's label `color` has the value `red`. | + * | labels.color:red labels.size:big | The project's label `color` has + * the value `red` and its label `size` has the value `big`. | + * ``` + * + * If no query is specified, the call will return projects for which the user + * has the `resourcemanager.projects.get` permission. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to [ListProjects] + * [google.cloud.resourcemanager.v3.Projects.ListProjects] + * that indicates from where listing should continue. + * @param {number} [request.pageSize] + * Optional. The maximum number of projects to return in the response. + * The server can return fewer projects than requested. + * If unspecified, server picks an appropriate default. + * @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 + * [Project]{@link google.cloud.resourcemanager.v3.Project}. 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/v3/projects.search_projects.js + * region_tag:cloudresourcemanager_v3_generated_Projects_SearchProjects_async + */ + searchProjectsAsync( + request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['searchProjects']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.searchProjects.asyncIterate( + this.innerApiCalls['searchProjects'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.projectsStub && !this._terminated) { + return this.projectsStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v3/src/v3/projects_client_config.json b/owl-bot-staging/v3/src/v3/projects_client_config.json new file mode 100644 index 0000000..f1308d4 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/projects_client_config.json @@ -0,0 +1,83 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.Projects": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "GetProject": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "ListProjects": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SearchProjects": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "MoveProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UndeleteProject": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v3/src/v3/projects_proto_list.json b/owl-bot-staging/v3/src/v3/projects_proto_list.json new file mode 100644 index 0000000..0c00660 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/projects_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/v3/src/v3/tag_bindings_client.ts b/owl-bot-staging/v3/src/v3/tag_bindings_client.ts new file mode 100644 index 0000000..19e49e2 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/tag_bindings_client.ts @@ -0,0 +1,867 @@ +// 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/v3/tag_bindings_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tag_bindings_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Allow users to create and manage TagBindings between TagValues and + * different cloud resources throughout the GCP resource hierarchy. + * @class + * @memberof v3 + */ +export class TagBindingsClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + tagBindingsStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TagBindingsClient. + * + * @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 TagBindingsClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listTagBindings: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagBindings') + }; + + 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.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createTagBindingResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagBinding') as gax.protobuf.Type; + const createTagBindingMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateTagBindingMetadata') as gax.protobuf.Type; + const deleteTagBindingResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty') as gax.protobuf.Type; + const deleteTagBindingMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteTagBindingMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createTagBinding: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createTagBindingResponse.decode.bind(createTagBindingResponse), + createTagBindingMetadata.decode.bind(createTagBindingMetadata)), + deleteTagBinding: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteTagBindingResponse.decode.bind(deleteTagBindingResponse), + deleteTagBindingMetadata.decode.bind(deleteTagBindingMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.TagBindings', 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.tagBindingsStub) { + return this.tagBindingsStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.TagBindings. + this.tagBindingsStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagBindings') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.TagBindings, + 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 tagBindingsStubMethods = + ['listTagBindings', 'createTagBinding', 'deleteTagBinding']; + for (const methodName of tagBindingsStubMethods) { + const callPromise = this.tagBindingsStub.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.tagBindingsStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- + +/** + * Creates a TagBinding between a TagValue and a cloud resource + * (currently project, folder, or organization). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagBinding} request.tagBinding + * Required. The TagBinding to be created. + * @param {boolean} [request.validateOnly] + * Optional. Set to true to perform the validations necessary for creating the resource, + * but not actually perform the action. + * @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/v3/tag_bindings.create_tag_binding.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async + */ + createTagBinding( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createTagBinding( + request: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagBinding( + request: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagBinding( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.createTagBinding(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createTagBinding()`. + * @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/v3/tag_bindings.create_tag_binding.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async + */ + async checkCreateTagBindingProgress(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.createTagBinding, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a TagBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the TagBinding. This is a String of the form: + * `tagBindings/{id}` (e.g. + * `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). + * @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/v3/tag_bindings.delete_tag_binding.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async + */ + deleteTagBinding( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteTagBinding( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagBinding( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagBinding( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, + 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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteTagBinding(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteTagBinding()`. + * @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/v3/tag_bindings.delete_tag_binding.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async + */ + async checkDeleteTagBindingProgress(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.deleteTagBinding, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists the TagBindings for the given cloud resource, as specified with + * `parent`. + * + * NOTE: The `parent` field is expected to be a full resource name: + * https://cloud.google.com/apis/design/resource_names#full_resource_name + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The full resource name of a resource for which you want to list existing + * TagBindings. + * E.g. "//cloudresourcemanager.googleapis.com/projects/123" + * @param {number} [request.pageSize] + * Optional. The maximum number of TagBindings to return in the response. The server + * allows a maximum of 300 TagBindings to return. If unspecified, the server + * will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagBindings` + * that indicates where this listing should continue from. + * @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 [TagBinding]{@link google.cloud.resourcemanager.v3.TagBinding}. + * 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 `listTagBindingsAsync()` + * 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. + */ + listTagBindings( + request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagBinding[], + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse + ]>; + listTagBindings( + request: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagBinding>): void; + listTagBindings( + request: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagBinding>): void; + listTagBindings( + request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagBinding>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagBinding>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagBinding[], + protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.listTagBindings(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.parent + * Required. The full resource name of a resource for which you want to list existing + * TagBindings. + * E.g. "//cloudresourcemanager.googleapis.com/projects/123" + * @param {number} [request.pageSize] + * Optional. The maximum number of TagBindings to return in the response. The server + * allows a maximum of 300 TagBindings to return. If unspecified, the server + * will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagBindings` + * that indicates where this listing should continue from. + * @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 [TagBinding]{@link google.cloud.resourcemanager.v3.TagBinding} 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 `listTagBindingsAsync()` + * 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. + */ + listTagBindingsStream( + request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagBindings']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagBindings.createStream( + this.innerApiCalls.listTagBindings as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTagBindings`, 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.parent + * Required. The full resource name of a resource for which you want to list existing + * TagBindings. + * E.g. "//cloudresourcemanager.googleapis.com/projects/123" + * @param {number} [request.pageSize] + * Optional. The maximum number of TagBindings to return in the response. The server + * allows a maximum of 300 TagBindings to return. If unspecified, the server + * will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagBindings` + * that indicates where this listing should continue from. + * @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 + * [TagBinding]{@link google.cloud.resourcemanager.v3.TagBinding}. 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/v3/tag_bindings.list_tag_bindings.js + * region_tag:cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async + */ + listTagBindingsAsync( + request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagBindings']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagBindings.asyncIterate( + this.innerApiCalls['listTagBindings'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.tagBindingsStub && !this._terminated) { + return this.tagBindingsStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v3/src/v3/tag_bindings_client_config.json b/owl-bot-staging/v3/src/v3/tag_bindings_client_config.json new file mode 100644 index 0000000..25129f4 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/tag_bindings_client_config.json @@ -0,0 +1,44 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.TagBindings": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "ListTagBindings": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "CreateTagBinding": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteTagBinding": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v3/src/v3/tag_bindings_proto_list.json b/owl-bot-staging/v3/src/v3/tag_bindings_proto_list.json new file mode 100644 index 0000000..0c00660 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/tag_bindings_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/v3/src/v3/tag_keys_client.ts b/owl-bot-staging/v3/src/v3/tag_keys_client.ts new file mode 100644 index 0000000..586c1de --- /dev/null +++ b/owl-bot-staging/v3/src/v3/tag_keys_client.ts @@ -0,0 +1,1299 @@ +// 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/v3/tag_keys_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tag_keys_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Allow users to create and manage tag keys. + * @class + * @memberof v3 + */ +export class TagKeysClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + tagKeysStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TagKeysClient. + * + * @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 TagKeysClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listTagKeys: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagKeys') + }; + + 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.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createTagKeyResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; + const createTagKeyMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateTagKeyMetadata') as gax.protobuf.Type; + const updateTagKeyResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; + const updateTagKeyMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UpdateTagKeyMetadata') as gax.protobuf.Type; + const deleteTagKeyResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; + const deleteTagKeyMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteTagKeyMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createTagKey: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createTagKeyResponse.decode.bind(createTagKeyResponse), + createTagKeyMetadata.decode.bind(createTagKeyMetadata)), + updateTagKey: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateTagKeyResponse.decode.bind(updateTagKeyResponse), + updateTagKeyMetadata.decode.bind(updateTagKeyMetadata)), + deleteTagKey: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteTagKeyResponse.decode.bind(deleteTagKeyResponse), + deleteTagKeyMetadata.decode.bind(deleteTagKeyMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.TagKeys', 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.tagKeysStub) { + return this.tagKeysStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.TagKeys. + this.tagKeysStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagKeys') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.TagKeys, + 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 tagKeysStubMethods = + ['listTagKeys', 'getTagKey', 'createTagKey', 'updateTagKey', 'deleteTagKey', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of tagKeysStubMethods) { + const callPromise = this.tagKeysStub.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.tagKeysStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the + * key does not exist or the user does not have permission to view it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A resource name in the format `tagKeys/{id}`, such as + * `tagKeys/123`. + * @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 [TagKey]{@link google.cloud.resourcemanager.v3.TagKey}. + * 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/v3/tag_keys.get_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async + */ + getTagKey( + request?: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|undefined, {}|undefined + ]>; + getTagKey( + request: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, + {}|null|undefined>): void; + getTagKey( + request: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, + {}|null|undefined>): void; + getTagKey( + request?: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey, + protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getTagKey(request, options, callback); + } +/** + * Gets the access control policy for a TagKey. The returned policy may be + * empty if no such policy or resource exists. The `resource` field should + * be the TagKey's resource name. For example, "tagKeys/1234". + * The caller must have + * `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on + * the specified TagKey. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/tag_keys.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the access control policy on a TagKey, replacing any existing + * policy. The `resource` field should be the TagKey's resource name. + * For example, "tagKeys/1234". + * The caller must have `resourcemanager.tagKeys.setIamPolicy` permission + * on the identified tagValue. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/tag_keys.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified TagKey. + * The `resource` field should be the TagKey's resource name. + * For example, "tagKeys/1234". + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * 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/v3/tag_keys.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a new TagKey. If another request with the same parameters is + * sent while the original request is in process, the second request + * will receive an error. A maximum of 300 TagKeys can exist under a parent at + * any given time. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagKey} request.tagKey + * Required. The TagKey to be created. Only fields `short_name`, `description`, + * and `parent` are considered during the creation request. + * @param {boolean} [request.validateOnly] + * Optional. Set to true to perform validations necessary for creating the resource, but + * not actually perform the action. + * @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/v3/tag_keys.create_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async + */ + createTagKey( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createTagKey( + request: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagKey( + request: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagKey( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.createTagKey(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createTagKey()`. + * @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/v3/tag_keys.create_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async + */ + async checkCreateTagKeyProgress(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.createTagKey, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the attributes of the TagKey resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagKey} request.tagKey + * Required. The new definition of the TagKey. Only the `description` and `etag` fields + * can be updated by this request. If the `etag` field is not empty, it + * must match the `etag` field of the existing tag key. Otherwise, + * `FAILED_PRECONDITION` will be returned. + * @param {google.protobuf.FieldMask} request.updateMask + * Fields to be updated. The mask may only contain `description` or + * `etag`. If omitted entirely, both `description` and `etag` are assumed to + * be significant. + * @param {boolean} request.validateOnly + * Set as true to perform validations necessary for updating the resource, but + * not actually perform the action. + * @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/v3/tag_keys.update_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async + */ + updateTagKey( + request?: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateTagKey( + request: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateTagKey( + request: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateTagKey( + request?: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, + 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({ + 'tag_key.name': request.tagKey!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateTagKey(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateTagKey()`. + * @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/v3/tag_keys.update_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async + */ + async checkUpdateTagKeyProgress(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.updateTagKey, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a TagKey. The TagKey cannot be deleted if it has any child + * TagValues. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of a TagKey to be deleted in the format `tagKeys/123`. + * The TagKey cannot be a parent of any existing TagValues or it will not be + * deleted successfully. + * @param {boolean} [request.validateOnly] + * Optional. Set as true to perform validations necessary for deletion, but not actually + * perform the action. + * @param {string} [request.etag] + * Optional. The etag known to the client for the expected state of the TagKey. This is + * to be used for optimistic concurrency. + * @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/v3/tag_keys.delete_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async + */ + deleteTagKey( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteTagKey( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagKey( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagKey( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, + 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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteTagKey(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteTagKey()`. + * @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/v3/tag_keys.delete_tag_key.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async + */ + async checkDeleteTagKeyProgress(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.deleteTagKey, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists all TagKeys for a parent resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the new TagKey's parent. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagKeys to return in the response. The server allows + * a maximum of 300 TagKeys to return. If unspecified, the server will use 100 + * as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagKey` + * that indicates where this listing should continue from. + * @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 [TagKey]{@link google.cloud.resourcemanager.v3.TagKey}. + * 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 `listTagKeysAsync()` + * 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. + */ + listTagKeys( + request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey[], + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse + ]>; + listTagKeys( + request: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagKey>): void; + listTagKeys( + request: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagKey>): void; + listTagKeys( + request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagKey>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagKey>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagKey[], + protos.google.cloud.resourcemanager.v3.IListTagKeysRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagKeysResponse + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.listTagKeys(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.parent + * Required. The resource name of the new TagKey's parent. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagKeys to return in the response. The server allows + * a maximum of 300 TagKeys to return. If unspecified, the server will use 100 + * as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagKey` + * that indicates where this listing should continue from. + * @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 [TagKey]{@link google.cloud.resourcemanager.v3.TagKey} 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 `listTagKeysAsync()` + * 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. + */ + listTagKeysStream( + request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagKeys']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagKeys.createStream( + this.innerApiCalls.listTagKeys as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTagKeys`, 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.parent + * Required. The resource name of the new TagKey's parent. + * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagKeys to return in the response. The server allows + * a maximum of 300 TagKeys to return. If unspecified, the server will use 100 + * as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagKey` + * that indicates where this listing should continue from. + * @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 + * [TagKey]{@link google.cloud.resourcemanager.v3.TagKey}. 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/v3/tag_keys.list_tag_keys.js + * region_tag:cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async + */ + listTagKeysAsync( + request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagKeys']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagKeys.asyncIterate( + this.innerApiCalls['listTagKeys'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.tagKeysStub && !this._terminated) { + return this.tagKeysStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v3/src/v3/tag_keys_client_config.json b/owl-bot-staging/v3/src/v3/tag_keys_client_config.json new file mode 100644 index 0000000..b72c651 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/tag_keys_client_config.json @@ -0,0 +1,68 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.TagKeys": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "ListTagKeys": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "GetTagKey": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "CreateTagKey": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateTagKey": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteTagKey": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v3/src/v3/tag_keys_proto_list.json b/owl-bot-staging/v3/src/v3/tag_keys_proto_list.json new file mode 100644 index 0000000..0c00660 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/tag_keys_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/v3/src/v3/tag_values_client.ts b/owl-bot-staging/v3/src/v3/tag_values_client.ts new file mode 100644 index 0000000..9a75b3b --- /dev/null +++ b/owl-bot-staging/v3/src/v3/tag_values_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/v3/tag_values_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './tag_values_client_config.json'; +import { operationsProtos } from 'google-gax'; +const version = require('../../../package.json').version; + +/** + * Allow users to create and manage tag values. + * @class + * @memberof v3 + */ +export class TagValuesClient { + 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}; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + tagValuesStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of TagValuesClient. + * + * @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 TagValuesClient; + 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); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + folderPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}' + ), + organizationPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + tagBindingPathTemplate: new this._gaxModule.PathTemplate( + 'tagBindings/{tag_binding}' + ), + tagKeyPathTemplate: new this._gaxModule.PathTemplate( + 'tagKeys/{tag_key}' + ), + tagValuePathTemplate: new this._gaxModule.PathTemplate( + 'tagValues/{tag_value}' + ), + }; + + // 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 = { + listTagValues: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagValues') + }; + + 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.GetOperation',get: '/v3/{name=operations/**}',}]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createTagValueResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; + const createTagValueMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.CreateTagValueMetadata') as gax.protobuf.Type; + const updateTagValueResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; + const updateTagValueMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.UpdateTagValueMetadata') as gax.protobuf.Type; + const deleteTagValueResponse = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; + const deleteTagValueMetadata = protoFilesRoot.lookup( + '.google.cloud.resourcemanager.v3.DeleteTagValueMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createTagValue: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createTagValueResponse.decode.bind(createTagValueResponse), + createTagValueMetadata.decode.bind(createTagValueMetadata)), + updateTagValue: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateTagValueResponse.decode.bind(updateTagValueResponse), + updateTagValueMetadata.decode.bind(updateTagValueMetadata)), + deleteTagValue: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteTagValueResponse.decode.bind(deleteTagValueResponse), + deleteTagValueMetadata.decode.bind(deleteTagValueMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.resourcemanager.v3.TagValues', 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.tagValuesStub) { + return this.tagValuesStub; + } + + // Put together the "service stub" for + // google.cloud.resourcemanager.v3.TagValues. + this.tagValuesStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagValues') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.resourcemanager.v3.TagValues, + 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 tagValuesStubMethods = + ['listTagValues', 'getTagValue', 'createTagValue', 'updateTagValue', 'deleteTagValue', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + for (const methodName of tagValuesStubMethods) { + const callPromise = this.tagValuesStub.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.tagValuesStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' + ]; + } + + 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 -- + // ------------------- +/** + * Retrieves TagValue. If the TagValue or namespaced name does not exist, or + * if the user does not have permission to view it, this method will return + * `PERMISSION_DENIED`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name for TagValue to be fetched in the format `tagValues/456`. + * @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 [TagValue]{@link google.cloud.resourcemanager.v3.TagValue}. + * 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/v3/tag_values.get_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_GetTagValue_async + */ + getTagValue( + request?: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|undefined, {}|undefined + ]>; + getTagValue( + request: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, + {}|null|undefined>): void; + getTagValue( + request: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, + callback: Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, + {}|null|undefined>): void; + getTagValue( + request?: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue, + protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getTagValue(request, options, callback); + } +/** + * Gets the access control policy for a TagValue. The returned policy may be + * empty if no such policy or resource exists. The `resource` field should + * be the TagValue's resource name. For example: `tagValues/1234`. + * The caller must have the + * `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on + * the identified TagValue to get the access control policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/tag_values.get_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Sets the access control policy on a TagValue, replacing any existing + * policy. The `resource` field should be the TagValue's resource name. + * For example: `tagValues/1234`. + * The caller must have `resourcemanager.tagValues.setIamPolicy` permission + * on the identified tagValue. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @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 [Policy]{@link google.iam.v1.Policy}. + * 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/v3/tag_values.set_iam_policy.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified TagValue. + * The `resource` field should be the TagValue's resource name. For example: + * `tagValues/1234`. + * + * There are no permissions required for making this API call. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * 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/v3/tag_values.test_iam_permissions.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|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({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } + +/** + * Creates a TagValue as a child of the specified TagKey. If a another + * request with the same parameters is sent while the original request is in + * process the second request will receive an error. A maximum of 300 + * TagValues can exist under a TagKey at any given time. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagValue} request.tagValue + * Required. The TagValue to be created. Only fields `short_name`, `description`, + * and `parent` are considered during the creation request. + * @param {boolean} [request.validateOnly] + * Optional. Set as true to perform the validations necessary for creating the resource, + * but not actually perform the action. + * @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/v3/tag_values.create_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async + */ + createTagValue( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createTagValue( + request: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagValue( + request: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createTagValue( + request?: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, + 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 || {}; + this.initialize(); + return this.innerApiCalls.createTagValue(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createTagValue()`. + * @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/v3/tag_values.create_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async + */ + async checkCreateTagValueProgress(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.createTagValue, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Updates the attributes of the TagValue resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.resourcemanager.v3.TagValue} request.tagValue + * Required. The new definition of the TagValue. Only fields `description` and `etag` + * fields can be updated by this request. If the `etag` field is nonempty, it + * must match the `etag` field of the existing ControlGroup. Otherwise, + * `FAILED_PRECONDITION` will be returned. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Fields to be updated. + * @param {boolean} [request.validateOnly] + * Optional. True to perform validations necessary for updating the resource, but not + * actually perform the action. + * @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/v3/tag_values.update_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async + */ + updateTagValue( + request?: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + updateTagValue( + request: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateTagValue( + request: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + updateTagValue( + request?: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, + 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({ + 'tag_value.name': request.tagValue!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateTagValue(request, options, callback); + } +/** + * Check the status of the long running operation returned by `updateTagValue()`. + * @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/v3/tag_values.update_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async + */ + async checkUpdateTagValueProgress(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.updateTagValue, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Deletes a TagValue. The TagValue cannot have any bindings when it is + * deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Resource name for TagValue to be deleted in the format tagValues/456. + * @param {boolean} [request.validateOnly] + * Optional. Set as true to perform the validations necessary for deletion, but not + * actually perform the action. + * @param {string} [request.etag] + * Optional. The etag known to the client for the expected state of the TagValue. This + * is to be used for optimistic concurrency. + * @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/v3/tag_values.delete_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async + */ + deleteTagValue( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + deleteTagValue( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagValue( + request: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + deleteTagValue( + request?: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, + 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({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteTagValue(request, options, callback); + } +/** + * Check the status of the long running operation returned by `deleteTagValue()`. + * @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/v3/tag_values.delete_tag_value.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async + */ + async checkDeleteTagValueProgress(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.deleteTagValue, gax.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists all TagValues for a specific TagKey. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name for TagKey, parent of the TagValues to be listed, + * in the format `tagKeys/123`. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagValues to return in the response. The server + * allows a maximum of 300 TagValues to return. If unspecified, the server + * will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagValues` + * that indicates where this listing should continue from. + * @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 [TagValue]{@link google.cloud.resourcemanager.v3.TagValue}. + * 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 `listTagValuesAsync()` + * 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. + */ + listTagValues( + request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue[], + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse + ]>; + listTagValues( + request: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagValue>): void; + listTagValues( + request: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + callback: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagValue>): void; + listTagValues( + request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagValue>, + callback?: PaginationCallback< + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, + protos.google.cloud.resourcemanager.v3.ITagValue>): + Promise<[ + protos.google.cloud.resourcemanager.v3.ITagValue[], + protos.google.cloud.resourcemanager.v3.IListTagValuesRequest|null, + protos.google.cloud.resourcemanager.v3.IListTagValuesResponse + ]>|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 || {}; + this.initialize(); + return this.innerApiCalls.listTagValues(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.parent + * Required. Resource name for TagKey, parent of the TagValues to be listed, + * in the format `tagKeys/123`. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagValues to return in the response. The server + * allows a maximum of 300 TagValues to return. If unspecified, the server + * will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagValues` + * that indicates where this listing should continue from. + * @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 [TagValue]{@link google.cloud.resourcemanager.v3.TagValue} 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 `listTagValuesAsync()` + * 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. + */ + listTagValuesStream( + request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagValues']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagValues.createStream( + this.innerApiCalls.listTagValues as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listTagValues`, 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.parent + * Required. Resource name for TagKey, parent of the TagValues to be listed, + * in the format `tagKeys/123`. + * @param {number} [request.pageSize] + * Optional. The maximum number of TagValues to return in the response. The server + * allows a maximum of 300 TagValues to return. If unspecified, the server + * will use 100 as the default. + * @param {string} [request.pageToken] + * Optional. A pagination token returned from a previous call to `ListTagValues` + * that indicates where this listing should continue from. + * @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 + * [TagValue]{@link google.cloud.resourcemanager.v3.TagValue}. 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/v3/tag_values.list_tag_values.js + * region_tag:cloudresourcemanager_v3_generated_TagValues_ListTagValues_async + */ + listTagValuesAsync( + request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['listTagValues']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listTagValues.asyncIterate( + this.innerApiCalls['listTagValues'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified folder resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderPath(folder:string) { + return this.pathTemplates.folderPathTemplate.render({ + folder: folder, + }); + } + + /** + * Parse the folder from Folder resource. + * + * @param {string} folderName + * A fully-qualified path representing Folder resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderName(folderName: string) { + return this.pathTemplates.folderPathTemplate.match(folderName).folder; + } + + /** + * Return a fully-qualified organization resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationPath(organization:string) { + return this.pathTemplates.organizationPathTemplate.render({ + organization: organization, + }); + } + + /** + * Parse the organization from Organization resource. + * + * @param {string} organizationName + * A fully-qualified path representing Organization resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationName(organizationName: string) { + return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project:string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Return a fully-qualified tagBinding resource name string. + * + * @param {string} tag_binding + * @returns {string} Resource name string. + */ + tagBindingPath(tagBinding:string) { + return this.pathTemplates.tagBindingPathTemplate.render({ + tag_binding: tagBinding, + }); + } + + /** + * Parse the tag_binding from TagBinding resource. + * + * @param {string} tagBindingName + * A fully-qualified path representing TagBinding resource. + * @returns {string} A string representing the tag_binding. + */ + matchTagBindingFromTagBindingName(tagBindingName: string) { + return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; + } + + /** + * Return a fully-qualified tagKey resource name string. + * + * @param {string} tag_key + * @returns {string} Resource name string. + */ + tagKeyPath(tagKey:string) { + return this.pathTemplates.tagKeyPathTemplate.render({ + tag_key: tagKey, + }); + } + + /** + * Parse the tag_key from TagKey resource. + * + * @param {string} tagKeyName + * A fully-qualified path representing TagKey resource. + * @returns {string} A string representing the tag_key. + */ + matchTagKeyFromTagKeyName(tagKeyName: string) { + return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; + } + + /** + * Return a fully-qualified tagValue resource name string. + * + * @param {string} tag_value + * @returns {string} Resource name string. + */ + tagValuePath(tagValue:string) { + return this.pathTemplates.tagValuePathTemplate.render({ + tag_value: tagValue, + }); + } + + /** + * Parse the tag_value from TagValue resource. + * + * @param {string} tagValueName + * A fully-qualified path representing TagValue resource. + * @returns {string} A string representing the tag_value. + */ + matchTagValueFromTagValueName(tagValueName: string) { + return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; + } + + /** + * 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.tagValuesStub && !this._terminated) { + return this.tagValuesStub.then(stub => { + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v3/src/v3/tag_values_client_config.json b/owl-bot-staging/v3/src/v3/tag_values_client_config.json new file mode 100644 index 0000000..01ac770 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/tag_values_client_config.json @@ -0,0 +1,68 @@ +{ + "interfaces": { + "google.cloud.resourcemanager.v3.TagValues": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "unavailable": [ + "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": { + "ListTagValues": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "GetTagValue": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "CreateTagValue": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateTagValue": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteTagValue": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "unavailable", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v3/src/v3/tag_values_proto_list.json b/owl-bot-staging/v3/src/v3/tag_values_proto_list.json new file mode 100644 index 0000000..0c00660 --- /dev/null +++ b/owl-bot-staging/v3/src/v3/tag_values_proto_list.json @@ -0,0 +1,8 @@ +[ + "../../protos/google/cloud/resourcemanager/v3/folders.proto", + "../../protos/google/cloud/resourcemanager/v3/organizations.proto", + "../../protos/google/cloud/resourcemanager/v3/projects.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", + "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" +] diff --git a/owl-bot-staging/v3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v3/system-test/fixtures/sample/src/index.js new file mode 100644 index 0000000..6fe6a2e --- /dev/null +++ b/owl-bot-staging/v3/system-test/fixtures/sample/src/index.js @@ -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. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const resourcemanager = require('@google-cloud/resource-manager'); + +function main() { + const foldersClient = new resourcemanager.FoldersClient(); + const organizationsClient = new resourcemanager.OrganizationsClient(); + const projectsClient = new resourcemanager.ProjectsClient(); + const tagBindingsClient = new resourcemanager.TagBindingsClient(); + const tagKeysClient = new resourcemanager.TagKeysClient(); + const tagValuesClient = new resourcemanager.TagValuesClient(); +} + +main(); diff --git a/owl-bot-staging/v3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v3/system-test/fixtures/sample/src/index.ts new file mode 100644 index 0000000..65f594c --- /dev/null +++ b/owl-bot-staging/v3/system-test/fixtures/sample/src/index.ts @@ -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. ** + +import {FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagKeysClient, TagValuesClient} from '@google-cloud/resource-manager'; + +// check that the client class type name can be used +function doStuffWithFoldersClient(client: FoldersClient) { + client.close(); +} +function doStuffWithOrganizationsClient(client: OrganizationsClient) { + client.close(); +} +function doStuffWithProjectsClient(client: ProjectsClient) { + client.close(); +} +function doStuffWithTagBindingsClient(client: TagBindingsClient) { + client.close(); +} +function doStuffWithTagKeysClient(client: TagKeysClient) { + client.close(); +} +function doStuffWithTagValuesClient(client: TagValuesClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const foldersClient = new FoldersClient(); + doStuffWithFoldersClient(foldersClient); + // check that the client instance can be created + const organizationsClient = new OrganizationsClient(); + doStuffWithOrganizationsClient(organizationsClient); + // check that the client instance can be created + const projectsClient = new ProjectsClient(); + doStuffWithProjectsClient(projectsClient); + // check that the client instance can be created + const tagBindingsClient = new TagBindingsClient(); + doStuffWithTagBindingsClient(tagBindingsClient); + // check that the client instance can be created + const tagKeysClient = new TagKeysClient(); + doStuffWithTagKeysClient(tagKeysClient); + // check that the client instance can be created + const tagValuesClient = new TagValuesClient(); + doStuffWithTagValuesClient(tagValuesClient); +} + +main(); diff --git a/owl-bot-staging/v3/system-test/install.ts b/owl-bot-staging/v3/system-test/install.ts new file mode 100644 index 0000000..8ec4522 --- /dev/null +++ b/owl-bot-staging/v3/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/v3/test/gapic_folders_v3.ts b/owl-bot-staging/v3/test/gapic_folders_v3.ts new file mode 100644 index 0000000..05377b0 --- /dev/null +++ b/owl-bot-staging/v3/test/gapic_folders_v3.ts @@ -0,0 +1,1803 @@ +// 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 foldersModule 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('v3.FoldersClient', () => { + it('has servicePath', () => { + const servicePath = foldersModule.v3.FoldersClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = foldersModule.v3.FoldersClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = foldersModule.v3.FoldersClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new foldersModule.v3.FoldersClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new foldersModule.v3.FoldersClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.foldersStub, undefined); + await client.initialize(); + assert(client.foldersStub); + }); + + it('has close method for the initialized client', done => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.foldersStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.foldersStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new foldersModule.v3.FoldersClient({ + 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 foldersModule.v3.FoldersClient({ + 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('getFolder', () => { + it('invokes getFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()); + client.innerApiCalls.getFolder = stubSimpleCall(expectedResponse); + const [response] = await client.getFolder(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()); + client.innerApiCalls.getFolder = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFolder( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getFolder with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getFolder = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getFolder(request), expectedError); + assert((client.innerApiCalls.getFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getFolder with closed client', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetFolderRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getFolder(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createFolder', () => { + it('invokes createFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateFolderRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.createFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateFolderRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createFolder( + 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.createFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateFolderRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createFolder(request), expectedError); + assert((client.innerApiCalls.createFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateFolderRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createFolder(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkCreateFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkCreateFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateFolder', () => { + it('invokes updateFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest()); + request.folder = {}; + request.folder.name = ''; + const expectedHeaderRequestParams = "folder.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest()); + request.folder = {}; + request.folder.name = ''; + const expectedHeaderRequestParams = "folder.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFolder( + 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.updateFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest()); + request.folder = {}; + request.folder.name = ''; + const expectedHeaderRequestParams = "folder.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateFolder(request), expectedError); + assert((client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest()); + request.folder = {}; + request.folder.name = ''; + const expectedHeaderRequestParams = "folder.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateFolder(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkUpdateFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkUpdateFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('moveFolder', () => { + it('invokes moveFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.moveFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.moveFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes moveFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.moveFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moveFolder( + 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.moveFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes moveFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.moveFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.moveFolder(request), expectedError); + assert((client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes moveFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.moveFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.moveFolder(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.moveFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkMoveFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkMoveFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkMoveFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkMoveFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteFolder', () => { + it('invokes deleteFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteFolder( + 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.deleteFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteFolder(request), expectedError); + assert((client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteFolder(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkDeleteFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkDeleteFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('undeleteFolder', () => { + it('invokes undeleteFolder without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.undeleteFolder = stubLongRunningCall(expectedResponse); + const [operation] = await client.undeleteFolder(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes undeleteFolder without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.undeleteFolder = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeleteFolder( + 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.undeleteFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes undeleteFolder with call error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteFolder = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.undeleteFolder(request), expectedError); + assert((client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes undeleteFolder with LRO error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteFolder = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.undeleteFolder(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.undeleteFolder as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUndeleteFolderProgress without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkUndeleteFolderProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUndeleteFolderProgress with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + 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.checkUndeleteFolderProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listFolders', () => { + it('invokes listFolders without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.innerApiCalls.listFolders = stubSimpleCall(expectedResponse); + const [response] = await client.listFolders(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFolders as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFolders without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.innerApiCalls.listFolders = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFolders( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listFolders as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listFolders with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.listFolders = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listFolders(request), expectedError); + assert((client.innerApiCalls.listFolders as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listFoldersStream without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.descriptors.page.listFolders.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listFoldersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { + 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.listFolders.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFolders, request)); + }); + + it('invokes listFoldersStream with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); + const expectedError = new Error('expected'); + client.descriptors.page.listFolders.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listFoldersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listFolders.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listFolders, request)); + }); + + it('uses async iteration with listFolders without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.descriptors.page.listFolders.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; + const iterable = client.listFoldersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listFolders.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listFolders with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest());const expectedError = new Error('expected'); + client.descriptors.page.listFolders.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFoldersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listFolders.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('searchFolders', () => { + it('invokes searchFolders without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.innerApiCalls.searchFolders = stubSimpleCall(expectedResponse); + const [response] = await client.searchFolders(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchFolders as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchFolders without error using callback', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.innerApiCalls.searchFolders = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchFolders( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchFolders as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes searchFolders with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.searchFolders = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchFolders(request), expectedError); + assert((client.innerApiCalls.searchFolders as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchFoldersStream without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.descriptors.page.searchFolders.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchFoldersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { + 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.searchFolders.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchFolders, request)); + }); + + it('invokes searchFoldersStream with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); + const expectedError = new Error('expected'); + client.descriptors.page.searchFolders.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchFoldersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchFolders.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchFolders, request)); + }); + + it('uses async iteration with searchFolders without error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), + ]; + client.descriptors.page.searchFolders.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; + const iterable = client.searchFoldersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchFolders.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with searchFolders with error', async () => { + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest());const expectedError = new Error('expected'); + client.descriptors.page.searchFolders.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchFoldersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchFolders.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new foldersModule.v3.FoldersClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v3/test/gapic_organizations_v3.ts b/owl-bot-staging/v3/test/gapic_organizations_v3.ts new file mode 100644 index 0000000..3f2351b --- /dev/null +++ b/owl-bot-staging/v3/test/gapic_organizations_v3.ts @@ -0,0 +1,924 @@ +// 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 organizationsModule from '../src'; + +import {PassThrough} from 'stream'; + +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); +} + +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('v3.OrganizationsClient', () => { + it('has servicePath', () => { + const servicePath = organizationsModule.v3.OrganizationsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = organizationsModule.v3.OrganizationsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = organizationsModule.v3.OrganizationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new organizationsModule.v3.OrganizationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new organizationsModule.v3.OrganizationsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.organizationsStub, undefined); + await client.initialize(); + assert(client.organizationsStub); + }); + + it('has close method for the initialized client', done => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.organizationsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.organizationsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new organizationsModule.v3.OrganizationsClient({ + 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 organizationsModule.v3.OrganizationsClient({ + 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('getOrganization', () => { + it('invokes getOrganization without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()); + client.innerApiCalls.getOrganization = stubSimpleCall(expectedResponse); + const [response] = await client.getOrganization(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOrganization as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getOrganization without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()); + client.innerApiCalls.getOrganization = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOrganization( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IOrganization|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getOrganization as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getOrganization with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getOrganization = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getOrganization(request), expectedError); + assert((client.innerApiCalls.getOrganization as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getOrganization with closed client', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getOrganization(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('searchOrganizations', () => { + it('invokes searchOrganizations without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + ]; + client.innerApiCalls.searchOrganizations = stubSimpleCall(expectedResponse); + const [response] = await client.searchOrganizations(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchOrganizations as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchOrganizations without error using callback', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + ]; + client.innerApiCalls.searchOrganizations = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchOrganizations( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IOrganization[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchOrganizations as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes searchOrganizations with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.searchOrganizations = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchOrganizations(request), expectedError); + assert((client.innerApiCalls.searchOrganizations as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchOrganizationsStream without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + ]; + client.descriptors.page.searchOrganizations.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchOrganizationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Organization[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Organization) => { + 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.searchOrganizations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchOrganizations, request)); + }); + + it('invokes searchOrganizationsStream with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); + const expectedError = new Error('expected'); + client.descriptors.page.searchOrganizations.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchOrganizationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Organization[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Organization) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchOrganizations.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchOrganizations, request)); + }); + + it('uses async iteration with searchOrganizations without error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), + ]; + client.descriptors.page.searchOrganizations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IOrganization[] = []; + const iterable = client.searchOrganizationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchOrganizations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with searchOrganizations with error', async () => { + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest());const expectedError = new Error('expected'); + client.descriptors.page.searchOrganizations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchOrganizationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IOrganization[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchOrganizations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new organizationsModule.v3.OrganizationsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v3/test/gapic_projects_v3.ts b/owl-bot-staging/v3/test/gapic_projects_v3.ts new file mode 100644 index 0000000..89f3c09 --- /dev/null +++ b/owl-bot-staging/v3/test/gapic_projects_v3.ts @@ -0,0 +1,1803 @@ +// 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 projectsModule 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('v3.ProjectsClient', () => { + it('has servicePath', () => { + const servicePath = projectsModule.v3.ProjectsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = projectsModule.v3.ProjectsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = projectsModule.v3.ProjectsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new projectsModule.v3.ProjectsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new projectsModule.v3.ProjectsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.projectsStub, undefined); + await client.initialize(); + assert(client.projectsStub); + }); + + it('has close method for the initialized client', done => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.projectsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.projectsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new projectsModule.v3.ProjectsClient({ + 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 projectsModule.v3.ProjectsClient({ + 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('getProject', () => { + it('invokes getProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()); + client.innerApiCalls.getProject = stubSimpleCall(expectedResponse); + const [response] = await client.getProject(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()); + client.innerApiCalls.getProject = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProject( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getProject with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getProject = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProject(request), expectedError); + assert((client.innerApiCalls.getProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getProject with closed client', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetProjectRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProject(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createProject', () => { + it('invokes createProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateProjectRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.createProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateProjectRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProject( + 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.createProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateProjectRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createProject(request), expectedError); + assert((client.innerApiCalls.createProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateProjectRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createProject(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkCreateProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkCreateProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateProject', () => { + it('invokes updateProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest()); + request.project = {}; + request.project.name = ''; + const expectedHeaderRequestParams = "project.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest()); + request.project = {}; + request.project.name = ''; + const expectedHeaderRequestParams = "project.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateProject( + 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.updateProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest()); + request.project = {}; + request.project.name = ''; + const expectedHeaderRequestParams = "project.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateProject(request), expectedError); + assert((client.innerApiCalls.updateProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest()); + request.project = {}; + request.project.name = ''; + const expectedHeaderRequestParams = "project.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateProject(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkUpdateProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkUpdateProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('moveProject', () => { + it('invokes moveProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.moveProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.moveProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.moveProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes moveProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.moveProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moveProject( + 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.moveProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes moveProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.moveProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.moveProject(request), expectedError); + assert((client.innerApiCalls.moveProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes moveProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.moveProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.moveProject(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.moveProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkMoveProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkMoveProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkMoveProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkMoveProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteProject', () => { + it('invokes deleteProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProject( + 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.deleteProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteProject(request), expectedError); + assert((client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteProject(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkDeleteProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkDeleteProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('undeleteProject', () => { + it('invokes undeleteProject without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.undeleteProject = stubLongRunningCall(expectedResponse); + const [operation] = await client.undeleteProject(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes undeleteProject without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.undeleteProject = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeleteProject( + 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.undeleteProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes undeleteProject with call error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteProject = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.undeleteProject(request), expectedError); + assert((client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes undeleteProject with LRO error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteProject = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.undeleteProject(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.undeleteProject as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUndeleteProjectProgress without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkUndeleteProjectProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUndeleteProjectProgress with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + 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.checkUndeleteProjectProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listProjects', () => { + it('invokes listProjects without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.innerApiCalls.listProjects = stubSimpleCall(expectedResponse); + const [response] = await client.listProjects(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProjects as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProjects without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.innerApiCalls.listProjects = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProjects( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listProjects as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listProjects with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.listProjects = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProjects(request), expectedError); + assert((client.innerApiCalls.listProjects as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listProjectsStream without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.descriptors.page.listProjects.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listProjectsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { + 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.listProjects.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProjects, request)); + }); + + it('invokes listProjectsStream with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); + const expectedError = new Error('expected'); + client.descriptors.page.listProjects.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProjectsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listProjects.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listProjects, request)); + }); + + it('uses async iteration with listProjects without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.descriptors.page.listProjects.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; + const iterable = client.listProjectsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listProjects.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listProjects with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest());const expectedError = new Error('expected'); + client.descriptors.page.listProjects.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProjectsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listProjects.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('searchProjects', () => { + it('invokes searchProjects without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.innerApiCalls.searchProjects = stubSimpleCall(expectedResponse); + const [response] = await client.searchProjects(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchProjects as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchProjects without error using callback', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.innerApiCalls.searchProjects = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchProjects( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.searchProjects as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes searchProjects with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.searchProjects = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.searchProjects(request), expectedError); + assert((client.innerApiCalls.searchProjects as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes searchProjectsStream without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.descriptors.page.searchProjects.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.searchProjectsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { + 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.searchProjects.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchProjects, request)); + }); + + it('invokes searchProjectsStream with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); + const expectedError = new Error('expected'); + client.descriptors.page.searchProjects.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.searchProjectsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.searchProjects.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.searchProjects, request)); + }); + + it('uses async iteration with searchProjects without error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), + ]; + client.descriptors.page.searchProjects.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; + const iterable = client.searchProjectsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchProjects.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with searchProjects with error', async () => { + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest());const expectedError = new Error('expected'); + client.descriptors.page.searchProjects.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchProjectsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchProjects.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new projectsModule.v3.ProjectsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v3/test/gapic_tag_bindings_v3.ts b/owl-bot-staging/v3/test/gapic_tag_bindings_v3.ts new file mode 100644 index 0000000..062c5f9 --- /dev/null +++ b/owl-bot-staging/v3/test/gapic_tag_bindings_v3.ts @@ -0,0 +1,808 @@ +// 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 tagbindingsModule 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('v3.TagBindingsClient', () => { + it('has servicePath', () => { + const servicePath = tagbindingsModule.v3.TagBindingsClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tagbindingsModule.v3.TagBindingsClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tagbindingsModule.v3.TagBindingsClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tagbindingsModule.v3.TagBindingsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagBindingsStub, undefined); + await client.initialize(); + assert(client.tagBindingsStub); + }); + + it('has close method for the initialized client', done => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tagBindingsStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagBindingsStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tagbindingsModule.v3.TagBindingsClient({ + 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 tagbindingsModule.v3.TagBindingsClient({ + 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('createTagBinding', () => { + it('invokes createTagBinding without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createTagBinding = stubLongRunningCall(expectedResponse); + const [operation] = await client.createTagBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createTagBinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createTagBinding without error using callback', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createTagBinding = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTagBinding( + 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.createTagBinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createTagBinding with call error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createTagBinding = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createTagBinding(request), expectedError); + assert((client.innerApiCalls.createTagBinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createTagBinding with LRO error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createTagBinding = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createTagBinding(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createTagBinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateTagBindingProgress without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + 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.checkCreateTagBindingProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateTagBindingProgress with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + 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.checkCreateTagBindingProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteTagBinding', () => { + it('invokes deleteTagBinding without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteTagBinding = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTagBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteTagBinding without error using callback', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteTagBinding = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTagBinding( + 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.deleteTagBinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteTagBinding with call error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagBinding = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteTagBinding(request), expectedError); + assert((client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteTagBinding with LRO error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagBinding = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteTagBinding(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteTagBinding as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteTagBindingProgress without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + 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.checkDeleteTagBindingProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteTagBindingProgress with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + 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.checkDeleteTagBindingProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listTagBindings', () => { + it('invokes listTagBindings without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + ]; + client.innerApiCalls.listTagBindings = stubSimpleCall(expectedResponse); + const [response] = await client.listTagBindings(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listTagBindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listTagBindings without error using callback', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + ]; + client.innerApiCalls.listTagBindings = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTagBindings( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagBinding[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listTagBindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listTagBindings with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.listTagBindings = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTagBindings(request), expectedError); + assert((client.innerApiCalls.listTagBindings as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listTagBindingsStream without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + ]; + client.descriptors.page.listTagBindings.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTagBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagBinding[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagBinding) => { + 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.listTagBindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagBindings, request)); + }); + + it('invokes listTagBindingsStream with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); + const expectedError = new Error('expected'); + client.descriptors.page.listTagBindings.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTagBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagBinding[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagBinding) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTagBindings.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagBindings, request)); + }); + + it('uses async iteration with listTagBindings without error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), + ]; + client.descriptors.page.listTagBindings.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.ITagBinding[] = []; + const iterable = client.listTagBindingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTagBindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listTagBindings with error', async () => { + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest());const expectedError = new Error('expected'); + client.descriptors.page.listTagBindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTagBindingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.ITagBinding[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTagBindings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new tagbindingsModule.v3.TagBindingsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v3/test/gapic_tag_keys_v3.ts b/owl-bot-staging/v3/test/gapic_tag_keys_v3.ts new file mode 100644 index 0000000..b2ff45b --- /dev/null +++ b/owl-bot-staging/v3/test/gapic_tag_keys_v3.ts @@ -0,0 +1,1344 @@ +// 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 tagkeysModule 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('v3.TagKeysClient', () => { + it('has servicePath', () => { + const servicePath = tagkeysModule.v3.TagKeysClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tagkeysModule.v3.TagKeysClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tagkeysModule.v3.TagKeysClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tagkeysModule.v3.TagKeysClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tagkeysModule.v3.TagKeysClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagKeysStub, undefined); + await client.initialize(); + assert(client.tagKeysStub); + }); + + it('has close method for the initialized client', done => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tagKeysStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagKeysStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tagkeysModule.v3.TagKeysClient({ + 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 tagkeysModule.v3.TagKeysClient({ + 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('getTagKey', () => { + it('invokes getTagKey without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()); + client.innerApiCalls.getTagKey = stubSimpleCall(expectedResponse); + const [response] = await client.getTagKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getTagKey without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()); + client.innerApiCalls.getTagKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTagKey( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getTagKey with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getTagKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTagKey(request), expectedError); + assert((client.innerApiCalls.getTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getTagKey with closed client', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getTagKey(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createTagKey', () => { + it('invokes createTagKey without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createTagKey = stubLongRunningCall(expectedResponse); + const [operation] = await client.createTagKey(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createTagKey without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createTagKey = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTagKey( + 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.createTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createTagKey with call error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createTagKey = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createTagKey(request), expectedError); + assert((client.innerApiCalls.createTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createTagKey with LRO error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createTagKey = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createTagKey(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateTagKeyProgress without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + 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.checkCreateTagKeyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateTagKeyProgress with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + 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.checkCreateTagKeyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateTagKey', () => { + it('invokes updateTagKey without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest()); + request.tagKey = {}; + request.tagKey.name = ''; + const expectedHeaderRequestParams = "tag_key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateTagKey = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateTagKey(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateTagKey without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest()); + request.tagKey = {}; + request.tagKey.name = ''; + const expectedHeaderRequestParams = "tag_key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateTagKey = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTagKey( + 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.updateTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateTagKey with call error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest()); + request.tagKey = {}; + request.tagKey.name = ''; + const expectedHeaderRequestParams = "tag_key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTagKey = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateTagKey(request), expectedError); + assert((client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateTagKey with LRO error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest()); + request.tagKey = {}; + request.tagKey.name = ''; + const expectedHeaderRequestParams = "tag_key.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTagKey = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateTagKey(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateTagKeyProgress without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + 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.checkUpdateTagKeyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateTagKeyProgress with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + 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.checkUpdateTagKeyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteTagKey', () => { + it('invokes deleteTagKey without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteTagKey = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTagKey(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteTagKey without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteTagKey = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTagKey( + 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.deleteTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteTagKey with call error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagKey = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteTagKey(request), expectedError); + assert((client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteTagKey with LRO error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagKey = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteTagKey(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteTagKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteTagKeyProgress without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + 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.checkDeleteTagKeyProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteTagKeyProgress with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + 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.checkDeleteTagKeyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listTagKeys', () => { + it('invokes listTagKeys without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + ]; + client.innerApiCalls.listTagKeys = stubSimpleCall(expectedResponse); + const [response] = await client.listTagKeys(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listTagKeys as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listTagKeys without error using callback', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + ]; + client.innerApiCalls.listTagKeys = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTagKeys( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listTagKeys as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listTagKeys with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.listTagKeys = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTagKeys(request), expectedError); + assert((client.innerApiCalls.listTagKeys as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listTagKeysStream without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + ]; + client.descriptors.page.listTagKeys.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTagKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagKey[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagKey) => { + 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.listTagKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagKeys, request)); + }); + + it('invokes listTagKeysStream with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); + const expectedError = new Error('expected'); + client.descriptors.page.listTagKeys.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTagKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagKey[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagKey) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTagKeys.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagKeys, request)); + }); + + it('uses async iteration with listTagKeys without error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), + ]; + client.descriptors.page.listTagKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.ITagKey[] = []; + const iterable = client.listTagKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTagKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listTagKeys with error', async () => { + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest());const expectedError = new Error('expected'); + client.descriptors.page.listTagKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTagKeysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.ITagKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTagKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new tagkeysModule.v3.TagKeysClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v3/test/gapic_tag_values_v3.ts b/owl-bot-staging/v3/test/gapic_tag_values_v3.ts new file mode 100644 index 0000000..9773fd6 --- /dev/null +++ b/owl-bot-staging/v3/test/gapic_tag_values_v3.ts @@ -0,0 +1,1344 @@ +// 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 tagvaluesModule 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('v3.TagValuesClient', () => { + it('has servicePath', () => { + const servicePath = tagvaluesModule.v3.TagValuesClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = tagvaluesModule.v3.TagValuesClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = tagvaluesModule.v3.TagValuesClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new tagvaluesModule.v3.TagValuesClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagValuesStub, undefined); + await client.initialize(); + assert(client.tagValuesStub); + }); + + it('has close method for the initialized client', done => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.tagValuesStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.tagValuesStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tagvaluesModule.v3.TagValuesClient({ + 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 tagvaluesModule.v3.TagValuesClient({ + 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('getTagValue', () => { + it('invokes getTagValue without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagValueRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()); + client.innerApiCalls.getTagValue = stubSimpleCall(expectedResponse); + const [response] = await client.getTagValue(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getTagValue without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagValueRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()); + client.innerApiCalls.getTagValue = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTagValue( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getTagValue with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagValueRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getTagValue = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTagValue(request), expectedError); + assert((client.innerApiCalls.getTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getTagValue with closed client', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagValueRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getTagValue(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createTagValue', () => { + it('invokes createTagValue without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createTagValue = stubLongRunningCall(expectedResponse); + const [operation] = await client.createTagValue(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createTagValue without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.createTagValue = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTagValue( + 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.createTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createTagValue with call error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createTagValue = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createTagValue(request), expectedError); + assert((client.innerApiCalls.createTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createTagValue with LRO error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.createTagValue = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createTagValue(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.createTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkCreateTagValueProgress without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + 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.checkCreateTagValueProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateTagValueProgress with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + 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.checkCreateTagValueProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('updateTagValue', () => { + it('invokes updateTagValue without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest()); + request.tagValue = {}; + request.tagValue.name = ''; + const expectedHeaderRequestParams = "tag_value.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateTagValue = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateTagValue(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateTagValue without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest()); + request.tagValue = {}; + request.tagValue.name = ''; + const expectedHeaderRequestParams = "tag_value.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.updateTagValue = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTagValue( + 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.updateTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateTagValue with call error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest()); + request.tagValue = {}; + request.tagValue.name = ''; + const expectedHeaderRequestParams = "tag_value.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTagValue = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.updateTagValue(request), expectedError); + assert((client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateTagValue with LRO error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest()); + request.tagValue = {}; + request.tagValue.name = ''; + const expectedHeaderRequestParams = "tag_value.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTagValue = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateTagValue(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.updateTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkUpdateTagValueProgress without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + 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.checkUpdateTagValueProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateTagValueProgress with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + 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.checkUpdateTagValueProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('deleteTagValue', () => { + it('invokes deleteTagValue without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteTagValue = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteTagValue(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteTagValue without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); + client.innerApiCalls.deleteTagValue = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTagValue( + 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.deleteTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteTagValue with call error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagValue = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.deleteTagValue(request), expectedError); + assert((client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteTagValue with LRO error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTagValue = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteTagValue(request); + await assert.rejects(operation.promise(), expectedError); + assert((client.innerApiCalls.deleteTagValue as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes checkDeleteTagValueProgress without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + 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.checkDeleteTagValueProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteTagValueProgress with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + 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.checkDeleteTagValueProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listTagValues', () => { + it('invokes listTagValues without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + ]; + client.innerApiCalls.listTagValues = stubSimpleCall(expectedResponse); + const [response] = await client.listTagValues(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listTagValues as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listTagValues without error using callback', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + ]; + client.innerApiCalls.listTagValues = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTagValues( + request, + (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listTagValues as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listTagValues with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); + const expectedOptions = {otherArgs: {headers: {}}};; + const expectedError = new Error('expected'); + client.innerApiCalls.listTagValues = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTagValues(request), expectedError); + assert((client.innerApiCalls.listTagValues as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listTagValuesStream without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + ]; + client.descriptors.page.listTagValues.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listTagValuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagValue[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagValue) => { + 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.listTagValues.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagValues, request)); + }); + + it('invokes listTagValuesStream with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); + const expectedError = new Error('expected'); + client.descriptors.page.listTagValues.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listTagValuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.resourcemanager.v3.TagValue[] = []; + stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagValue) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listTagValues.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listTagValues, request)); + }); + + it('uses async iteration with listTagValues without error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), + ]; + client.descriptors.page.listTagValues.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.resourcemanager.v3.ITagValue[] = []; + const iterable = client.listTagValuesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTagValues.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listTagValues with error', async () => { + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest());const expectedError = new Error('expected'); + client.descriptors.page.listTagValues.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTagValuesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.resourcemanager.v3.ITagValue[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTagValues.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('folder', () => { + const fakePath = "/rendered/path/folder"; + const expectedParameters = { + folder: "folderValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.folderPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.folderPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('folderPath', () => { + const result = client.folderPath("folderValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.folderPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchFolderFromFolderName', () => { + const result = client.matchFolderFromFolderName(fakePath); + assert.strictEqual(result, "folderValue"); + assert((client.pathTemplates.folderPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('organization', () => { + const fakePath = "/rendered/path/organization"; + const expectedParameters = { + organization: "organizationValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.organizationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath("organizationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, "organizationValue"); + assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('project', () => { + const fakePath = "/rendered/path/project"; + const expectedParameters = { + project: "projectValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath("projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagBinding', () => { + const fakePath = "/rendered/path/tagBinding"; + const expectedParameters = { + tag_binding: "tagBindingValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagBindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagBindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagBindingPath', () => { + const result = client.tagBindingPath("tagBindingValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagBindingFromTagBindingName', () => { + const result = client.matchTagBindingFromTagBindingName(fakePath); + assert.strictEqual(result, "tagBindingValue"); + assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagKey', () => { + const fakePath = "/rendered/path/tagKey"; + const expectedParameters = { + tag_key: "tagKeyValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagKeyPath', () => { + const result = client.tagKeyPath("tagKeyValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagKeyFromTagKeyName', () => { + const result = client.matchTagKeyFromTagKeyName(fakePath); + assert.strictEqual(result, "tagKeyValue"); + assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('tagValue', () => { + const fakePath = "/rendered/path/tagValue"; + const expectedParameters = { + tag_value: "tagValueValue", + }; + const client = new tagvaluesModule.v3.TagValuesClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tagValuePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.tagValuePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('tagValuePath', () => { + const result = client.tagValuePath("tagValueValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchTagValueFromTagValueName', () => { + const result = client.matchTagValueFromTagValueName(fakePath); + assert.strictEqual(result, "tagValueValue"); + assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v3/tsconfig.json b/owl-bot-staging/v3/tsconfig.json new file mode 100644 index 0000000..c78f1c8 --- /dev/null +++ b/owl-bot-staging/v3/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/v3/webpack.config.js b/owl-bot-staging/v3/webpack.config.js new file mode 100644 index 0000000..92f3d14 --- /dev/null +++ b/owl-bot-staging/v3/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: 'Folders', + filename: './folders.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 620f9e07808c4a6aee421f23f455599e88b277e7 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 24 Jun 2022 10:10:00 +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/v3/.eslintignore | 7 - owl-bot-staging/v3/.eslintrc.json | 3 - owl-bot-staging/v3/.gitignore | 14 - owl-bot-staging/v3/.jsdoc.js | 55 - owl-bot-staging/v3/.mocharc.js | 33 - owl-bot-staging/v3/.prettierrc.js | 22 - owl-bot-staging/v3/README.md | 1 - owl-bot-staging/v3/linkinator.config.json | 16 - owl-bot-staging/v3/package.json | 69 - .../cloud/resourcemanager/v3/folders.proto | 536 ----- .../resourcemanager/v3/organizations.proto | 237 -- .../cloud/resourcemanager/v3/projects.proto | 640 ----- .../resourcemanager/v3/tag_bindings.proto | 177 -- .../cloud/resourcemanager/v3/tag_keys.proto | 300 --- .../cloud/resourcemanager/v3/tag_values.proto | 296 --- .../generated/v3/folders.create_folder.js | 60 - .../generated/v3/folders.delete_folder.js | 60 - .../generated/v3/folders.get_folder.js | 59 - .../generated/v3/folders.get_iam_policy.js | 64 - .../generated/v3/folders.list_folders.js | 80 - .../generated/v3/folders.move_folder.js | 67 - .../generated/v3/folders.search_folders.js | 94 - .../generated/v3/folders.set_iam_policy.js | 74 - .../v3/folders.test_iam_permissions.js | 67 - .../generated/v3/folders.undelete_folder.js | 60 - .../generated/v3/folders.update_folder.js | 66 - .../v3/organizations.get_iam_policy.js | 64 - .../v3/organizations.get_organization.js | 60 - .../v3/organizations.search_organizations.js | 83 - .../v3/organizations.set_iam_policy.js | 74 - .../v3/organizations.test_iam_permissions.js | 67 - .../generated/v3/projects.create_project.js | 65 - .../generated/v3/projects.delete_project.js | 59 - .../generated/v3/projects.get_iam_policy.js | 64 - .../generated/v3/projects.get_project.js | 58 - .../generated/v3/projects.list_projects.js | 79 - .../generated/v3/projects.move_project.js | 64 - .../generated/v3/projects.search_projects.js | 104 - .../generated/v3/projects.set_iam_policy.js | 74 - .../v3/projects.test_iam_permissions.js | 67 - .../generated/v3/projects.undelete_project.js | 60 - .../generated/v3/projects.update_project.js | 63 - ...adata.google.cloud.resourcemanager.v3.json | 2067 ----------------- .../v3/tag_bindings.create_tag_binding.js | 64 - .../v3/tag_bindings.delete_tag_binding.js | 61 - .../v3/tag_bindings.list_tag_bindings.js | 73 - .../generated/v3/tag_keys.create_tag_key.js | 65 - .../generated/v3/tag_keys.delete_tag_key.js | 71 - .../generated/v3/tag_keys.get_iam_policy.js | 64 - .../generated/v3/tag_keys.get_tag_key.js | 59 - .../generated/v3/tag_keys.list_tag_keys.js | 72 - .../generated/v3/tag_keys.set_iam_policy.js | 74 - .../v3/tag_keys.test_iam_permissions.js | 67 - .../generated/v3/tag_keys.update_tag_key.js | 73 - .../v3/tag_values.create_tag_value.js | 65 - .../v3/tag_values.delete_tag_value.js | 69 - .../generated/v3/tag_values.get_iam_policy.js | 64 - .../generated/v3/tag_values.get_tag_value.js | 58 - .../v3/tag_values.list_tag_values.js | 72 - .../generated/v3/tag_values.set_iam_policy.js | 74 - .../v3/tag_values.test_iam_permissions.js | 67 - .../v3/tag_values.update_tag_value.js | 71 - owl-bot-staging/v3/src/index.ts | 35 - owl-bot-staging/v3/src/v3/folders_client.ts | 1844 --------------- .../v3/src/v3/folders_client_config.json | 83 - .../v3/src/v3/folders_proto_list.json | 8 - owl-bot-staging/v3/src/v3/gapic_metadata.json | 585 ----- owl-bot-staging/v3/src/v3/index.ts | 24 - .../v3/src/v3/organizations_client.ts | 1013 -------- .../src/v3/organizations_client_config.json | 53 - .../v3/src/v3/organizations_proto_list.json | 8 - owl-bot-staging/v3/src/v3/projects_client.ts | 1896 --------------- .../v3/src/v3/projects_client_config.json | 83 - .../v3/src/v3/projects_proto_list.json | 8 - .../v3/src/v3/tag_bindings_client.ts | 867 ------- .../v3/src/v3/tag_bindings_client_config.json | 44 - .../v3/src/v3/tag_bindings_proto_list.json | 8 - owl-bot-staging/v3/src/v3/tag_keys_client.ts | 1299 ----------- .../v3/src/v3/tag_keys_client_config.json | 68 - .../v3/src/v3/tag_keys_proto_list.json | 8 - .../v3/src/v3/tag_values_client.ts | 1295 ----------- .../v3/src/v3/tag_values_client_config.json | 68 - .../v3/src/v3/tag_values_proto_list.json | 8 - .../system-test/fixtures/sample/src/index.js | 32 - .../system-test/fixtures/sample/src/index.ts | 62 - owl-bot-staging/v3/system-test/install.ts | 49 - owl-bot-staging/v3/test/gapic_folders_v3.ts | 1803 -------------- .../v3/test/gapic_organizations_v3.ts | 924 -------- owl-bot-staging/v3/test/gapic_projects_v3.ts | 1803 -------------- .../v3/test/gapic_tag_bindings_v3.ts | 808 ------- owl-bot-staging/v3/test/gapic_tag_keys_v3.ts | 1344 ----------- .../v3/test/gapic_tag_values_v3.ts | 1344 ----------- owl-bot-staging/v3/tsconfig.json | 19 - owl-bot-staging/v3/webpack.config.js | 64 - src/v3/folders_client.ts | 32 +- src/v3/organizations_client.ts | 11 +- src/v3/projects_client.ts | 32 +- src/v3/tag_bindings_client.ts | 32 +- src/v3/tag_keys_client.ts | 32 +- src/v3/tag_values_client.ts | 32 +- 100 files changed, 105 insertions(+), 25235 deletions(-) delete mode 100644 owl-bot-staging/v3/.eslintignore delete mode 100644 owl-bot-staging/v3/.eslintrc.json delete mode 100644 owl-bot-staging/v3/.gitignore delete mode 100644 owl-bot-staging/v3/.jsdoc.js delete mode 100644 owl-bot-staging/v3/.mocharc.js delete mode 100644 owl-bot-staging/v3/.prettierrc.js delete mode 100644 owl-bot-staging/v3/README.md delete mode 100644 owl-bot-staging/v3/linkinator.config.json delete mode 100644 owl-bot-staging/v3/package.json delete mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/folders.proto delete mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/organizations.proto delete mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/projects.proto delete mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto delete mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto delete mode 100644 owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.create_folder.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.delete_folder.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.get_folder.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.get_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.list_folders.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.move_folder.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.search_folders.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.set_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.test_iam_permissions.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.undelete_folder.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/folders.update_folder.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.get_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.get_organization.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.search_organizations.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.set_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/organizations.test_iam_permissions.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.create_project.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.delete_project.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.get_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.get_project.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.list_projects.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.move_project.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.search_projects.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.set_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.test_iam_permissions.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.undelete_project.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/projects.update_project.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/snippet_metadata.google.cloud.resourcemanager.v3.json delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_bindings.create_tag_binding.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.create_tag_key.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.delete_tag_key.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.get_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.get_tag_key.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.list_tag_keys.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.set_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.test_iam_permissions.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_keys.update_tag_key.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.create_tag_value.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.delete_tag_value.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.get_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.get_tag_value.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.list_tag_values.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.set_iam_policy.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.test_iam_permissions.js delete mode 100644 owl-bot-staging/v3/samples/generated/v3/tag_values.update_tag_value.js delete mode 100644 owl-bot-staging/v3/src/index.ts delete mode 100644 owl-bot-staging/v3/src/v3/folders_client.ts delete mode 100644 owl-bot-staging/v3/src/v3/folders_client_config.json delete mode 100644 owl-bot-staging/v3/src/v3/folders_proto_list.json delete mode 100644 owl-bot-staging/v3/src/v3/gapic_metadata.json delete mode 100644 owl-bot-staging/v3/src/v3/index.ts delete mode 100644 owl-bot-staging/v3/src/v3/organizations_client.ts delete mode 100644 owl-bot-staging/v3/src/v3/organizations_client_config.json delete mode 100644 owl-bot-staging/v3/src/v3/organizations_proto_list.json delete mode 100644 owl-bot-staging/v3/src/v3/projects_client.ts delete mode 100644 owl-bot-staging/v3/src/v3/projects_client_config.json delete mode 100644 owl-bot-staging/v3/src/v3/projects_proto_list.json delete mode 100644 owl-bot-staging/v3/src/v3/tag_bindings_client.ts delete mode 100644 owl-bot-staging/v3/src/v3/tag_bindings_client_config.json delete mode 100644 owl-bot-staging/v3/src/v3/tag_bindings_proto_list.json delete mode 100644 owl-bot-staging/v3/src/v3/tag_keys_client.ts delete mode 100644 owl-bot-staging/v3/src/v3/tag_keys_client_config.json delete mode 100644 owl-bot-staging/v3/src/v3/tag_keys_proto_list.json delete mode 100644 owl-bot-staging/v3/src/v3/tag_values_client.ts delete mode 100644 owl-bot-staging/v3/src/v3/tag_values_client_config.json delete mode 100644 owl-bot-staging/v3/src/v3/tag_values_proto_list.json delete mode 100644 owl-bot-staging/v3/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v3/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v3/system-test/install.ts delete mode 100644 owl-bot-staging/v3/test/gapic_folders_v3.ts delete mode 100644 owl-bot-staging/v3/test/gapic_organizations_v3.ts delete mode 100644 owl-bot-staging/v3/test/gapic_projects_v3.ts delete mode 100644 owl-bot-staging/v3/test/gapic_tag_bindings_v3.ts delete mode 100644 owl-bot-staging/v3/test/gapic_tag_keys_v3.ts delete mode 100644 owl-bot-staging/v3/test/gapic_tag_values_v3.ts delete mode 100644 owl-bot-staging/v3/tsconfig.json delete mode 100644 owl-bot-staging/v3/webpack.config.js diff --git a/owl-bot-staging/v3/.eslintignore b/owl-bot-staging/v3/.eslintignore deleted file mode 100644 index cfc348e..0000000 --- a/owl-bot-staging/v3/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v3/.eslintrc.json b/owl-bot-staging/v3/.eslintrc.json deleted file mode 100644 index 7821534..0000000 --- a/owl-bot-staging/v3/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v3/.gitignore b/owl-bot-staging/v3/.gitignore deleted file mode 100644 index 5d32b23..0000000 --- a/owl-bot-staging/v3/.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/v3/.jsdoc.js b/owl-bot-staging/v3/.jsdoc.js deleted file mode 100644 index ccd2dc4..0000000 --- a/owl-bot-staging/v3/.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/resource-manager', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v3/.mocharc.js b/owl-bot-staging/v3/.mocharc.js deleted file mode 100644 index 481c522..0000000 --- a/owl-bot-staging/v3/.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/v3/.prettierrc.js b/owl-bot-staging/v3/.prettierrc.js deleted file mode 100644 index 494e147..0000000 --- a/owl-bot-staging/v3/.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/v3/README.md b/owl-bot-staging/v3/README.md deleted file mode 100644 index 3dd631a..0000000 --- a/owl-bot-staging/v3/README.md +++ /dev/null @@ -1 +0,0 @@ -Resourcemanager: Nodejs Client diff --git a/owl-bot-staging/v3/linkinator.config.json b/owl-bot-staging/v3/linkinator.config.json deleted file mode 100644 index befd23c..0000000 --- a/owl-bot-staging/v3/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/v3/package.json b/owl-bot-staging/v3/package.json deleted file mode 100644 index a440e2a..0000000 --- a/owl-bot-staging/v3/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@google-cloud/resource-manager", - "version": "0.1.0", - "description": "Resourcemanager client for Node.js", - "repository": "googleapis/nodejs-resourcemanager", - "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 resourcemanager", - "resourcemanager", - "folders", - "organizations", - "projects", - "tag bindings", - "tag keys", - "tag values" - ], - "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/v3/protos/google/cloud/resourcemanager/v3/folders.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/folders.proto deleted file mode 100644 index af87809..0000000 --- a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/folders.proto +++ /dev/null @@ -1,536 +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 -// -// 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.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; -option java_multiple_files = true; -option java_outer_classname = "FoldersProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Manages Cloud Platform folder resources. -// Folders can be used to organize the resources under an -// organization and to control the policies applied to groups of resources. -service Folders { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Retrieves a folder identified by the supplied resource name. - // Valid folder resource names have the format `folders/{folder_id}` - // (for example, `folders/1234`). - // The caller must have `resourcemanager.folders.get` permission on the - // identified folder. - rpc GetFolder(GetFolderRequest) returns (Folder) { - option (google.api.http) = { - get: "/v3/{name=folders/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists the folders that are direct descendants of supplied parent resource. - // `list()` provides a strongly consistent view of the folders underneath - // the specified parent resource. - // `list()` returns folders sorted based upon the (ascending) lexical ordering - // of their display_name. - // The caller must have `resourcemanager.folders.list` permission on the - // identified parent. - rpc ListFolders(ListFoldersRequest) returns (ListFoldersResponse) { - option (google.api.http) = { - get: "/v3/folders" - }; - option (google.api.method_signature) = "parent"; - } - - // Search for folders that match specific filter criteria. - // `search()` provides an eventually consistent view of the folders a user has - // access to which meet the specified filter criteria. - // - // This will only return folders on which the caller has the - // permission `resourcemanager.folders.get`. - rpc SearchFolders(SearchFoldersRequest) returns (SearchFoldersResponse) { - option (google.api.http) = { - get: "/v3/folders:search" - }; - option (google.api.method_signature) = "query"; - } - - // Creates a folder in the resource hierarchy. - // Returns an `Operation` which can be used to track the progress of the - // folder creation workflow. - // Upon success, the `Operation.response` field will be populated with the - // created Folder. - // - // In order to succeed, the addition of this new folder must not violate - // the folder naming, height, or fanout constraints. - // - // + The folder's `display_name` must be distinct from all other folders that - // share its parent. - // + The addition of the folder must not cause the active folder hierarchy - // to exceed a height of 10. Note, the full active + deleted folder hierarchy - // is allowed to reach a height of 20; this provides additional headroom when - // moving folders that contain deleted folders. - // + The addition of the folder must not cause the total number of folders - // under its parent to exceed 300. - // - // If the operation fails due to a folder constraint violation, some errors - // may be returned by the `CreateFolder` request, with status code - // `FAILED_PRECONDITION` and an error description. Other folder constraint - // violations will be communicated in the `Operation`, with the specific - // `PreconditionFailure` returned in the details list in the `Operation.error` - // field. - // - // The caller must have `resourcemanager.folders.create` permission on the - // identified parent. - rpc CreateFolder(CreateFolderRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/folders" - body: "folder" - }; - option (google.api.method_signature) = "folder"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "CreateFolderMetadata" - }; - } - - // Updates a folder, changing its `display_name`. - // Changes to the folder `display_name` will be rejected if they violate - // either the `display_name` formatting rules or the naming constraints - // described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. - // - // The folder's `display_name` must start and end with a letter or digit, - // may contain letters, digits, spaces, hyphens and underscores and can be - // between 3 and 30 characters. This is captured by the regular expression: - // `[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]`. - // The caller must have `resourcemanager.folders.update` permission on the - // identified folder. - // - // If the update fails due to the unique name constraint then a - // `PreconditionFailure` explaining this violation will be returned - // in the Status.details field. - rpc UpdateFolder(UpdateFolderRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v3/{folder.name=folders/*}" - body: "folder" - }; - option (google.api.method_signature) = "folder,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "UpdateFolderMetadata" - }; - } - - // Moves a folder under a new resource parent. - // Returns an `Operation` which can be used to track the progress of the - // folder move workflow. - // Upon success, the `Operation.response` field will be populated with the - // moved folder. - // Upon failure, a `FolderOperationError` categorizing the failure cause will - // be returned - if the failure occurs synchronously then the - // `FolderOperationError` will be returned in the `Status.details` field. - // If it occurs asynchronously, then the FolderOperation will be returned - // in the `Operation.error` field. - // In addition, the `Operation.metadata` field will be populated with a - // `FolderOperation` message as an aid to stateless clients. - // Folder moves will be rejected if they violate either the naming, height, - // or fanout constraints described in the - // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. - // The caller must have `resourcemanager.folders.move` permission on the - // folder's current and proposed new parent. - rpc MoveFolder(MoveFolderRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/{name=folders/*}:move" - body: "*" - }; - option (google.api.method_signature) = "name,destination_parent"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "MoveFolderMetadata" - }; - } - - // Requests deletion of a folder. The folder is moved into the - // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state - // immediately, and is deleted approximately 30 days later. This method may - // only be called on an empty folder, where a folder is empty if it doesn't - // contain any folders or projects in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. - // If called on a folder in [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] - // state the operation will result in a no-op success. - // The caller must have `resourcemanager.folders.delete` permission on the - // identified folder. - rpc DeleteFolder(DeleteFolderRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=folders/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "DeleteFolderMetadata" - }; - } - - // Cancels the deletion request for a folder. This method may be called on a - // folder in any state. If the folder is in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] - // state the result will be a no-op success. In order to succeed, the folder's - // parent must be in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In addition, - // reintroducing the folder into the tree must not violate folder naming, - // height, and fanout constraints described in the - // [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. - // The caller must have `resourcemanager.folders.undelete` permission on the - // identified folder. - rpc UndeleteFolder(UndeleteFolderRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/{name=folders/*}:undelete" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Folder" - metadata_type: "UndeleteFolderMetadata" - }; - } - - // Gets the access control policy for a folder. The returned policy may be - // empty if no such policy or resource exists. The `resource` field should - // be the folder's resource name, for example: "folders/1234". - // The caller must have `resourcemanager.folders.getIamPolicy` permission - // on the identified folder. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=folders/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy on a folder, replacing any existing policy. - // The `resource` field should be the folder's resource name, for example: - // "folders/1234". - // The caller must have `resourcemanager.folders.setIamPolicy` permission - // on the identified folder. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=folders/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Returns permissions that a caller has on the specified folder. - // The `resource` field should be the folder's resource name, - // for example: "folders/1234". - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=folders/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// A folder in an organization's resource hierarchy, used to -// organize that organization's resources. -message Folder { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/Folder" - pattern: "folders/{folder}" - style: DECLARATIVE_FRIENDLY - }; - - // Folder lifecycle states. - enum State { - // Unspecified state. - STATE_UNSPECIFIED = 0; - - // The normal and active state. - ACTIVE = 1; - - // The folder has been marked for deletion by the user. - DELETE_REQUESTED = 2; - } - - // Output only. The resource name of the folder. - // Its format is `folders/{folder_id}`, for example: "folders/1234". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The folder's parent's resource name. - // Updates to the folder's parent must be performed using - // [MoveFolder][google.cloud.resourcemanager.v3.Folders.MoveFolder]. - string parent = 2 [(google.api.field_behavior) = REQUIRED]; - - // The folder's display name. - // A folder's display name must be unique amongst its siblings. For example, - // no two folders with the same parent can share the same display name. - // The display name must start and end with a letter or digit, may contain - // letters, digits, spaces, hyphens and underscores and can be no longer - // than 30 characters. This is captured by the regular expression: - // `[\p{L}\p{N}]([\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?`. - string display_name = 3; - - // Output only. The lifecycle state of the folder. - // Updates to the state must be performed using - // [DeleteFolder][google.cloud.resourcemanager.v3.Folders.DeleteFolder] and - // [UndeleteFolder][google.cloud.resourcemanager.v3.Folders.UndeleteFolder]. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the folder was created. - google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the folder was last modified. - google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the folder was requested to be deleted. - google.protobuf.Timestamp delete_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A checksum computed by the server based on the current value of the folder - // resource. This may be sent on update and delete requests to ensure the - // client has an up-to-date value before proceeding. - string etag = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The GetFolder request message. -message GetFolderRequest { - // Required. The resource name of the folder to retrieve. - // Must be of the form `folders/{folder_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Folder" - } - ]; -} - -// The ListFolders request message. -message ListFoldersRequest { - // Required. The resource name of the organization or folder whose folders are - // being listed. - // Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - // Access to this method is controlled by checking the - // `resourcemanager.folders.list` permission on the `parent`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "*" - } - ]; - - // Optional. The maximum number of folders to return in the response. - // If unspecified, server picks an appropriate default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `ListFolders` - // that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Controls whether folders in the - // [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] - // state should be returned. Defaults to false. - bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// The ListFolders response message. -message ListFoldersResponse { - // A possibly paginated list of folders that are direct descendants of - // the specified parent resource. - repeated Folder folders = 1; - - // A pagination token returned from a previous call to `ListFolders` - // that indicates from where listing should continue. - string next_page_token = 2; -} - -// The request message for searching folders. -message SearchFoldersRequest { - // Optional. The maximum number of folders to return in the response. - // If unspecified, server picks an appropriate default. - int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `SearchFolders` - // that indicates from where search should continue. - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Search criteria used to select the folders to return. - // If no search criteria is specified then all accessible folders will be - // returned. - // - // Query expressions can be used to restrict results based upon displayName, - // state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - // can be used along with the suffix wildcard symbol `*`. - // - // The `displayName` field in a query expression should use escaped quotes - // for values that include whitespace to prevent unexpected behavior. - // - // ``` - // | Field | Description | - // |-------------------------|----------------------------------------| - // | displayName | Filters by displayName. | - // | parent | Filters by parent (for example: folders/123). | - // | state, lifecycleState | Filters by state. | - // ``` - // - // Some example queries are: - // - // * Query `displayName=Test*` returns Folder resources whose display name - // starts with "Test". - // * Query `state=ACTIVE` returns Folder resources with - // `state` set to `ACTIVE`. - // * Query `parent=folders/123` returns Folder resources that have - // `folders/123` as a parent resource. - // * Query `parent=folders/123 AND state=ACTIVE` returns active - // Folder resources that have `folders/123` as a parent resource. - // * Query `displayName=\\"Test String\\"` returns Folder resources with - // display names that include both "Test" and "String". - string query = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response message for searching folders. -message SearchFoldersResponse { - // A possibly paginated folder search results. - // the specified parent resource. - repeated Folder folders = 1; - - // A pagination token returned from a previous call to `SearchFolders` - // that indicates from where searching should continue. - string next_page_token = 2; -} - -// The CreateFolder request message. -message CreateFolderRequest { - // Required. The folder being created, only the display name and parent will be - // consulted. All other fields will be ignored. - Folder folder = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Metadata pertaining to the Folder creation process. -message CreateFolderMetadata { - // The display name of the folder. - string display_name = 1; - - // The resource name of the folder or organization we are creating the folder - // under. - string parent = 2; -} - -// The request sent to the -// [UpdateFolder][google.cloud.resourcemanager.v3.Folder.UpdateFolder] -// method. -// -// Only the `display_name` field can be changed. All other fields will be -// ignored. Use the -// [MoveFolder][google.cloud.resourcemanager.v3.Folders.MoveFolder] method to -// change the `parent` field. -message UpdateFolderRequest { - // Required. The new definition of the Folder. It must include the `name` field, which - // cannot be changed. - Folder folder = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Fields to be updated. - // Only the `display_name` can be updated. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by UpdateFolder. -message UpdateFolderMetadata { - -} - -// The MoveFolder request message. -message MoveFolderRequest { - // Required. The resource name of the Folder to move. - // Must be of the form folders/{folder_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Folder" - } - ]; - - // Required. The resource name of the folder or organization which should be the - // folder's new parent. - // Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - string destination_parent = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "*" - } - ]; -} - -// Metadata pertaining to the folder move process. -message MoveFolderMetadata { - // The display name of the folder. - string display_name = 1; - - // The resource name of the folder's parent. - string source_parent = 2; - - // The resource name of the folder or organization to move the folder to. - string destination_parent = 3; -} - -// The DeleteFolder request message. -message DeleteFolderRequest { - // Required. The resource name of the folder to be deleted. - // Must be of the form `folders/{folder_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Folder" - } - ]; -} - -// A status object which is used as the `metadata` field for the `Operation` -// returned by `DeleteFolder`. -message DeleteFolderMetadata { - -} - -// The UndeleteFolder request message. -message UndeleteFolderRequest { - // Required. The resource name of the folder to undelete. - // Must be of the form `folders/{folder_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Folder" - } - ]; -} - -// A status object which is used as the `metadata` field for the `Operation` -// returned by `UndeleteFolder`. -message UndeleteFolderMetadata { - -} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/organizations.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/organizations.proto deleted file mode 100644 index 0474ca2..0000000 --- a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/organizations.proto +++ /dev/null @@ -1,237 +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 -// -// 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.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; -option java_multiple_files = true; -option java_outer_classname = "OrganizationsProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Allows users to manage their organization resources. -service Organizations { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Fetches an organization resource identified by the specified resource name. - rpc GetOrganization(GetOrganizationRequest) returns (Organization) { - option (google.api.http) = { - get: "/v3/{name=organizations/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Searches organization resources that are visible to the user and satisfy - // the specified filter. This method returns organizations in an unspecified - // order. New organizations do not necessarily appear at the end of the - // results, and may take a small amount of time to appear. - // - // Search will only return organizations on which the user has the permission - // `resourcemanager.organizations.get` - rpc SearchOrganizations(SearchOrganizationsRequest) returns (SearchOrganizationsResponse) { - option (google.api.http) = { - get: "/v3/organizations:search" - }; - option (google.api.method_signature) = "query"; - } - - // Gets the access control policy for an organization resource. The policy may - // be empty if no such policy or resource exists. The `resource` field should - // be the organization's resource name, for example: "organizations/123". - // - // Authorization requires the IAM permission - // `resourcemanager.organizations.getIamPolicy` on the specified organization. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=organizations/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy on an organization resource. Replaces any - // existing policy. The `resource` field should be the organization's resource - // name, for example: "organizations/123". - // - // Authorization requires the IAM permission - // `resourcemanager.organizations.setIamPolicy` on the specified organization. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=organizations/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Returns the permissions that a caller has on the specified organization. - // The `resource` field should be the organization's resource name, - // for example: "organizations/123". - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=organizations/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// The root node in the resource hierarchy to which a particular entity's -// (a company, for example) resources belong. -message Organization { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/Organization" - pattern: "organizations/{organization}" - style: DECLARATIVE_FRIENDLY - }; - - // Organization lifecycle states. - enum State { - // Unspecified state. This is only useful for distinguishing unset values. - STATE_UNSPECIFIED = 0; - - // The normal and active state. - ACTIVE = 1; - - // The organization has been marked for deletion by the user. - DELETE_REQUESTED = 2; - } - - // Output only. The resource name of the organization. This is the - // organization's relative path in the API. Its format is - // "organizations/[organization_id]". For example, "organizations/1234". - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A human-readable string that refers to the organization in the - // Google Cloud Console. This string is set by the server and cannot be - // changed. The string will be set to the primary domain (for example, - // "google.com") of the Google Workspace customer that owns the organization. - string display_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The owner of this organization. The owner should be specified on - // creation. Once set, it cannot be changed. - // - // The lifetime of the organization and all of its descendants are bound to - // the owner. If the owner is deleted, the organization and all its - // descendants will be deleted. - oneof owner { - // Immutable. The G Suite / Workspace customer id used in the Directory API. - string directory_customer_id = 3 [(google.api.field_behavior) = IMMUTABLE]; - } - - // Output only. The organization's current lifecycle state. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the Organization was created. - google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the Organization was last modified. - google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp when the Organization was requested for deletion. - google.protobuf.Timestamp delete_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A checksum computed by the server based on the current value of the - // Organization resource. This may be sent on update and delete requests to - // ensure the client has an up-to-date value before proceeding. - string etag = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// The request sent to the `GetOrganization` method. The `name` field is -// required. `organization_id` is no longer accepted. -message GetOrganizationRequest { - // Required. The resource name of the Organization to fetch. This is the organization's - // relative path in the API, formatted as "organizations/[organizationId]". - // For example, "organizations/1234". - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Organization" - } - ]; -} - -// The request sent to the `SearchOrganizations` method. -message SearchOrganizationsRequest { - // Optional. The maximum number of organizations to return in the response. - // If unspecified, server picks an appropriate default. - int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `SearchOrganizations` - // that indicates from where listing should continue. - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. An optional query string used to filter the Organizations to return in - // the response. Query rules are case-insensitive. - // - // ``` - // | Field | Description | - // |------------------|--------------------------------------------| - // | directoryCustomerId, owner.directoryCustomerId | Filters by directory - // customer id. | - // | domain | Filters by domain. | - // ``` - // - // Organizations may be queried by `directoryCustomerId` or by - // `domain`, where the domain is a G Suite domain, for example: - // - // * Query `directorycustomerid:123456789` returns Organization - // resources with `owner.directory_customer_id` equal to `123456789`. - // * Query `domain:google.com` returns Organization resources corresponding - // to the domain `google.com`. - string query = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response returned from the `SearchOrganizations` method. -message SearchOrganizationsResponse { - // The list of Organizations that matched the search query, possibly - // paginated. - repeated Organization organizations = 1; - - // A pagination token to be used to retrieve the next page of results. If the - // result is too large to fit within the page size specified in the request, - // this field will be set with a token that can be used to fetch the next page - // of results. If this field is empty, it indicates that this response - // contains the last page of results. - string next_page_token = 2; -} - -// A status object which is used as the `metadata` field for the operation -// returned by DeleteOrganization. -message DeleteOrganizationMetadata { - -} - -// A status object which is used as the `metadata` field for the Operation -// returned by UndeleteOrganization. -message UndeleteOrganizationMetadata { - -} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/projects.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/projects.proto deleted file mode 100644 index 3d2feb0..0000000 --- a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/projects.proto +++ /dev/null @@ -1,640 +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 -// -// 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.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; -option java_multiple_files = true; -option java_outer_classname = "ProjectsProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Manages Google Cloud Projects. -service Projects { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Retrieves the project identified by the specified `name` (for example, - // `projects/415104041262`). - // - // The caller must have `resourcemanager.projects.get` permission - // for this project. - rpc GetProject(GetProjectRequest) returns (Project) { - option (google.api.http) = { - get: "/v3/{name=projects/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists projects that are direct children of the specified folder or - // organization resource. `list()` provides a strongly consistent view of the - // projects underneath the specified parent resource. `list()` returns - // projects sorted based upon the (ascending) lexical ordering of their - // `display_name`. The caller must have `resourcemanager.projects.list` - // permission on the identified parent. - rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse) { - option (google.api.http) = { - get: "/v3/projects" - }; - option (google.api.method_signature) = "parent"; - } - - // Search for projects that the caller has both `resourcemanager.projects.get` - // permission on, and also satisfy the specified query. - // - // This method returns projects in an unspecified order. - // - // This method is eventually consistent with project mutations; this means - // that a newly created project may not appear in the results or recent - // updates to an existing project may not be reflected in the results. To - // retrieve the latest state of a project, use the - // [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method. - rpc SearchProjects(SearchProjectsRequest) returns (SearchProjectsResponse) { - option (google.api.http) = { - get: "/v3/projects:search" - }; - option (google.api.method_signature) = "query"; - } - - // Request that a new project be created. The result is an `Operation` which - // can be used to track the creation process. This process usually takes a few - // seconds, but can sometimes take much longer. The tracking `Operation` is - // automatically deleted after a few hours, so there is no need to call - // `DeleteOperation`. - rpc CreateProject(CreateProjectRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/projects" - body: "project" - }; - option (google.api.method_signature) = "project"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "CreateProjectMetadata" - }; - } - - // Updates the `display_name` and labels of the project identified by the - // specified `name` (for example, `projects/415104041262`). Deleting all - // labels requires an update mask for labels field. - // - // The caller must have `resourcemanager.projects.update` permission for this - // project. - rpc UpdateProject(UpdateProjectRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v3/{project.name=projects/*}" - body: "project" - }; - option (google.api.method_signature) = "project,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "UpdateProjectMetadata" - }; - } - - // Move a project to another place in your resource hierarchy, under a new - // resource parent. - // - // Returns an operation which can be used to track the process of the project - // move workflow. - // Upon success, the `Operation.response` field will be populated with the - // moved project. - // - // The caller must have `resourcemanager.projects.update` permission on the - // project and have `resourcemanager.projects.move` permission on the - // project's current and proposed new parent. - // - // - rpc MoveProject(MoveProjectRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/{name=projects/*}:move" - body: "*" - }; - option (google.api.method_signature) = "name, destination_parent"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "MoveProjectMetadata" - }; - } - - // Marks the project identified by the specified - // `name` (for example, `projects/415104041262`) for deletion. - // - // This method will only affect the project if it has a lifecycle state of - // [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. - // - // This method changes the Project's lifecycle state from - // [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] - // to [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. - // The deletion starts at an unspecified time, - // at which point the Project is no longer accessible. - // - // Until the deletion completes, you can check the lifecycle state - // checked by retrieving the project with [GetProject] - // [google.cloud.resourcemanager.v3.Projects.GetProject], - // and the project remains visible to [ListProjects] - // [google.cloud.resourcemanager.v3.Projects.ListProjects]. - // However, you cannot update the project. - // - // After the deletion completes, the project is not retrievable by - // the [GetProject] - // [google.cloud.resourcemanager.v3.Projects.GetProject], - // [ListProjects] - // [google.cloud.resourcemanager.v3.Projects.ListProjects], and - // [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] - // methods. - // - // This method behaves idempotently, such that deleting a `DELETE_REQUESTED` - // project will not cause an error, but also won't do anything. - // - // The caller must have `resourcemanager.projects.delete` permissions for this - // project. - rpc DeleteProject(DeleteProjectRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=projects/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "DeleteProjectMetadata" - }; - } - - // Restores the project identified by the specified - // `name` (for example, `projects/415104041262`). - // You can only use this method for a project that has a lifecycle state of - // [DELETE_REQUESTED] - // [Projects.State.DELETE_REQUESTED]. - // After deletion starts, the project cannot be restored. - // - // The caller must have `resourcemanager.projects.undelete` permission for - // this project. - rpc UndeleteProject(UndeleteProjectRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/{name=projects/*}:undelete" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "Project" - metadata_type: "UndeleteProjectMetadata" - }; - } - - // Returns the IAM access control policy for the specified project. - // Permission is denied if the policy or the resource do not exist. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=projects/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the IAM access control policy for the specified project. - // - // CAUTION: This method will replace the existing policy, and cannot be used - // to append additional IAM settings. - // - // Note: Removing service accounts from policies or changing their roles can - // render services completely inoperable. It is important to understand how - // the service account is being used before removing or updating its roles. - // - // The following constraints apply when using `setIamPolicy()`: - // - // + Project does not support `allUsers` and `allAuthenticatedUsers` as - // `members` in a `Binding` of a `Policy`. - // - // + The owner role can be granted to a `user`, `serviceAccount`, or a group - // that is part of an organization. For example, - // group@myownpersonaldomain.com could be added as an owner to a project in - // the myownpersonaldomain.com organization, but not the examplepetstore.com - // organization. - // - // + Service accounts can be made owners of a project directly - // without any restrictions. However, to be added as an owner, a user must be - // invited using the Cloud Platform console and must accept the invitation. - // - // + A user cannot be granted the owner role using `setIamPolicy()`. The user - // must be granted the owner role using the Cloud Platform Console and must - // explicitly accept the invitation. - // - // + Invitations to grant the owner role cannot be sent using - // `setIamPolicy()`; - // they must be sent only using the Cloud Platform Console. - // - // + Membership changes that leave the project without any owners that have - // accepted the Terms of Service (ToS) will be rejected. - // - // + If the project is not part of an organization, there must be at least - // one owner who has accepted the Terms of Service (ToS) agreement in the - // policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner - // from the policy will fail. This restriction also applies to legacy - // projects that no longer have owners who have accepted the ToS. Edits to - // IAM policies will be rejected until the lack of a ToS-accepting owner is - // rectified. - // - // + Calling this method requires enabling the App Engine Admin API. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=projects/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource, policy"; - } - - // Returns permissions that a caller has on the specified project. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=projects/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource, permissions"; - } -} - -// A project is a high-level Google Cloud entity. It is a -// container for ACLs, APIs, App Engine Apps, VMs, and other -// Google Cloud Platform resources. -message Project { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/Project" - pattern: "projects/{project}" - style: DECLARATIVE_FRIENDLY - }; - - // Project lifecycle states. - enum State { - // Unspecified state. This is only used/useful for distinguishing - // unset values. - STATE_UNSPECIFIED = 0; - - // The normal and active state. - ACTIVE = 1; - - // The project has been marked for deletion by the user - // (by invoking - // [DeleteProject][google.cloud.resourcemanager.v3.Projects.DeleteProject]) - // or by the system (Google Cloud Platform). - // This can generally be reversed by invoking [UndeleteProject] - // [google.cloud.resourcemanager.v3.Projects.UndeleteProject]. - DELETE_REQUESTED = 2; - } - - // Output only. The unique resource name of the project. It is an int64 generated number - // prefixed by "projects/". - // - // Example: `projects/415104041262` - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. A reference to a parent Resource. eg., `organizations/123` or - // `folders/876`. - string parent = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Immutable. The unique, user-assigned id of the project. - // It must be 6 to 30 lowercase ASCII letters, digits, or hyphens. - // It must start with a letter. - // Trailing hyphens are prohibited. - // - // Example: `tokyo-rain-123` - string project_id = 3 [(google.api.field_behavior) = IMMUTABLE]; - - // Output only. The project lifecycle state. - State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. A user-assigned display name of the project. - // When present it must be between 4 to 30 characters. - // Allowed characters are: lowercase and uppercase letters, numbers, - // hyphen, single-quote, double-quote, space, and exclamation point. - // - // Example: `My Project` - string display_name = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Creation time. - google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The most recent time this resource was modified. - google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The time at which this resource was requested for deletion. - google.protobuf.Timestamp delete_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. A checksum computed by the server based on the current value of the Project - // resource. This may be sent on update and delete requests to ensure the - // client has an up-to-date value before proceeding. - string etag = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. The labels associated with this project. - // - // Label keys must be between 1 and 63 characters long and must conform - // to the following regular expression: \[a-z\](\[-a-z0-9\]*\[a-z0-9\])?. - // - // Label values must be between 0 and 63 characters long and must conform - // to the regular expression (\[a-z\](\[-a-z0-9\]*\[a-z0-9\])?)?. - // - // No more than 256 labels can be associated with a given resource. - // - // Clients should store labels in a representation such as JSON that does not - // depend on specific characters being disallowed. - // - // Example: `"myBusinessDimension" : "businessValue"` - map labels = 10 [(google.api.field_behavior) = OPTIONAL]; -} - -// The request sent to the -// [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] -// method. -message GetProjectRequest { - // Required. The name of the project (for example, `projects/415104041262`). - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; -} - -// The request sent to the -// [ListProjects][google.cloud.resourcemanager.v3.Projects.ListProjects] -// method. -message ListProjectsRequest { - // Required. The name of the parent resource to list projects under. - // - // For example, setting this field to 'folders/1234' would list all projects - // directly under that folder. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "*" - } - ]; - - // Optional. A pagination token returned from a previous call to [ListProjects] - // [google.cloud.resourcemanager.v3.Projects.ListProjects] - // that indicates from where listing should continue. - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maximum number of projects to return in the response. - // The server can return fewer projects than requested. - // If unspecified, server picks an appropriate default. - int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be - // returned. Normally only `ACTIVE` projects are returned. - bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL]; -} - -// A page of the response received from the -// [ListProjects][google.cloud.resourcemanager.v3.Projects.ListProjects] -// method. -// -// A paginated response where more pages are available has -// `next_page_token` set. This token can be used in a subsequent request to -// retrieve the next request page. -// -// NOTE: A response may contain fewer elements than the request `page_size` and -// still have a `next_page_token`. -message ListProjectsResponse { - // The list of Projects under the parent. This list can be paginated. - repeated Project projects = 1; - - // Pagination token. - // - // If the result set is too large to fit in a single response, this token - // is returned. It encodes the position of the current result cursor. - // Feeding this value into a new list request with the `page_token` parameter - // gives the next page of the results. - // - // When `next_page_token` is not filled in, there is no next page and - // the list returned is the last page in the result set. - // - // Pagination tokens have a limited lifetime. - string next_page_token = 2; -} - -// The request sent to the -// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] -// method. -message SearchProjectsRequest { - // Optional. A query string for searching for projects that the caller has - // `resourcemanager.projects.get` permission to. If multiple fields are - // included in the query, the it will return results that match any of the - // fields. Some eligible fields are: - // - // ``` - // | Field | Description | - // |-------------------------|----------------------------------------------| - // | displayName, name | Filters by displayName. | - // | parent | Project's parent. (for example: folders/123, - // organizations/*) Prefer parent field over parent.type and parent.id. | - // | parent.type | Parent's type: `folder` or `organization`. | - // | parent.id | Parent's id number (for example: 123) | - // | id, projectId | Filters by projectId. | - // | state, lifecycleState | Filters by state. | - // | labels | Filters by label name or value. | - // | labels. (where *key* is the name of a label) | Filters by label - // name. | - // ``` - // - // Search expressions are case insensitive. - // - // Some examples queries: - // - // ``` - // | Query | Description | - // |------------------|-----------------------------------------------------| - // | name:how* | The project's name starts with "how". | - // | name:Howl | The project's name is `Howl` or `howl`. | - // | name:HOWL | Equivalent to above. | - // | NAME:howl | Equivalent to above. | - // | labels.color:* | The project has the label `color`. | - // | labels.color:red | The project's label `color` has the value `red`. | - // | labels.color:red labels.size:big | The project's label `color` has - // the value `red` and its label `size` has the value `big`. | - // ``` - // - // If no query is specified, the call will return projects for which the user - // has the `resourcemanager.projects.get` permission. - string query = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to [ListProjects] - // [google.cloud.resourcemanager.v3.Projects.ListProjects] - // that indicates from where listing should continue. - string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The maximum number of projects to return in the response. - // The server can return fewer projects than requested. - // If unspecified, server picks an appropriate default. - int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// A page of the response received from the -// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] -// method. -// -// A paginated response where more pages are available has -// `next_page_token` set. This token can be used in a subsequent request to -// retrieve the next request page. -message SearchProjectsResponse { - // The list of Projects that matched the list filter query. This list can - // be paginated. - repeated Project projects = 1; - - // Pagination token. - // - // If the result set is too large to fit in a single response, this token - // is returned. It encodes the position of the current result cursor. - // Feeding this value into a new list request with the `page_token` parameter - // gives the next page of the results. - // - // When `next_page_token` is not filled in, there is no next page and - // the list returned is the last page in the result set. - // - // Pagination tokens have a limited lifetime. - string next_page_token = 2; -} - -// The request sent to the -// [CreateProject][google.cloud.resourcemanager.v3.Projects.CreateProject] -// method. -message CreateProjectRequest { - // Required. The Project to create. - // - // Project ID is required. If the requested ID is unavailable, the request - // fails. - // - // If the `parent` field is set, the `resourcemanager.projects.create` - // permission is checked on the parent resource. If no parent is set and - // the authorization credentials belong to an Organziation, the parent - // will be set to that Organization. - Project project = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by CreateProject. It provides insight for when significant phases of -// Project creation have completed. -message CreateProjectMetadata { - // Creation time of the project creation workflow. - google.protobuf.Timestamp create_time = 1; - - // True if the project can be retrieved using `GetProject`. No other - // operations on the project are guaranteed to work until the project creation - // is complete. - bool gettable = 2; - - // True if the project creation process is complete. - bool ready = 3; -} - -// The request sent to the -// [UpdateProject][google.cloud.resourcemanager.v3.Projects.UpdateProject] -// method. -// -// Only the `display_name` and `labels` fields can be change. Use the -// [MoveProject][google.cloud.resourcemanager.v3.Projects.MoveProject] method to -// change the `parent` field. -message UpdateProjectRequest { - // Required. The new definition of the project. - Project project = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. An update mask to selectively update fields. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by UpdateProject. -message UpdateProjectMetadata { - -} - -// The request sent to -// [MoveProject][google.cloud.resourcemanager.v3.Projects.MoveProject] -// method. -message MoveProjectRequest { - // Required. The name of the project to move. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. The new parent to move the Project under. - string destination_parent = 2 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "*" - } - ]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by MoveProject. -message MoveProjectMetadata { - -} - -// [DeleteProject][google.cloud.resourcemanager.v3.Projects.DeleteProject] -// method. -message DeleteProjectRequest { - // Required. The name of the Project (for example, `projects/415104041262`). - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by `DeleteProject`. -message DeleteProjectMetadata { - -} - -// The request sent to the [UndeleteProject] -// [google.cloud.resourcemanager.v3.Projects.UndeleteProject] -// method. -message UndeleteProjectRequest { - // Required. The name of the project (for example, `projects/415104041262`). - // - // Required. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; -} - -// A status object which is used as the `metadata` field for the Operation -// returned by `UndeleteProject`. -message UndeleteProjectMetadata { - -} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto deleted file mode 100644 index 6c8f260..0000000 --- a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_bindings.proto +++ /dev/null @@ -1,177 +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 -// -// 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.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; -option java_multiple_files = true; -option java_outer_classname = "TagBindingsProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Allow users to create and manage TagBindings between TagValues and -// different cloud resources throughout the GCP resource hierarchy. -service TagBindings { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Lists the TagBindings for the given cloud resource, as specified with - // `parent`. - // - // NOTE: The `parent` field is expected to be a full resource name: - // https://cloud.google.com/apis/design/resource_names#full_resource_name - rpc ListTagBindings(ListTagBindingsRequest) returns (ListTagBindingsResponse) { - option (google.api.http) = { - get: "/v3/tagBindings" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a TagBinding between a TagValue and a cloud resource - // (currently project, folder, or organization). - rpc CreateTagBinding(CreateTagBindingRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/tagBindings" - body: "tag_binding" - }; - option (google.api.method_signature) = "tag_binding"; - option (google.longrunning.operation_info) = { - response_type: "TagBinding" - metadata_type: "CreateTagBindingMetadata" - }; - } - - // Deletes a TagBinding. - rpc DeleteTagBinding(DeleteTagBindingRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=tagBindings/**}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.protobuf.Empty" - metadata_type: "DeleteTagBindingMetadata" - }; - } -} - -// A TagBinding represents a connection between a TagValue and a cloud -// resource (currently project, folder, or organization). Once a TagBinding is -// created, the TagValue is applied to all the descendants of the cloud -// resource. -message TagBinding { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/TagBinding" - pattern: "tagBindings/{tag_binding}" - }; - - // Output only. The name of the TagBinding. This is a String of the form: - // `tagBindings/{full-resource-name}/{tag-value-name}` (e.g. - // `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). - string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // The full resource name of the resource the TagValue is bound to. - // E.g. `//cloudresourcemanager.googleapis.com/projects/123` - string parent = 2; - - // The TagValue of the TagBinding. - // Must be of the form `tagValues/456`. - string tag_value = 3; -} - -// Runtime operation information for creating a TagValue. -message CreateTagBindingMetadata { - -} - -// The request message to create a TagBinding. -message CreateTagBindingRequest { - // Required. The TagBinding to be created. - TagBinding tag_binding = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Set to true to perform the validations necessary for creating the resource, - // but not actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for deleting a TagBinding. -message DeleteTagBindingMetadata { - -} - -// The request message to delete a TagBinding. -message DeleteTagBindingRequest { - // Required. The name of the TagBinding. This is a String of the form: - // `tagBindings/{id}` (e.g. - // `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagBinding" - } - ]; -} - -// The request message to list all TagBindings for a parent. -message ListTagBindingsRequest { - // Required. The full resource name of a resource for which you want to list existing - // TagBindings. - // E.g. "//cloudresourcemanager.googleapis.com/projects/123" - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "*" - } - ]; - - // Optional. The maximum number of TagBindings to return in the response. The server - // allows a maximum of 300 TagBindings to return. If unspecified, the server - // will use 100 as the default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `ListTagBindings` - // that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The ListTagBindings response. -message ListTagBindingsResponse { - // A possibly paginated list of TagBindings for the specified TagValue or - // resource. - repeated TagBinding tag_bindings = 1; - - // Pagination token. - // - // If the result set is too large to fit in a single response, this token - // is returned. It encodes the position of the current result cursor. - // Feeding this value into a new list request with the `page_token` parameter - // gives the next page of the results. - // - // When `next_page_token` is not filled in, there is no next page and - // the list returned is the last page in the result set. - // - // Pagination tokens have a limited lifetime. - string next_page_token = 2; -} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto deleted file mode 100644 index 5ecf0b4..0000000 --- a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_keys.proto +++ /dev/null @@ -1,300 +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 -// -// 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.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; -option java_multiple_files = true; -option java_outer_classname = "TagKeysProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Allow users to create and manage tag keys. -service TagKeys { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Lists all TagKeys for a parent resource. - rpc ListTagKeys(ListTagKeysRequest) returns (ListTagKeysResponse) { - option (google.api.http) = { - get: "/v3/tagKeys" - }; - option (google.api.method_signature) = "parent"; - } - - // Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the - // key does not exist or the user does not have permission to view it. - rpc GetTagKey(GetTagKeyRequest) returns (TagKey) { - option (google.api.http) = { - get: "/v3/{name=tagKeys/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a new TagKey. If another request with the same parameters is - // sent while the original request is in process, the second request - // will receive an error. A maximum of 300 TagKeys can exist under a parent at - // any given time. - rpc CreateTagKey(CreateTagKeyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/tagKeys" - body: "tag_key" - }; - option (google.api.method_signature) = "tag_key"; - option (google.longrunning.operation_info) = { - response_type: "TagKey" - metadata_type: "CreateTagKeyMetadata" - }; - } - - // Updates the attributes of the TagKey resource. - rpc UpdateTagKey(UpdateTagKeyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v3/{tag_key.name=tagKeys/*}" - body: "tag_key" - }; - option (google.api.method_signature) = "tag_key,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "TagKey" - metadata_type: "UpdateTagKeyMetadata" - }; - } - - // Deletes a TagKey. The TagKey cannot be deleted if it has any child - // TagValues. - rpc DeleteTagKey(DeleteTagKeyRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=tagKeys/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "TagKey" - metadata_type: "DeleteTagKeyMetadata" - }; - } - - // Gets the access control policy for a TagKey. The returned policy may be - // empty if no such policy or resource exists. The `resource` field should - // be the TagKey's resource name. For example, "tagKeys/1234". - // The caller must have - // `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on - // the specified TagKey. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=tagKeys/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy on a TagKey, replacing any existing - // policy. The `resource` field should be the TagKey's resource name. - // For example, "tagKeys/1234". - // The caller must have `resourcemanager.tagKeys.setIamPolicy` permission - // on the identified tagValue. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=tagKeys/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Returns permissions that a caller has on the specified TagKey. - // The `resource` field should be the TagKey's resource name. - // For example, "tagKeys/1234". - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=tagKeys/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// A TagKey, used to group a set of TagValues. -message TagKey { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/TagKey" - pattern: "tagKeys/{tag_key}" - style: DECLARATIVE_FRIENDLY - }; - - // Immutable. The resource name for a TagKey. Must be in the format - // `tagKeys/{tag_key_id}`, where `tag_key_id` is the generated numeric id for - // the TagKey. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The resource name of the new TagKey's parent. - // Must be of the form `organizations/{org_id}`. - string parent = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. Immutable. The user friendly name for a TagKey. The short name should be - // unique for TagKeys within the same tag namespace. - // - // The short name must be 1-63 characters, beginning and ending with - // an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), - // dots (.), and alphanumerics between. - string short_name = 3 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Output only. Immutable. Namespaced name of the TagKey. - string namespaced_name = 4 [ - (google.api.field_behavior) = OUTPUT_ONLY, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Optional. User-assigned description of the TagKey. Must not exceed 256 characters. - // - // Read-write. - string description = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Creation time. - google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Update time. - google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Entity tag which users can pass to prevent race conditions. This field is - // always set in server responses. See UpdateTagKeyRequest for details. - string etag = 8 [(google.api.field_behavior) = OPTIONAL]; -} - -// The request message for listing all TagKeys under a parent resource. -message ListTagKeysRequest { - // Required. The resource name of the new TagKey's parent. - // Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "*" - } - ]; - - // Optional. The maximum number of TagKeys to return in the response. The server allows - // a maximum of 300 TagKeys to return. If unspecified, the server will use 100 - // as the default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `ListTagKey` - // that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The ListTagKeys response message. -message ListTagKeysResponse { - // List of TagKeys that live under the specified parent in the request. - repeated TagKey tag_keys = 1; - - // A pagination token returned from a previous call to `ListTagKeys` - // that indicates from where listing should continue. - string next_page_token = 2; -} - -// The request message for getting a TagKey. -message GetTagKeyRequest { - // Required. A resource name in the format `tagKeys/{id}`, such as - // `tagKeys/123`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagKey" - } - ]; -} - -// The request message for creating a TagKey. -message CreateTagKeyRequest { - // Required. The TagKey to be created. Only fields `short_name`, `description`, - // and `parent` are considered during the creation request. - TagKey tag_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Set to true to perform validations necessary for creating the resource, but - // not actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for creating a TagKey. -message CreateTagKeyMetadata { - -} - -// The request message for updating a TagKey. -message UpdateTagKeyRequest { - // Required. The new definition of the TagKey. Only the `description` and `etag` fields - // can be updated by this request. If the `etag` field is not empty, it - // must match the `etag` field of the existing tag key. Otherwise, - // `FAILED_PRECONDITION` will be returned. - TagKey tag_key = 1 [(google.api.field_behavior) = REQUIRED]; - - // Fields to be updated. The mask may only contain `description` or - // `etag`. If omitted entirely, both `description` and `etag` are assumed to - // be significant. - google.protobuf.FieldMask update_mask = 2; - - // Set as true to perform validations necessary for updating the resource, but - // not actually perform the action. - bool validate_only = 3; -} - -// Runtime operation information for updating a TagKey. -message UpdateTagKeyMetadata { - -} - -// The request message for deleting a TagKey. -message DeleteTagKeyRequest { - // Required. The resource name of a TagKey to be deleted in the format `tagKeys/123`. - // The TagKey cannot be a parent of any existing TagValues or it will not be - // deleted successfully. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagKey" - } - ]; - - // Optional. Set as true to perform validations necessary for deletion, but not actually - // perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The etag known to the client for the expected state of the TagKey. This is - // to be used for optimistic concurrency. - string etag = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for deleting a TagKey. -message DeleteTagKeyMetadata { - -} diff --git a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto b/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto deleted file mode 100644 index 86ba701..0000000 --- a/owl-bot-staging/v3/protos/google/cloud/resourcemanager/v3/tag_values.proto +++ /dev/null @@ -1,296 +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 -// -// 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.cloud.resourcemanager.v3; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/field_mask.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.ResourceManager.V3"; -option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3;resourcemanager"; -option java_multiple_files = true; -option java_outer_classname = "TagValuesProto"; -option java_package = "com.google.cloud.resourcemanager.v3"; -option php_namespace = "Google\\Cloud\\ResourceManager\\V3"; -option ruby_package = "Google::Cloud::ResourceManager::V3"; - -// Allow users to create and manage tag values. -service TagValues { - option (google.api.default_host) = "cloudresourcemanager.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloud-platform.read-only"; - - // Lists all TagValues for a specific TagKey. - rpc ListTagValues(ListTagValuesRequest) returns (ListTagValuesResponse) { - option (google.api.http) = { - get: "/v3/tagValues" - }; - option (google.api.method_signature) = "parent"; - } - - // Retrieves TagValue. If the TagValue or namespaced name does not exist, or - // if the user does not have permission to view it, this method will return - // `PERMISSION_DENIED`. - rpc GetTagValue(GetTagValueRequest) returns (TagValue) { - option (google.api.http) = { - get: "/v3/{name=tagValues/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Creates a TagValue as a child of the specified TagKey. If a another - // request with the same parameters is sent while the original request is in - // process the second request will receive an error. A maximum of 300 - // TagValues can exist under a TagKey at any given time. - rpc CreateTagValue(CreateTagValueRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v3/tagValues" - body: "tag_value" - }; - option (google.api.method_signature) = "tag_value"; - option (google.longrunning.operation_info) = { - response_type: "TagValue" - metadata_type: "CreateTagValueMetadata" - }; - } - - // Updates the attributes of the TagValue resource. - rpc UpdateTagValue(UpdateTagValueRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - patch: "/v3/{tag_value.name=tagValues/*}" - body: "tag_value" - }; - option (google.api.method_signature) = "tag_value,update_mask"; - option (google.longrunning.operation_info) = { - response_type: "TagValue" - metadata_type: "UpdateTagValueMetadata" - }; - } - - // Deletes a TagValue. The TagValue cannot have any bindings when it is - // deleted. - rpc DeleteTagValue(DeleteTagValueRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - delete: "/v3/{name=tagValues/*}" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "TagValue" - metadata_type: "DeleteTagValueMetadata" - }; - } - - // Gets the access control policy for a TagValue. The returned policy may be - // empty if no such policy or resource exists. The `resource` field should - // be the TagValue's resource name. For example: `tagValues/1234`. - // The caller must have the - // `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on - // the identified TagValue to get the access control policy. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=tagValues/*}:getIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource"; - } - - // Sets the access control policy on a TagValue, replacing any existing - // policy. The `resource` field should be the TagValue's resource name. - // For example: `tagValues/1234`. - // The caller must have `resourcemanager.tagValues.setIamPolicy` permission - // on the identified tagValue. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v3/{resource=tagValues/*}:setIamPolicy" - body: "*" - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Returns permissions that a caller has on the specified TagValue. - // The `resource` field should be the TagValue's resource name. For example: - // `tagValues/1234`. - // - // There are no permissions required for making this API call. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v3/{resource=tagValues/*}:testIamPermissions" - body: "*" - }; - option (google.api.method_signature) = "resource,permissions"; - } -} - -// A TagValue is a child of a particular TagKey. This is used to group -// cloud resources for the purpose of controlling them using policies. -message TagValue { - option (google.api.resource) = { - type: "cloudresourcemanager.googleapis.com/TagValue" - pattern: "tagValues/{tag_value}" - style: DECLARATIVE_FRIENDLY - }; - - // Immutable. Resource name for TagValue in the format `tagValues/456`. - string name = 1 [(google.api.field_behavior) = IMMUTABLE]; - - // Immutable. The resource name of the new TagValue's parent TagKey. - // Must be of the form `tagKeys/{tag_key_id}`. - string parent = 2 [(google.api.field_behavior) = IMMUTABLE]; - - // Required. Immutable. User-assigned short name for TagValue. The short name should be - // unique for TagValues within the same parent TagKey. - // - // The short name must be 63 characters or less, beginning and ending with - // an alphanumeric character ([a-z0-9A-Z]) with dashes (-), underscores (_), - // dots (.), and alphanumerics between. - string short_name = 3 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // Output only. Namespaced name of the TagValue. Must be in the format - // `{organization_id}/{tag_key_short_name}/{short_name}`. - string namespaced_name = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. User-assigned description of the TagValue. - // Must not exceed 256 characters. - // - // Read-write. - string description = 5 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. Creation time. - google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Update time. - google.protobuf.Timestamp update_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. Entity tag which users can pass to prevent race conditions. This field is - // always set in server responses. See UpdateTagValueRequest for details. - string etag = 8 [(google.api.field_behavior) = OPTIONAL]; -} - -// The request message for listing TagValues for the specified TagKey. -message ListTagValuesRequest { - // Required. Resource name for TagKey, parent of the TagValues to be listed, - // in the format `tagKeys/123`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - child_type: "*" - } - ]; - - // Optional. The maximum number of TagValues to return in the response. The server - // allows a maximum of 300 TagValues to return. If unspecified, the server - // will use 100 as the default. - int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. A pagination token returned from a previous call to `ListTagValues` - // that indicates where this listing should continue from. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// The ListTagValues response. -message ListTagValuesResponse { - // A possibly paginated list of TagValues that are direct descendants of - // the specified parent TagKey. - repeated TagValue tag_values = 1; - - // A pagination token returned from a previous call to `ListTagValues` - // that indicates from where listing should continue. This is currently not - // used, but the server may at any point start supplying a valid token. - string next_page_token = 2; -} - -// The request message for getting a TagValue. -message GetTagValueRequest { - // Required. Resource name for TagValue to be fetched in the format `tagValues/456`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagValue" - } - ]; -} - -// The request message for creating a TagValue. -message CreateTagValueRequest { - // Required. The TagValue to be created. Only fields `short_name`, `description`, - // and `parent` are considered during the creation request. - TagValue tag_value = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Set as true to perform the validations necessary for creating the resource, - // but not actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for creating a TagValue. -message CreateTagValueMetadata { - -} - -// The request message for updating a TagValue. -message UpdateTagValueRequest { - // Required. The new definition of the TagValue. Only fields `description` and `etag` - // fields can be updated by this request. If the `etag` field is nonempty, it - // must match the `etag` field of the existing ControlGroup. Otherwise, - // `FAILED_PRECONDITION` will be returned. - TagValue tag_value = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Fields to be updated. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. True to perform validations necessary for updating the resource, but not - // actually perform the action. - bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for updating a TagValue. -message UpdateTagValueMetadata { - -} - -// The request message for deleting a TagValue. -message DeleteTagValueRequest { - // Required. Resource name for TagValue to be deleted in the format tagValues/456. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/TagValue" - } - ]; - - // Optional. Set as true to perform the validations necessary for deletion, but not - // actually perform the action. - bool validate_only = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The etag known to the client for the expected state of the TagValue. This - // is to be used for optimistic concurrency. - string etag = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Runtime operation information for deleting a TagValue. -message DeleteTagValueMetadata { - -} diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.create_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.create_folder.js deleted file mode 100644 index c243825..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.create_folder.js +++ /dev/null @@ -1,60 +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(folder) { - // [START cloudresourcemanager_v3_generated_Folders_CreateFolder_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The folder being created, only the display name and parent will be - * consulted. All other fields will be ignored. - */ - // const folder = {} - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callCreateFolder() { - // Construct request - const request = { - folder, - }; - - // Run request - const [operation] = await resourcemanagerClient.createFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateFolder(); - // [END cloudresourcemanager_v3_generated_Folders_CreateFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.delete_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.delete_folder.js deleted file mode 100644 index e6517a9..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.delete_folder.js +++ /dev/null @@ -1,60 +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(name) { - // [START cloudresourcemanager_v3_generated_Folders_DeleteFolder_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the folder to be deleted. - * Must be of the form `folders/{folder_id}`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callDeleteFolder() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteFolder(); - // [END cloudresourcemanager_v3_generated_Folders_DeleteFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.get_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.get_folder.js deleted file mode 100644 index a448f44..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.get_folder.js +++ /dev/null @@ -1,59 +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(name) { - // [START cloudresourcemanager_v3_generated_Folders_GetFolder_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the folder to retrieve. - * Must be of the form `folders/{folder_id}`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callGetFolder() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getFolder(request); - console.log(response); - } - - callGetFolder(); - // [END cloudresourcemanager_v3_generated_Folders_GetFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/folders.get_iam_policy.js deleted file mode 100644 index 049a601..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.list_folders.js b/owl-bot-staging/v3/samples/generated/v3/folders.list_folders.js deleted file mode 100644 index daf26e6..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.list_folders.js +++ /dev/null @@ -1,80 +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(parent) { - // [START cloudresourcemanager_v3_generated_Folders_ListFolders_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the organization or folder whose folders are - * being listed. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - * Access to this method is controlled by checking the - * `resourcemanager.folders.list` permission on the `parent`. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of folders to return in the response. - * If unspecified, server picks an appropriate default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to `ListFolders` - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - /** - * Optional. Controls whether folders in the - * DELETE_REQUESTED google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED - * state should be returned. Defaults to false. - */ - // const showDeleted = true - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callListFolders() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listFoldersAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListFolders(); - // [END cloudresourcemanager_v3_generated_Folders_ListFolders_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.move_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.move_folder.js deleted file mode 100644 index bd90af4..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.move_folder.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(name, destinationParent) { - // [START cloudresourcemanager_v3_generated_Folders_MoveFolder_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Folder to move. - * Must be of the form folders/{folder_id} - */ - // const name = 'abc123' - /** - * Required. The resource name of the folder or organization which should be the - * folder's new parent. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - */ - // const destinationParent = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callMoveFolder() { - // Construct request - const request = { - name, - destinationParent, - }; - - // Run request - const [operation] = await resourcemanagerClient.moveFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callMoveFolder(); - // [END cloudresourcemanager_v3_generated_Folders_MoveFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.search_folders.js b/owl-bot-staging/v3/samples/generated/v3/folders.search_folders.js deleted file mode 100644 index 5670775..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.search_folders.js +++ /dev/null @@ -1,94 +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 cloudresourcemanager_v3_generated_Folders_SearchFolders_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. The maximum number of folders to return in the response. - * If unspecified, server picks an appropriate default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to `SearchFolders` - * that indicates from where search should continue. - */ - // const pageToken = 'abc123' - /** - * Optional. Search criteria used to select the folders to return. - * If no search criteria is specified then all accessible folders will be - * returned. - * Query expressions can be used to restrict results based upon displayName, - * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - * can be used along with the suffix wildcard symbol `*`. - * The `displayName` field in a query expression should use escaped quotes - * for values that include whitespace to prevent unexpected behavior. - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------| - * | displayName | Filters by displayName. | - * | parent | Filters by parent (for example: folders/123). | - * | state, lifecycleState | Filters by state. | - * ``` - * Some example queries are: - * * Query `displayName=Test*` returns Folder resources whose display name - * starts with "Test". - * * Query `state=ACTIVE` returns Folder resources with - * `state` set to `ACTIVE`. - * * Query `parent=folders/123` returns Folder resources that have - * `folders/123` as a parent resource. - * * Query `parent=folders/123 AND state=ACTIVE` returns active - * Folder resources that have `folders/123` as a parent resource. - * * Query `displayName=\\"Test String\\"` returns Folder resources with - * display names that include both "Test" and "String". - */ - // const query = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callSearchFolders() { - // Construct request - const request = { - }; - - // Run request - const iterable = await resourcemanagerClient.searchFoldersAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchFolders(); - // [END cloudresourcemanager_v3_generated_Folders_SearchFolders_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/folders.set_iam_policy.js deleted file mode 100644 index 7d94806..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.set_iam_policy.js +++ /dev/null @@ -1,74 +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(resource, policy) { - // [START cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/folders.test_iam_permissions.js deleted file mode 100644 index c016fc1..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.undelete_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.undelete_folder.js deleted file mode 100644 index 1ecf3de..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.undelete_folder.js +++ /dev/null @@ -1,60 +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(name) { - // [START cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the folder to undelete. - * Must be of the form `folders/{folder_id}`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callUndeleteFolder() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.undeleteFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUndeleteFolder(); - // [END cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/folders.update_folder.js b/owl-bot-staging/v3/samples/generated/v3/folders.update_folder.js deleted file mode 100644 index b16522d..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/folders.update_folder.js +++ /dev/null @@ -1,66 +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(folder, updateMask) { - // [START cloudresourcemanager_v3_generated_Folders_UpdateFolder_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new definition of the Folder. It must include the `name` field, which - * cannot be changed. - */ - // const folder = {} - /** - * Required. Fields to be updated. - * Only the `display_name` can be updated. - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {FoldersClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new FoldersClient(); - - async function callUpdateFolder() { - // Construct request - const request = { - folder, - updateMask, - }; - - // Run request - const [operation] = await resourcemanagerClient.updateFolder(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateFolder(); - // [END cloudresourcemanager_v3_generated_Folders_UpdateFolder_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/organizations.get_iam_policy.js deleted file mode 100644 index fbcdf88..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/organizations.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.get_organization.js b/owl-bot-staging/v3/samples/generated/v3/organizations.get_organization.js deleted file mode 100644 index a520198..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/organizations.get_organization.js +++ /dev/null @@ -1,60 +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(name) { - // [START cloudresourcemanager_v3_generated_Organizations_GetOrganization_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Organization to fetch. This is the organization's - * relative path in the API, formatted as "organizations/[organizationId]". - * For example, "organizations/1234". - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callGetOrganization() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getOrganization(request); - console.log(response); - } - - callGetOrganization(); - // [END cloudresourcemanager_v3_generated_Organizations_GetOrganization_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.search_organizations.js b/owl-bot-staging/v3/samples/generated/v3/organizations.search_organizations.js deleted file mode 100644 index eb719e3..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/organizations.search_organizations.js +++ /dev/null @@ -1,83 +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 cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. The maximum number of organizations to return in the response. - * If unspecified, server picks an appropriate default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to `SearchOrganizations` - * that indicates from where listing should continue. - */ - // const pageToken = 'abc123' - /** - * Optional. An optional query string used to filter the Organizations to return in - * the response. Query rules are case-insensitive. - * ``` - * | Field | Description | - * |------------------|--------------------------------------------| - * | directoryCustomerId, owner.directoryCustomerId | Filters by directory - * customer id. | - * | domain | Filters by domain. | - * ``` - * Organizations may be queried by `directoryCustomerId` or by - * `domain`, where the domain is a G Suite domain, for example: - * * Query `directorycustomerid:123456789` returns Organization - * resources with `owner.directory_customer_id` equal to `123456789`. - * * Query `domain:google.com` returns Organization resources corresponding - * to the domain `google.com`. - */ - // const query = 'abc123' - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callSearchOrganizations() { - // Construct request - const request = { - }; - - // Run request - const iterable = await resourcemanagerClient.searchOrganizationsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchOrganizations(); - // [END cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/organizations.set_iam_policy.js deleted file mode 100644 index 86ed152..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/organizations.set_iam_policy.js +++ /dev/null @@ -1,74 +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(resource, policy) { - // [START cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/organizations.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/organizations.test_iam_permissions.js deleted file mode 100644 index f807e41..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/organizations.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Resourcemanager library - const {OrganizationsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new OrganizationsClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.create_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.create_project.js deleted file mode 100644 index c9da418..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.create_project.js +++ /dev/null @@ -1,65 +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(project) { - // [START cloudresourcemanager_v3_generated_Projects_CreateProject_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The Project to create. - * Project ID is required. If the requested ID is unavailable, the request - * fails. - * If the `parent` field is set, the `resourcemanager.projects.create` - * permission is checked on the parent resource. If no parent is set and - * the authorization credentials belong to an Organziation, the parent - * will be set to that Organization. - */ - // const project = 'my-project' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callCreateProject() { - // Construct request - const request = { - project, - }; - - // Run request - const [operation] = await resourcemanagerClient.createProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateProject(); - // [END cloudresourcemanager_v3_generated_Projects_CreateProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.delete_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.delete_project.js deleted file mode 100644 index c8ec405..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.delete_project.js +++ /dev/null @@ -1,59 +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(name) { - // [START cloudresourcemanager_v3_generated_Projects_DeleteProject_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the Project (for example, `projects/415104041262`). - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callDeleteProject() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteProject(); - // [END cloudresourcemanager_v3_generated_Projects_DeleteProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/projects.get_iam_policy.js deleted file mode 100644 index c8b3347..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.get_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.get_project.js deleted file mode 100644 index fc9dfdf..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.get_project.js +++ /dev/null @@ -1,58 +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(name) { - // [START cloudresourcemanager_v3_generated_Projects_GetProject_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project (for example, `projects/415104041262`). - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callGetProject() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getProject(request); - console.log(response); - } - - callGetProject(); - // [END cloudresourcemanager_v3_generated_Projects_GetProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.list_projects.js b/owl-bot-staging/v3/samples/generated/v3/projects.list_projects.js deleted file mode 100644 index 49c3c59..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.list_projects.js +++ /dev/null @@ -1,79 +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(parent) { - // [START cloudresourcemanager_v3_generated_Projects_ListProjects_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the parent resource to list projects under. - * For example, setting this field to 'folders/1234' would list all projects - * directly under that folder. - */ - // const parent = 'abc123' - /** - * Optional. A pagination token returned from a previous call to ListProjects - * google.cloud.resourcemanager.v3.Projects.ListProjects - * that indicates from where listing should continue. - */ - // const pageToken = 'abc123' - /** - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - */ - // const pageSize = 1234 - /** - * Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be - * returned. Normally only `ACTIVE` projects are returned. - */ - // const showDeleted = true - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callListProjects() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listProjectsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListProjects(); - // [END cloudresourcemanager_v3_generated_Projects_ListProjects_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.move_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.move_project.js deleted file mode 100644 index 3c443ab..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.move_project.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(name, destinationParent) { - // [START cloudresourcemanager_v3_generated_Projects_MoveProject_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project to move. - */ - // const name = 'abc123' - /** - * Required. The new parent to move the Project under. - */ - // const destinationParent = 'abc123' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callMoveProject() { - // Construct request - const request = { - name, - destinationParent, - }; - - // Run request - const [operation] = await resourcemanagerClient.moveProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callMoveProject(); - // [END cloudresourcemanager_v3_generated_Projects_MoveProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.search_projects.js b/owl-bot-staging/v3/samples/generated/v3/projects.search_projects.js deleted file mode 100644 index dd711a8..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.search_projects.js +++ /dev/null @@ -1,104 +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 cloudresourcemanager_v3_generated_Projects_SearchProjects_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Optional. A query string for searching for projects that the caller has - * `resourcemanager.projects.get` permission to. If multiple fields are - * included in the query, the it will return results that match any of the - * fields. Some eligible fields are: - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------------| - * | displayName, name | Filters by displayName. | - * | parent | Project's parent. (for example: folders/123, - * organizations/*) Prefer parent field over parent.type and parent.id. | - * | parent.type | Parent's type: `folder` or `organization`. | - * | parent.id | Parent's id number (for example: 123) | - * | id, projectId | Filters by projectId. | - * | state, lifecycleState | Filters by state. | - * | labels | Filters by label name or value. | - * | labels. (where *key* is the name of a label) | Filters by label - * name. | - * ``` - * Search expressions are case insensitive. - * Some examples queries: - * ``` - * | Query | Description | - * |------------------|-----------------------------------------------------| - * | name:how* | The project's name starts with "how". | - * | name:Howl | The project's name is `Howl` or `howl`. | - * | name:HOWL | Equivalent to above. | - * | NAME:howl | Equivalent to above. | - * | labels.color:* | The project has the label `color`. | - * | labels.color:red | The project's label `color` has the value `red`. | - * | labels.color:red labels.size:big | The project's label `color` has - * the value `red` and its label `size` has the value `big`. | - * ``` - * If no query is specified, the call will return projects for which the user - * has the `resourcemanager.projects.get` permission. - */ - // const query = 'abc123' - /** - * Optional. A pagination token returned from a previous call to ListProjects - * google.cloud.resourcemanager.v3.Projects.ListProjects - * that indicates from where listing should continue. - */ - // const pageToken = 'abc123' - /** - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - */ - // const pageSize = 1234 - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callSearchProjects() { - // Construct request - const request = { - }; - - // Run request - const iterable = await resourcemanagerClient.searchProjectsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callSearchProjects(); - // [END cloudresourcemanager_v3_generated_Projects_SearchProjects_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/projects.set_iam_policy.js deleted file mode 100644 index 19d61d3..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.set_iam_policy.js +++ /dev/null @@ -1,74 +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(resource, policy) { - // [START cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/projects.test_iam_permissions.js deleted file mode 100644 index 7d56e8b..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.undelete_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.undelete_project.js deleted file mode 100644 index 8ecca17..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.undelete_project.js +++ /dev/null @@ -1,60 +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(name) { - // [START cloudresourcemanager_v3_generated_Projects_UndeleteProject_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the project (for example, `projects/415104041262`). - * Required. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callUndeleteProject() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.undeleteProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUndeleteProject(); - // [END cloudresourcemanager_v3_generated_Projects_UndeleteProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/projects.update_project.js b/owl-bot-staging/v3/samples/generated/v3/projects.update_project.js deleted file mode 100644 index ed97372..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/projects.update_project.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(project) { - // [START cloudresourcemanager_v3_generated_Projects_UpdateProject_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new definition of the project. - */ - // const project = 'my-project' - /** - * Optional. An update mask to selectively update fields. - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {ProjectsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new ProjectsClient(); - - async function callUpdateProject() { - // Construct request - const request = { - project, - }; - - // Run request - const [operation] = await resourcemanagerClient.updateProject(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateProject(); - // [END cloudresourcemanager_v3_generated_Projects_UpdateProject_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/snippet_metadata.google.cloud.resourcemanager.v3.json b/owl-bot-staging/v3/samples/generated/v3/snippet_metadata.google.cloud.resourcemanager.v3.json deleted file mode 100644 index 67a3c2f..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/snippet_metadata.google.cloud.resourcemanager.v3.json +++ /dev/null @@ -1,2067 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-resourcemanager", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.resourcemanager.v3", - "version": "v3" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_GetFolder_async", - "title": "Folders getFolder Sample", - "origin": "API_DEFINITION", - "description": " Retrieves a folder identified by the supplied resource name. Valid folder resource names have the format `folders/{folder_id}` (for example, `folders/1234`). The caller must have `resourcemanager.folders.get` permission on the identified folder.", - "canonical": true, - "file": "folders.get_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.GetFolder", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.Folder", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "GetFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.GetFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_ListFolders_async", - "title": "Folders listFolders Sample", - "origin": "API_DEFINITION", - "description": " Lists the folders that are direct descendants of supplied parent resource. `list()` provides a strongly consistent view of the folders underneath the specified parent resource. `list()` returns folders sorted based upon the (ascending) lexical ordering of their display_name. The caller must have `resourcemanager.folders.list` permission on the identified parent.", - "canonical": true, - "file": "folders.list_folders.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 72, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListFolders", - "fullName": "google.cloud.resourcemanager.v3.Folders.ListFolders", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListFoldersResponse", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "ListFolders", - "fullName": "google.cloud.resourcemanager.v3.Folders.ListFolders", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_SearchFolders_async", - "title": "Folders searchFolders Sample", - "origin": "API_DEFINITION", - "description": " Search for folders that match specific filter criteria. `search()` provides an eventually consistent view of the folders a user has access to which meet the specified filter criteria. This will only return folders on which the caller has the permission `resourcemanager.folders.get`.", - "canonical": true, - "file": "folders.search_folders.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 86, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchFolders", - "fullName": "google.cloud.resourcemanager.v3.Folders.SearchFolders", - "async": true, - "parameters": [ - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.SearchFoldersResponse", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "SearchFolders", - "fullName": "google.cloud.resourcemanager.v3.Folders.SearchFolders", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_CreateFolder_async", - "title": "Folders createFolder Sample", - "origin": "API_DEFINITION", - "description": " Creates a folder in the resource hierarchy. Returns an `Operation` which can be used to track the progress of the folder creation workflow. Upon success, the `Operation.response` field will be populated with the created Folder. In order to succeed, the addition of this new folder must not violate the folder naming, height, or fanout constraints. + The folder's `display_name` must be distinct from all other folders that share its parent. + The addition of the folder must not cause the active folder hierarchy to exceed a height of 10. Note, the full active + deleted folder hierarchy is allowed to reach a height of 20; this provides additional headroom when moving folders that contain deleted folders. + The addition of the folder must not cause the total number of folders under its parent to exceed 300. If the operation fails due to a folder constraint violation, some errors may be returned by the `CreateFolder` request, with status code `FAILED_PRECONDITION` and an error description. Other folder constraint violations will be communicated in the `Operation`, with the specific `PreconditionFailure` returned in the details list in the `Operation.error` field. The caller must have `resourcemanager.folders.create` permission on the identified parent.", - "canonical": true, - "file": "folders.create_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 52, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.CreateFolder", - "async": true, - "parameters": [ - { - "name": "folder", - "type": ".google.cloud.resourcemanager.v3.Folder" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "CreateFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.CreateFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_UpdateFolder_async", - "title": "Folders updateFolder Sample", - "origin": "API_DEFINITION", - "description": " Updates a folder, changing its `display_name`. Changes to the folder `display_name` will be rejected if they violate either the `display_name` formatting rules or the naming constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The folder's `display_name` must start and end with a letter or digit, may contain letters, digits, spaces, hyphens and underscores and can be between 3 and 30 characters. This is captured by the regular expression: `[\\p{L}\\p{N}][\\p{L}\\p{N}_- ]{1,28}[\\p{L}\\p{N}]`. The caller must have `resourcemanager.folders.update` permission on the identified folder. If the update fails due to the unique name constraint then a `PreconditionFailure` explaining this violation will be returned in the Status.details field.", - "canonical": true, - "file": "folders.update_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.UpdateFolder", - "async": true, - "parameters": [ - { - "name": "folder", - "type": ".google.cloud.resourcemanager.v3.Folder" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "UpdateFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.UpdateFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_MoveFolder_async", - "title": "Folders moveFolder Sample", - "origin": "API_DEFINITION", - "description": " Moves a folder under a new resource parent. Returns an `Operation` which can be used to track the progress of the folder move workflow. Upon success, the `Operation.response` field will be populated with the moved folder. Upon failure, a `FolderOperationError` categorizing the failure cause will be returned - if the failure occurs synchronously then the `FolderOperationError` will be returned in the `Status.details` field. If it occurs asynchronously, then the FolderOperation will be returned in the `Operation.error` field. In addition, the `Operation.metadata` field will be populated with a `FolderOperation` message as an aid to stateless clients. Folder moves will be rejected if they violate either the naming, height, or fanout constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The caller must have `resourcemanager.folders.move` permission on the folder's current and proposed new parent.", - "canonical": true, - "file": "folders.move_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MoveFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.MoveFolder", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "destination_parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "MoveFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.MoveFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_DeleteFolder_async", - "title": "Folders deleteFolder Sample", - "origin": "API_DEFINITION", - "description": " Requests deletion of a folder. The folder is moved into the [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state immediately, and is deleted approximately 30 days later. This method may only be called on an empty folder, where a folder is empty if it doesn't contain any folders or projects in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If called on a folder in [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED] state the operation will result in a no-op success. The caller must have `resourcemanager.folders.delete` permission on the identified folder.", - "canonical": true, - "file": "folders.delete_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 52, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.DeleteFolder", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "DeleteFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.DeleteFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async", - "title": "Folders undeleteFolder Sample", - "origin": "API_DEFINITION", - "description": " Cancels the deletion request for a folder. This method may be called on a folder in any state. If the folder is in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the result will be a no-op success. In order to succeed, the folder's parent must be in the [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In addition, reintroducing the folder into the tree must not violate folder naming, height, and fanout constraints described in the [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder] documentation. The caller must have `resourcemanager.folders.undelete` permission on the identified folder.", - "canonical": true, - "file": "folders.undelete_folder.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 52, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UndeleteFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.UndeleteFolder", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "UndeleteFolder", - "fullName": "google.cloud.resourcemanager.v3.Folders.UndeleteFolder", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a folder. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the folder's resource name, for example: \"folders/1234\". The caller must have `resourcemanager.folders.getIamPolicy` permission on the identified folder.", - "canonical": true, - "file": "folders.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Folders.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Folders.GetIamPolicy", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy on a folder, replacing any existing policy. The `resource` field should be the folder's resource name, for example: \"folders/1234\". The caller must have `resourcemanager.folders.setIamPolicy` permission on the identified folder.", - "canonical": true, - "file": "folders.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Folders.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Folders.SetIamPolicy", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified folder. The `resource` field should be the folder's resource name, for example: \"folders/1234\". There are no permissions required for making this API call.", - "canonical": true, - "file": "folders.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Folders.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "FoldersClient", - "fullName": "google.cloud.resourcemanager.v3.FoldersClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Folders.TestIamPermissions", - "service": { - "shortName": "Folders", - "fullName": "google.cloud.resourcemanager.v3.Folders" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_GetOrganization_async", - "title": "Folders getOrganization Sample", - "origin": "API_DEFINITION", - "description": " Fetches an organization resource identified by the specified resource name.", - "canonical": true, - "file": "organizations.get_organization.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 52, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetOrganization", - "fullName": "google.cloud.resourcemanager.v3.Organizations.GetOrganization", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.Organization", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "GetOrganization", - "fullName": "google.cloud.resourcemanager.v3.Organizations.GetOrganization", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async", - "title": "Folders searchOrganizations Sample", - "origin": "API_DEFINITION", - "description": " Searches organization resources that are visible to the user and satisfy the specified filter. This method returns organizations in an unspecified order. New organizations do not necessarily appear at the end of the results, and may take a small amount of time to appear. Search will only return organizations on which the user has the permission `resourcemanager.organizations.get`", - "canonical": true, - "file": "organizations.search_organizations.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 75, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchOrganizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations.SearchOrganizations", - "async": true, - "parameters": [ - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "query", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.SearchOrganizationsResponse", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "SearchOrganizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations.SearchOrganizations", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for an organization resource. The policy may be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, for example: \"organizations/123\". Authorization requires the IAM permission `resourcemanager.organizations.getIamPolicy` on the specified organization.", - "canonical": true, - "file": "organizations.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Organizations.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Organizations.GetIamPolicy", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy on an organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, for example: \"organizations/123\". Authorization requires the IAM permission `resourcemanager.organizations.setIamPolicy` on the specified organization.", - "canonical": true, - "file": "organizations.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Organizations.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Organizations.SetIamPolicy", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns the permissions that a caller has on the specified organization. The `resource` field should be the organization's resource name, for example: \"organizations/123\". There are no permissions required for making this API call.", - "canonical": true, - "file": "organizations.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Organizations.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "OrganizationsClient", - "fullName": "google.cloud.resourcemanager.v3.OrganizationsClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Organizations.TestIamPermissions", - "service": { - "shortName": "Organizations", - "fullName": "google.cloud.resourcemanager.v3.Organizations" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_GetProject_async", - "title": "Folders getProject Sample", - "origin": "API_DEFINITION", - "description": " Retrieves the project identified by the specified `name` (for example, `projects/415104041262`). The caller must have `resourcemanager.projects.get` permission for this project.", - "canonical": true, - "file": "projects.get_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.GetProject", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.Project", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "GetProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.GetProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_ListProjects_async", - "title": "Folders listProjects Sample", - "origin": "API_DEFINITION", - "description": " Lists projects that are direct children of the specified folder or organization resource. `list()` provides a strongly consistent view of the projects underneath the specified parent resource. `list()` returns projects sorted based upon the (ascending) lexical ordering of their `display_name`. The caller must have `resourcemanager.projects.list` permission on the identified parent.", - "canonical": true, - "file": "projects.list_projects.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 71, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListProjects", - "fullName": "google.cloud.resourcemanager.v3.Projects.ListProjects", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "show_deleted", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListProjectsResponse", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "ListProjects", - "fullName": "google.cloud.resourcemanager.v3.Projects.ListProjects", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_SearchProjects_async", - "title": "Folders searchProjects Sample", - "origin": "API_DEFINITION", - "description": " Search for projects that the caller has both `resourcemanager.projects.get` permission on, and also satisfy the specified query. This method returns projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method.", - "canonical": true, - "file": "projects.search_projects.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 96, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SearchProjects", - "fullName": "google.cloud.resourcemanager.v3.Projects.SearchProjects", - "async": true, - "parameters": [ - { - "name": "query", - "type": "TYPE_STRING" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.SearchProjectsResponse", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "SearchProjects", - "fullName": "google.cloud.resourcemanager.v3.Projects.SearchProjects", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_CreateProject_async", - "title": "Folders createProject Sample", - "origin": "API_DEFINITION", - "description": " Request that a new project be created. The result is an `Operation` which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking `Operation` is automatically deleted after a few hours, so there is no need to call `DeleteOperation`.", - "canonical": true, - "file": "projects.create_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.CreateProject", - "async": true, - "parameters": [ - { - "name": "project", - "type": ".google.cloud.resourcemanager.v3.Project" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "CreateProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.CreateProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_UpdateProject_async", - "title": "Folders updateProject Sample", - "origin": "API_DEFINITION", - "description": " Updates the `display_name` and labels of the project identified by the specified `name` (for example, `projects/415104041262`). Deleting all labels requires an update mask for labels field. The caller must have `resourcemanager.projects.update` permission for this project.", - "canonical": true, - "file": "projects.update_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.UpdateProject", - "async": true, - "parameters": [ - { - "name": "project", - "type": ".google.cloud.resourcemanager.v3.Project" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "UpdateProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.UpdateProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_MoveProject_async", - "title": "Folders moveProject Sample", - "origin": "API_DEFINITION", - "description": " Move a project to another place in your resource hierarchy, under a new resource parent. Returns an operation which can be used to track the process of the project move workflow. Upon success, the `Operation.response` field will be populated with the moved project. The caller must have `resourcemanager.projects.update` permission on the project and have `resourcemanager.projects.move` permission on the project's current and proposed new parent.", - "canonical": true, - "file": "projects.move_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "MoveProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.MoveProject", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "destination_parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "MoveProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.MoveProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_DeleteProject_async", - "title": "Folders deleteProject Sample", - "origin": "API_DEFINITION", - "description": " Marks the project identified by the specified `name` (for example, `projects/415104041262`) for deletion. This method will only affect the project if it has a lifecycle state of [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]. This method changes the Project's lifecycle state from [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE] to [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the project with [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], and the project remains visible to [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects]. However, you cannot update the project. After the deletion completes, the project is not retrievable by the [GetProject] [google.cloud.resourcemanager.v3.Projects.GetProject], [ListProjects] [google.cloud.resourcemanager.v3.Projects.ListProjects], and [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects] methods. This method behaves idempotently, such that deleting a `DELETE_REQUESTED` project will not cause an error, but also won't do anything. The caller must have `resourcemanager.projects.delete` permissions for this project.", - "canonical": true, - "file": "projects.delete_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.DeleteProject", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "DeleteProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.DeleteProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_UndeleteProject_async", - "title": "Folders undeleteProject Sample", - "origin": "API_DEFINITION", - "description": " Restores the project identified by the specified `name` (for example, `projects/415104041262`). You can only use this method for a project that has a lifecycle state of [DELETE_REQUESTED] [Projects.State.DELETE_REQUESTED]. After deletion starts, the project cannot be restored. The caller must have `resourcemanager.projects.undelete` permission for this project.", - "canonical": true, - "file": "projects.undelete_project.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 52, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UndeleteProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.UndeleteProject", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "UndeleteProject", - "fullName": "google.cloud.resourcemanager.v3.Projects.UndeleteProject", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Returns the IAM access control policy for the specified project. Permission is denied if the policy or the resource do not exist.", - "canonical": true, - "file": "projects.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Projects.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Projects.GetIamPolicy", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the IAM access control policy for the specified project. CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings. Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted to a `user`, `serviceAccount`, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited using the Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + Invitations to grant the owner role cannot be sent using `setIamPolicy()`; they must be sent only using the Cloud Platform Console. + Membership changes that leave the project without any owners that have accepted the Terms of Service (ToS) will be rejected. + If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. + Calling this method requires enabling the App Engine Admin API.", - "canonical": true, - "file": "projects.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Projects.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.Projects.SetIamPolicy", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified project.", - "canonical": true, - "file": "projects.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Projects.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "ProjectsClient", - "fullName": "google.cloud.resourcemanager.v3.ProjectsClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.Projects.TestIamPermissions", - "service": { - "shortName": "Projects", - "fullName": "google.cloud.resourcemanager.v3.Projects" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async", - "title": "Folders listTagBindings Sample", - "origin": "API_DEFINITION", - "description": " Lists the TagBindings for the given cloud resource, as specified with `parent`. NOTE: The `parent` field is expected to be a full resource name: https://cloud.google.com/apis/design/resource_names#full_resource_name", - "canonical": true, - "file": "tag_bindings.list_tag_bindings.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListTagBindings", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListTagBindingsResponse", - "client": { - "shortName": "TagBindingsClient", - "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" - }, - "method": { - "shortName": "ListTagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.ListTagBindings", - "service": { - "shortName": "TagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async", - "title": "Folders createTagBinding Sample", - "origin": "API_DEFINITION", - "description": " Creates a TagBinding between a TagValue and a cloud resource (currently project, folder, or organization).", - "canonical": true, - "file": "tag_bindings.create_tag_binding.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateTagBinding", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.CreateTagBinding", - "async": true, - "parameters": [ - { - "name": "tag_binding", - "type": ".google.cloud.resourcemanager.v3.TagBinding" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagBindingsClient", - "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" - }, - "method": { - "shortName": "CreateTagBinding", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.CreateTagBinding", - "service": { - "shortName": "TagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async", - "title": "Folders deleteTagBinding Sample", - "origin": "API_DEFINITION", - "description": " Deletes a TagBinding.", - "canonical": true, - "file": "tag_bindings.delete_tag_binding.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 53, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteTagBinding", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.DeleteTagBinding", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagBindingsClient", - "fullName": "google.cloud.resourcemanager.v3.TagBindingsClient" - }, - "method": { - "shortName": "DeleteTagBinding", - "fullName": "google.cloud.resourcemanager.v3.TagBindings.DeleteTagBinding", - "service": { - "shortName": "TagBindings", - "fullName": "google.cloud.resourcemanager.v3.TagBindings" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async", - "title": "Folders listTagKeys Sample", - "origin": "API_DEFINITION", - "description": " Lists all TagKeys for a parent resource.", - "canonical": true, - "file": "tag_keys.list_tag_keys.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.ListTagKeys", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListTagKeysResponse", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "ListTagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.ListTagKeys", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async", - "title": "Folders getTagKey Sample", - "origin": "API_DEFINITION", - "description": " Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the key does not exist or the user does not have permission to view it.", - "canonical": true, - "file": "tag_keys.get_tag_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetTagKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.TagKey", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "GetTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetTagKey", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async", - "title": "Folders createTagKey Sample", - "origin": "API_DEFINITION", - "description": " Creates a new TagKey. If another request with the same parameters is sent while the original request is in process, the second request will receive an error. A maximum of 300 TagKeys can exist under a parent at any given time.", - "canonical": true, - "file": "tag_keys.create_tag_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.CreateTagKey", - "async": true, - "parameters": [ - { - "name": "tag_key", - "type": ".google.cloud.resourcemanager.v3.TagKey" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "CreateTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.CreateTagKey", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async", - "title": "Folders updateTagKey Sample", - "origin": "API_DEFINITION", - "description": " Updates the attributes of the TagKey resource.", - "canonical": true, - "file": "tag_keys.update_tag_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.UpdateTagKey", - "async": true, - "parameters": [ - { - "name": "tag_key", - "type": ".google.cloud.resourcemanager.v3.TagKey" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "UpdateTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.UpdateTagKey", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async", - "title": "Folders deleteTagKey Sample", - "origin": "API_DEFINITION", - "description": " Deletes a TagKey. The TagKey cannot be deleted if it has any child TagValues.", - "canonical": true, - "file": "tag_keys.delete_tag_key.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.DeleteTagKey", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "DeleteTagKey", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.DeleteTagKey", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a TagKey. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". The caller must have `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on the specified TagKey.", - "canonical": true, - "file": "tag_keys.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.GetIamPolicy", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy on a TagKey, replacing any existing policy. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". The caller must have `resourcemanager.tagKeys.setIamPolicy` permission on the identified tagValue.", - "canonical": true, - "file": "tag_keys.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.SetIamPolicy", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified TagKey. The `resource` field should be the TagKey's resource name. For example, \"tagKeys/1234\". There are no permissions required for making this API call.", - "canonical": true, - "file": "tag_keys.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "TagKeysClient", - "fullName": "google.cloud.resourcemanager.v3.TagKeysClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.TagKeys.TestIamPermissions", - "service": { - "shortName": "TagKeys", - "fullName": "google.cloud.resourcemanager.v3.TagKeys" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_ListTagValues_async", - "title": "Folders listTagValues Sample", - "origin": "API_DEFINITION", - "description": " Lists all TagValues for a specific TagKey.", - "canonical": true, - "file": "tag_values.list_tag_values.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListTagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues.ListTagValues", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.ListTagValuesResponse", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "ListTagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues.ListTagValues", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetTagValue_async", - "title": "Folders getTagValue Sample", - "origin": "API_DEFINITION", - "description": " Retrieves TagValue. If the TagValue or namespaced name does not exist, or if the user does not have permission to view it, this method will return `PERMISSION_DENIED`.", - "canonical": true, - "file": "tag_values.get_tag_value.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 50, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetTagValue", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.resourcemanager.v3.TagValue", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "GetTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetTagValue", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async", - "title": "Folders createTagValue Sample", - "origin": "API_DEFINITION", - "description": " Creates a TagValue as a child of the specified TagKey. If a another request with the same parameters is sent while the original request is in process the second request will receive an error. A maximum of 300 TagValues can exist under a TagKey at any given time.", - "canonical": true, - "file": "tag_values.create_tag_value.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 57, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.CreateTagValue", - "async": true, - "parameters": [ - { - "name": "tag_value", - "type": ".google.cloud.resourcemanager.v3.TagValue" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "CreateTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.CreateTagValue", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async", - "title": "Folders updateTagValue Sample", - "origin": "API_DEFINITION", - "description": " Updates the attributes of the TagValue resource.", - "canonical": true, - "file": "tag_values.update_tag_value.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 63, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.UpdateTagValue", - "async": true, - "parameters": [ - { - "name": "tag_value", - "type": ".google.cloud.resourcemanager.v3.TagValue" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "UpdateTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.UpdateTagValue", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async", - "title": "Folders deleteTagValue Sample", - "origin": "API_DEFINITION", - "description": " Deletes a TagValue. The TagValue cannot have any bindings when it is deleted.", - "canonical": true, - "file": "tag_values.delete_tag_value.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.DeleteTagValue", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "validate_only", - "type": "TYPE_BOOL" - }, - { - "name": "etag", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "DeleteTagValue", - "fullName": "google.cloud.resourcemanager.v3.TagValues.DeleteTagValue", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async", - "title": "Folders getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a TagValue. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. The caller must have the `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on the identified TagValue to get the access control policy.", - "canonical": true, - "file": "tag_values.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagValues.GetIamPolicy", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async", - "title": "Folders setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy on a TagValue, replacing any existing policy. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. The caller must have `resourcemanager.tagValues.setIamPolicy` permission on the identified tagValue.", - "canonical": true, - "file": "tag_values.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagValues.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.resourcemanager.v3.TagValues.SetIamPolicy", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - }, - { - "regionTag": "cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async", - "title": "Folders testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified TagValue. The `resource` field should be the TagValue's resource name. For example: `tagValues/1234`. There are no permissions required for making this API call.", - "canonical": true, - "file": "tag_values.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.TagValues.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "TagValuesClient", - "fullName": "google.cloud.resourcemanager.v3.TagValuesClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.resourcemanager.v3.TagValues.TestIamPermissions", - "service": { - "shortName": "TagValues", - "fullName": "google.cloud.resourcemanager.v3.TagValues" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_bindings.create_tag_binding.js b/owl-bot-staging/v3/samples/generated/v3/tag_bindings.create_tag_binding.js deleted file mode 100644 index d04c57e..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_bindings.create_tag_binding.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(tagBinding) { - // [START cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The TagBinding to be created. - */ - // const tagBinding = {} - /** - * Optional. Set to true to perform the validations necessary for creating the resource, - * but not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagBindingsClient(); - - async function callCreateTagBinding() { - // Construct request - const request = { - tagBinding, - }; - - // Run request - const [operation] = await resourcemanagerClient.createTagBinding(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateTagBinding(); - // [END cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js b/owl-bot-staging/v3/samples/generated/v3/tag_bindings.delete_tag_binding.js deleted file mode 100644 index 511ff1d..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_bindings.delete_tag_binding.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(name) { - // [START cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the TagBinding. This is a String of the form: - * `tagBindings/{id}` (e.g. - * `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagBindingsClient(); - - async function callDeleteTagBinding() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteTagBinding(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteTagBinding(); - // [END cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js b/owl-bot-staging/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js deleted file mode 100644 index faa55a2..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_bindings.list_tag_bindings.js +++ /dev/null @@ -1,73 +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(parent) { - // [START cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The full resource name of a resource for which you want to list existing - * TagBindings. - * E.g. "//cloudresourcemanager.googleapis.com/projects/123" - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of TagBindings to return in the response. The server - * allows a maximum of 300 TagBindings to return. If unspecified, the server - * will use 100 as the default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to `ListTagBindings` - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Resourcemanager library - const {TagBindingsClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagBindingsClient(); - - async function callListTagBindings() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listTagBindingsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTagBindings(); - // [END cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.create_tag_key.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.create_tag_key.js deleted file mode 100644 index 270f21a..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_keys.create_tag_key.js +++ /dev/null @@ -1,65 +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(tagKey) { - // [START cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The TagKey to be created. Only fields `short_name`, `description`, - * and `parent` are considered during the creation request. - */ - // const tagKey = {} - /** - * Optional. Set to true to perform validations necessary for creating the resource, but - * not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callCreateTagKey() { - // Construct request - const request = { - tagKey, - }; - - // Run request - const [operation] = await resourcemanagerClient.createTagKey(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateTagKey(); - // [END cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.delete_tag_key.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.delete_tag_key.js deleted file mode 100644 index f27a8e5..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_keys.delete_tag_key.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(name) { - // [START cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of a TagKey to be deleted in the format `tagKeys/123`. - * The TagKey cannot be a parent of any existing TagValues or it will not be - * deleted successfully. - */ - // const name = 'abc123' - /** - * Optional. Set as true to perform validations necessary for deletion, but not actually - * perform the action. - */ - // const validateOnly = true - /** - * Optional. The etag known to the client for the expected state of the TagKey. This is - * to be used for optimistic concurrency. - */ - // const etag = 'abc123' - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callDeleteTagKey() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteTagKey(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteTagKey(); - // [END cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_iam_policy.js deleted file mode 100644 index 23f6fc8..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_tag_key.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_tag_key.js deleted file mode 100644 index 22b41f5..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_keys.get_tag_key.js +++ /dev/null @@ -1,59 +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(name) { - // [START cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. A resource name in the format `tagKeys/{id}`, such as - * `tagKeys/123`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callGetTagKey() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getTagKey(request); - console.log(response); - } - - callGetTagKey(); - // [END cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.list_tag_keys.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.list_tag_keys.js deleted file mode 100644 index 71be42c..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_keys.list_tag_keys.js +++ /dev/null @@ -1,72 +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(parent) { - // [START cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the new TagKey's parent. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of TagKeys to return in the response. The server allows - * a maximum of 300 TagKeys to return. If unspecified, the server will use 100 - * as the default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to `ListTagKey` - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callListTagKeys() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listTagKeysAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTagKeys(); - // [END cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.set_iam_policy.js deleted file mode 100644 index 1442ba4..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_keys.set_iam_policy.js +++ /dev/null @@ -1,74 +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(resource, policy) { - // [START cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.test_iam_permissions.js deleted file mode 100644 index 1927d00..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_keys.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_keys.update_tag_key.js b/owl-bot-staging/v3/samples/generated/v3/tag_keys.update_tag_key.js deleted file mode 100644 index b21cf23..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_keys.update_tag_key.js +++ /dev/null @@ -1,73 +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(tagKey) { - // [START cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new definition of the TagKey. Only the `description` and `etag` fields - * can be updated by this request. If the `etag` field is not empty, it - * must match the `etag` field of the existing tag key. Otherwise, - * `FAILED_PRECONDITION` will be returned. - */ - // const tagKey = {} - /** - * Fields to be updated. The mask may only contain `description` or - * `etag`. If omitted entirely, both `description` and `etag` are assumed to - * be significant. - */ - // const updateMask = {} - /** - * Set as true to perform validations necessary for updating the resource, but - * not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagKeysClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagKeysClient(); - - async function callUpdateTagKey() { - // Construct request - const request = { - tagKey, - }; - - // Run request - const [operation] = await resourcemanagerClient.updateTagKey(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateTagKey(); - // [END cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.create_tag_value.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.create_tag_value.js deleted file mode 100644 index 5ae067c..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_values.create_tag_value.js +++ /dev/null @@ -1,65 +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(tagValue) { - // [START cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The TagValue to be created. Only fields `short_name`, `description`, - * and `parent` are considered during the creation request. - */ - // const tagValue = {} - /** - * Optional. Set as true to perform the validations necessary for creating the resource, - * but not actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callCreateTagValue() { - // Construct request - const request = { - tagValue, - }; - - // Run request - const [operation] = await resourcemanagerClient.createTagValue(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateTagValue(); - // [END cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.delete_tag_value.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.delete_tag_value.js deleted file mode 100644 index 62feff2..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_values.delete_tag_value.js +++ /dev/null @@ -1,69 +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(name) { - // [START cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name for TagValue to be deleted in the format tagValues/456. - */ - // const name = 'abc123' - /** - * Optional. Set as true to perform the validations necessary for deletion, but not - * actually perform the action. - */ - // const validateOnly = true - /** - * Optional. The etag known to the client for the expected state of the TagValue. This - * is to be used for optimistic concurrency. - */ - // const etag = 'abc123' - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callDeleteTagValue() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await resourcemanagerClient.deleteTagValue(request); - const [response] = await operation.promise(); - console.log(response); - } - - callDeleteTagValue(); - // [END cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.get_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.get_iam_policy.js deleted file mode 100644 index 43370c2..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_values.get_iam_policy.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(resource) { - // [START cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await resourcemanagerClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.get_tag_value.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.get_tag_value.js deleted file mode 100644 index b4fe6e3..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_values.get_tag_value.js +++ /dev/null @@ -1,58 +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(name) { - // [START cloudresourcemanager_v3_generated_TagValues_GetTagValue_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name for TagValue to be fetched in the format `tagValues/456`. - */ - // const name = 'abc123' - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callGetTagValue() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await resourcemanagerClient.getTagValue(request); - console.log(response); - } - - callGetTagValue(); - // [END cloudresourcemanager_v3_generated_TagValues_GetTagValue_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.list_tag_values.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.list_tag_values.js deleted file mode 100644 index 2523356..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_values.list_tag_values.js +++ /dev/null @@ -1,72 +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(parent) { - // [START cloudresourcemanager_v3_generated_TagValues_ListTagValues_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Resource name for TagKey, parent of the TagValues to be listed, - * in the format `tagKeys/123`. - */ - // const parent = 'abc123' - /** - * Optional. The maximum number of TagValues to return in the response. The server - * allows a maximum of 300 TagValues to return. If unspecified, the server - * will use 100 as the default. - */ - // const pageSize = 1234 - /** - * Optional. A pagination token returned from a previous call to `ListTagValues` - * that indicates where this listing should continue from. - */ - // const pageToken = 'abc123' - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callListTagValues() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await resourcemanagerClient.listTagValuesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListTagValues(); - // [END cloudresourcemanager_v3_generated_TagValues_ListTagValues_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.set_iam_policy.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.set_iam_policy.js deleted file mode 100644 index 6911eb8..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_values.set_iam_policy.js +++ /dev/null @@ -1,74 +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(resource, policy) { - // [START cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await resourcemanagerClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.test_iam_permissions.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.test_iam_permissions.js deleted file mode 100644 index 7843a70..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_values.test_iam_permissions.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(resource, permissions) { - // [START cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await resourcemanagerClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/samples/generated/v3/tag_values.update_tag_value.js b/owl-bot-staging/v3/samples/generated/v3/tag_values.update_tag_value.js deleted file mode 100644 index 8cd1194..0000000 --- a/owl-bot-staging/v3/samples/generated/v3/tag_values.update_tag_value.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(tagValue) { - // [START cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new definition of the TagValue. Only fields `description` and `etag` - * fields can be updated by this request. If the `etag` field is nonempty, it - * must match the `etag` field of the existing ControlGroup. Otherwise, - * `FAILED_PRECONDITION` will be returned. - */ - // const tagValue = {} - /** - * Optional. Fields to be updated. - */ - // const updateMask = {} - /** - * Optional. True to perform validations necessary for updating the resource, but not - * actually perform the action. - */ - // const validateOnly = true - - // Imports the Resourcemanager library - const {TagValuesClient} = require('@google-cloud/resource-manager').v3; - - // Instantiates a client - const resourcemanagerClient = new TagValuesClient(); - - async function callUpdateTagValue() { - // Construct request - const request = { - tagValue, - }; - - // Run request - const [operation] = await resourcemanagerClient.updateTagValue(request); - const [response] = await operation.promise(); - console.log(response); - } - - callUpdateTagValue(); - // [END cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v3/src/index.ts b/owl-bot-staging/v3/src/index.ts deleted file mode 100644 index 6ba6f62..0000000 --- a/owl-bot-staging/v3/src/index.ts +++ /dev/null @@ -1,35 +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 v3 from './v3'; -const FoldersClient = v3.FoldersClient; -type FoldersClient = v3.FoldersClient; -const OrganizationsClient = v3.OrganizationsClient; -type OrganizationsClient = v3.OrganizationsClient; -const ProjectsClient = v3.ProjectsClient; -type ProjectsClient = v3.ProjectsClient; -const TagBindingsClient = v3.TagBindingsClient; -type TagBindingsClient = v3.TagBindingsClient; -const TagKeysClient = v3.TagKeysClient; -type TagKeysClient = v3.TagKeysClient; -const TagValuesClient = v3.TagValuesClient; -type TagValuesClient = v3.TagValuesClient; -export {v3, FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagKeysClient, TagValuesClient}; -export default {v3, FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagKeysClient, TagValuesClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v3/src/v3/folders_client.ts b/owl-bot-staging/v3/src/v3/folders_client.ts deleted file mode 100644 index 4de30ae..0000000 --- a/owl-bot-staging/v3/src/v3/folders_client.ts +++ /dev/null @@ -1,1844 +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/v3/folders_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './folders_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Manages Cloud Platform folder resources. - * Folders can be used to organize the resources under an - * organization and to control the policies applied to groups of resources. - * @class - * @memberof v3 - */ -export class FoldersClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - foldersStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of FoldersClient. - * - * @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 FoldersClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listFolders: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'folders'), - searchFolders: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'folders') - }; - - 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.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const createFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateFolderMetadata') as gax.protobuf.Type; - const updateFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const updateFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UpdateFolderMetadata') as gax.protobuf.Type; - const moveFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const moveFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.MoveFolderMetadata') as gax.protobuf.Type; - const deleteFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const deleteFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteFolderMetadata') as gax.protobuf.Type; - const undeleteFolderResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Folder') as gax.protobuf.Type; - const undeleteFolderMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UndeleteFolderMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createFolderResponse.decode.bind(createFolderResponse), - createFolderMetadata.decode.bind(createFolderMetadata)), - updateFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateFolderResponse.decode.bind(updateFolderResponse), - updateFolderMetadata.decode.bind(updateFolderMetadata)), - moveFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - moveFolderResponse.decode.bind(moveFolderResponse), - moveFolderMetadata.decode.bind(moveFolderMetadata)), - deleteFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteFolderResponse.decode.bind(deleteFolderResponse), - deleteFolderMetadata.decode.bind(deleteFolderMetadata)), - undeleteFolder: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - undeleteFolderResponse.decode.bind(undeleteFolderResponse), - undeleteFolderMetadata.decode.bind(undeleteFolderMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.Folders', 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.foldersStub) { - return this.foldersStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.Folders. - this.foldersStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Folders') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.Folders, - 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 foldersStubMethods = - ['getFolder', 'listFolders', 'searchFolders', 'createFolder', 'updateFolder', 'moveFolder', 'deleteFolder', 'undeleteFolder', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of foldersStubMethods) { - const callPromise = this.foldersStub.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.foldersStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Retrieves a folder identified by the supplied resource name. - * Valid folder resource names have the format `folders/{folder_id}` - * (for example, `folders/1234`). - * The caller must have `resourcemanager.folders.get` permission on the - * identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the folder to retrieve. - * Must be of the form `folders/{folder_id}`. - * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder}. - * 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/v3/folders.get_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_GetFolder_async - */ - getFolder( - request?: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|undefined, {}|undefined - ]>; - getFolder( - request: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, - {}|null|undefined>): void; - getFolder( - request: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, - {}|null|undefined>): void; - getFolder( - request?: protos.google.cloud.resourcemanager.v3.IGetFolderRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder, - protos.google.cloud.resourcemanager.v3.IGetFolderRequest|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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getFolder(request, options, callback); - } -/** - * Gets the access control policy for a folder. The returned policy may be - * empty if no such policy or resource exists. The `resource` field should - * be the folder's resource name, for example: "folders/1234". - * The caller must have `resourcemanager.folders.getIamPolicy` permission - * on the identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/folders.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Folders_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the access control policy on a folder, replacing any existing policy. - * The `resource` field should be the folder's resource name, for example: - * "folders/1234". - * The caller must have `resourcemanager.folders.setIamPolicy` permission - * on the identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/folders.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Folders_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified folder. - * The `resource` field should be the folder's resource name, - * for example: "folders/1234". - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * 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/v3/folders.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_Folders_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a folder in the resource hierarchy. - * Returns an `Operation` which can be used to track the progress of the - * folder creation workflow. - * Upon success, the `Operation.response` field will be populated with the - * created Folder. - * - * In order to succeed, the addition of this new folder must not violate - * the folder naming, height, or fanout constraints. - * - * + The folder's `display_name` must be distinct from all other folders that - * share its parent. - * + The addition of the folder must not cause the active folder hierarchy - * to exceed a height of 10. Note, the full active + deleted folder hierarchy - * is allowed to reach a height of 20; this provides additional headroom when - * moving folders that contain deleted folders. - * + The addition of the folder must not cause the total number of folders - * under its parent to exceed 300. - * - * If the operation fails due to a folder constraint violation, some errors - * may be returned by the `CreateFolder` request, with status code - * `FAILED_PRECONDITION` and an error description. Other folder constraint - * violations will be communicated in the `Operation`, with the specific - * `PreconditionFailure` returned in the details list in the `Operation.error` - * field. - * - * The caller must have `resourcemanager.folders.create` permission on the - * identified parent. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.Folder} request.folder - * Required. The folder being created, only the display name and parent will be - * consulted. All other fields will be ignored. - * @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/v3/folders.create_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_CreateFolder_async - */ - createFolder( - request?: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createFolder( - request: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createFolder( - request: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createFolder( - request?: protos.google.cloud.resourcemanager.v3.ICreateFolderRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.createFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createFolder()`. - * @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/v3/folders.create_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_CreateFolder_async - */ - async checkCreateFolderProgress(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.createFolder, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates a folder, changing its `display_name`. - * Changes to the folder `display_name` will be rejected if they violate - * either the `display_name` formatting rules or the naming constraints - * described in the {@link google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} documentation. - * - * The folder's `display_name` must start and end with a letter or digit, - * may contain letters, digits, spaces, hyphens and underscores and can be - * between 3 and 30 characters. This is captured by the regular expression: - * `{@link \p{L}\p{N}_- |\p{L}\p{N}}{1,28}[\p{L}\p{N}]`. - * The caller must have `resourcemanager.folders.update` permission on the - * identified folder. - * - * If the update fails due to the unique name constraint then a - * `PreconditionFailure` explaining this violation will be returned - * in the Status.details field. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.Folder} request.folder - * Required. The new definition of the Folder. It must include the `name` field, which - * cannot be changed. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Fields to be updated. - * Only the `display_name` can be updated. - * @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/v3/folders.update_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_UpdateFolder_async - */ - updateFolder( - request?: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateFolder( - request: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateFolder( - request: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateFolder( - request?: protos.google.cloud.resourcemanager.v3.IUpdateFolderRequest, - 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({ - 'folder.name': request.folder!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateFolder()`. - * @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/v3/folders.update_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_UpdateFolder_async - */ - async checkUpdateFolderProgress(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.updateFolder, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Moves a folder under a new resource parent. - * Returns an `Operation` which can be used to track the progress of the - * folder move workflow. - * Upon success, the `Operation.response` field will be populated with the - * moved folder. - * Upon failure, a `FolderOperationError` categorizing the failure cause will - * be returned - if the failure occurs synchronously then the - * `FolderOperationError` will be returned in the `Status.details` field. - * If it occurs asynchronously, then the FolderOperation will be returned - * in the `Operation.error` field. - * In addition, the `Operation.metadata` field will be populated with a - * `FolderOperation` message as an aid to stateless clients. - * Folder moves will be rejected if they violate either the naming, height, - * or fanout constraints described in the - * {@link google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} documentation. - * The caller must have `resourcemanager.folders.move` permission on the - * folder's current and proposed new parent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Folder to move. - * Must be of the form folders/{folder_id} - * @param {string} request.destinationParent - * Required. The resource name of the folder or organization which should be the - * folder's new parent. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - * @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/v3/folders.move_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_MoveFolder_async - */ - moveFolder( - request?: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - moveFolder( - request: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - moveFolder( - request: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - moveFolder( - request?: protos.google.cloud.resourcemanager.v3.IMoveFolderRequest, - 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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.moveFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `moveFolder()`. - * @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/v3/folders.move_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_MoveFolder_async - */ - async checkMoveFolderProgress(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.moveFolder, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Requests deletion of a folder. The folder is moved into the - * {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} state - * immediately, and is deleted approximately 30 days later. This method may - * only be called on an empty folder, where a folder is empty if it doesn't - * contain any folders or projects in the {@link google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state. - * If called on a folder in {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} - * state the operation will result in a no-op success. - * The caller must have `resourcemanager.folders.delete` permission on the - * identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the folder to be deleted. - * Must be of the form `folders/{folder_id}`. - * @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/v3/folders.delete_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_DeleteFolder_async - */ - deleteFolder( - request?: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteFolder( - request: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteFolder( - request: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteFolder( - request?: protos.google.cloud.resourcemanager.v3.IDeleteFolderRequest, - 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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteFolder()`. - * @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/v3/folders.delete_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_DeleteFolder_async - */ - async checkDeleteFolderProgress(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.deleteFolder, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Cancels the deletion request for a folder. This method may be called on a - * folder in any state. If the folder is in the {@link google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} - * state the result will be a no-op success. In order to succeed, the folder's - * parent must be in the {@link google.cloud.resourcemanager.v3.Folder.State.ACTIVE|ACTIVE} state. In addition, - * reintroducing the folder into the tree must not violate folder naming, - * height, and fanout constraints described in the - * {@link google.cloud.resourcemanager.v3.Folders.CreateFolder|CreateFolder} documentation. - * The caller must have `resourcemanager.folders.undelete` permission on the - * identified folder. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the folder to undelete. - * Must be of the form `folders/{folder_id}`. - * @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/v3/folders.undelete_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async - */ - undeleteFolder( - request?: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - undeleteFolder( - request: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeleteFolder( - request: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeleteFolder( - request?: protos.google.cloud.resourcemanager.v3.IUndeleteFolderRequest, - 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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.undeleteFolder(request, options, callback); - } -/** - * Check the status of the long running operation returned by `undeleteFolder()`. - * @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/v3/folders.undelete_folder.js - * region_tag:cloudresourcemanager_v3_generated_Folders_UndeleteFolder_async - */ - async checkUndeleteFolderProgress(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.undeleteFolder, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the folders that are direct descendants of supplied parent resource. - * `list()` provides a strongly consistent view of the folders underneath - * the specified parent resource. - * `list()` returns folders sorted based upon the (ascending) lexical ordering - * of their display_name. - * The caller must have `resourcemanager.folders.list` permission on the - * identified parent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the organization or folder whose folders are - * being listed. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - * Access to this method is controlled by checking the - * `resourcemanager.folders.list` permission on the `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. - * If unspecified, server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListFolders` - * that indicates where this listing should continue from. - * @param {boolean} [request.showDeleted] - * Optional. Controls whether folders in the - * {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} - * state should be returned. Defaults to false. - * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder}. - * 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 `listFoldersAsync()` - * 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. - */ - listFolders( - request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder[], - protos.google.cloud.resourcemanager.v3.IListFoldersRequest|null, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse - ]>; - listFolders( - request: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): void; - listFolders( - request: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): void; - listFolders( - request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder[], - protos.google.cloud.resourcemanager.v3.IListFoldersRequest|null, - protos.google.cloud.resourcemanager.v3.IListFoldersResponse - ]>|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 || {}; - this.initialize(); - return this.innerApiCalls.listFolders(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.parent - * Required. The resource name of the organization or folder whose folders are - * being listed. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - * Access to this method is controlled by checking the - * `resourcemanager.folders.list` permission on the `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. - * If unspecified, server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListFolders` - * that indicates where this listing should continue from. - * @param {boolean} [request.showDeleted] - * Optional. Controls whether folders in the - * {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} - * state should be returned. Defaults to false. - * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder} 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 `listFoldersAsync()` - * 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. - */ - listFoldersStream( - request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listFolders']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listFolders.createStream( - this.innerApiCalls.listFolders as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listFolders`, 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.parent - * Required. The resource name of the organization or folder whose folders are - * being listed. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - * Access to this method is controlled by checking the - * `resourcemanager.folders.list` permission on the `parent`. - * @param {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. - * If unspecified, server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListFolders` - * that indicates where this listing should continue from. - * @param {boolean} [request.showDeleted] - * Optional. Controls whether folders in the - * {@link google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED|DELETE_REQUESTED} - * state should be returned. Defaults to false. - * @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 - * [Folder]{@link google.cloud.resourcemanager.v3.Folder}. 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/v3/folders.list_folders.js - * region_tag:cloudresourcemanager_v3_generated_Folders_ListFolders_async - */ - listFoldersAsync( - request?: protos.google.cloud.resourcemanager.v3.IListFoldersRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listFolders']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listFolders.asyncIterate( - this.innerApiCalls['listFolders'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * Search for folders that match specific filter criteria. - * `search()` provides an eventually consistent view of the folders a user has - * access to which meet the specified filter criteria. - * - * This will only return folders on which the caller has the - * permission `resourcemanager.folders.get`. - * - * @param {Object} request - * The request object that will be sent. - * @param {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. - * If unspecified, server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `SearchFolders` - * that indicates from where search should continue. - * @param {string} [request.query] - * Optional. Search criteria used to select the folders to return. - * If no search criteria is specified then all accessible folders will be - * returned. - * - * Query expressions can be used to restrict results based upon displayName, - * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - * can be used along with the suffix wildcard symbol `*`. - * - * The `displayName` field in a query expression should use escaped quotes - * for values that include whitespace to prevent unexpected behavior. - * - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------| - * | displayName | Filters by displayName. | - * | parent | Filters by parent (for example: folders/123). | - * | state, lifecycleState | Filters by state. | - * ``` - * - * Some example queries are: - * - * * Query `displayName=Test*` returns Folder resources whose display name - * starts with "Test". - * * Query `state=ACTIVE` returns Folder resources with - * `state` set to `ACTIVE`. - * * Query `parent=folders/123` returns Folder resources that have - * `folders/123` as a parent resource. - * * Query `parent=folders/123 AND state=ACTIVE` returns active - * Folder resources that have `folders/123` as a parent resource. - * * Query `displayName=\\"Test String\\"` returns Folder resources with - * display names that include both "Test" and "String". - * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder}. - * 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 `searchFoldersAsync()` - * 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. - */ - searchFolders( - request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder[], - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse - ]>; - searchFolders( - request: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): void; - searchFolders( - request: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): void; - searchFolders( - request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IFolder>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IFolder[], - protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchFoldersResponse - ]>|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 || {}; - this.initialize(); - return this.innerApiCalls.searchFolders(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 {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. - * If unspecified, server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `SearchFolders` - * that indicates from where search should continue. - * @param {string} [request.query] - * Optional. Search criteria used to select the folders to return. - * If no search criteria is specified then all accessible folders will be - * returned. - * - * Query expressions can be used to restrict results based upon displayName, - * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - * can be used along with the suffix wildcard symbol `*`. - * - * The `displayName` field in a query expression should use escaped quotes - * for values that include whitespace to prevent unexpected behavior. - * - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------| - * | displayName | Filters by displayName. | - * | parent | Filters by parent (for example: folders/123). | - * | state, lifecycleState | Filters by state. | - * ``` - * - * Some example queries are: - * - * * Query `displayName=Test*` returns Folder resources whose display name - * starts with "Test". - * * Query `state=ACTIVE` returns Folder resources with - * `state` set to `ACTIVE`. - * * Query `parent=folders/123` returns Folder resources that have - * `folders/123` as a parent resource. - * * Query `parent=folders/123 AND state=ACTIVE` returns active - * Folder resources that have `folders/123` as a parent resource. - * * Query `displayName=\\"Test String\\"` returns Folder resources with - * display names that include both "Test" and "String". - * @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 [Folder]{@link google.cloud.resourcemanager.v3.Folder} 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 `searchFoldersAsync()` - * 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. - */ - searchFoldersStream( - request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchFolders']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchFolders.createStream( - this.innerApiCalls.searchFolders as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchFolders`, 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 {number} [request.pageSize] - * Optional. The maximum number of folders to return in the response. - * If unspecified, server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `SearchFolders` - * that indicates from where search should continue. - * @param {string} [request.query] - * Optional. Search criteria used to select the folders to return. - * If no search criteria is specified then all accessible folders will be - * returned. - * - * Query expressions can be used to restrict results based upon displayName, - * state and parent, where the operators `=` (`:`) `NOT`, `AND` and `OR` - * can be used along with the suffix wildcard symbol `*`. - * - * The `displayName` field in a query expression should use escaped quotes - * for values that include whitespace to prevent unexpected behavior. - * - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------| - * | displayName | Filters by displayName. | - * | parent | Filters by parent (for example: folders/123). | - * | state, lifecycleState | Filters by state. | - * ``` - * - * Some example queries are: - * - * * Query `displayName=Test*` returns Folder resources whose display name - * starts with "Test". - * * Query `state=ACTIVE` returns Folder resources with - * `state` set to `ACTIVE`. - * * Query `parent=folders/123` returns Folder resources that have - * `folders/123` as a parent resource. - * * Query `parent=folders/123 AND state=ACTIVE` returns active - * Folder resources that have `folders/123` as a parent resource. - * * Query `displayName=\\"Test String\\"` returns Folder resources with - * display names that include both "Test" and "String". - * @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 - * [Folder]{@link google.cloud.resourcemanager.v3.Folder}. 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/v3/folders.search_folders.js - * region_tag:cloudresourcemanager_v3_generated_Folders_SearchFolders_async - */ - searchFoldersAsync( - request?: protos.google.cloud.resourcemanager.v3.ISearchFoldersRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchFolders']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchFolders.asyncIterate( - this.innerApiCalls['searchFolders'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.foldersStub && !this._terminated) { - return this.foldersStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v3/src/v3/folders_client_config.json b/owl-bot-staging/v3/src/v3/folders_client_config.json deleted file mode 100644 index a2bed85..0000000 --- a/owl-bot-staging/v3/src/v3/folders_client_config.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.Folders": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "GetFolder": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "ListFolders": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SearchFolders": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "MoveFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UndeleteFolder": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v3/src/v3/folders_proto_list.json b/owl-bot-staging/v3/src/v3/folders_proto_list.json deleted file mode 100644 index 0c00660..0000000 --- a/owl-bot-staging/v3/src/v3/folders_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/v3/src/v3/gapic_metadata.json b/owl-bot-staging/v3/src/v3/gapic_metadata.json deleted file mode 100644 index 066fbe7..0000000 --- a/owl-bot-staging/v3/src/v3/gapic_metadata.json +++ /dev/null @@ -1,585 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.resourcemanager.v3", - "libraryPackage": "@google-cloud/resource-manager", - "services": { - "Folders": { - "clients": { - "grpc": { - "libraryClient": "FoldersClient", - "rpcs": { - "GetFolder": { - "methods": [ - "getFolder" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateFolder": { - "methods": [ - "createFolder" - ] - }, - "UpdateFolder": { - "methods": [ - "updateFolder" - ] - }, - "MoveFolder": { - "methods": [ - "moveFolder" - ] - }, - "DeleteFolder": { - "methods": [ - "deleteFolder" - ] - }, - "UndeleteFolder": { - "methods": [ - "undeleteFolder" - ] - }, - "ListFolders": { - "methods": [ - "listFolders", - "listFoldersStream", - "listFoldersAsync" - ] - }, - "SearchFolders": { - "methods": [ - "searchFolders", - "searchFoldersStream", - "searchFoldersAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "FoldersClient", - "rpcs": { - "GetFolder": { - "methods": [ - "getFolder" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateFolder": { - "methods": [ - "createFolder" - ] - }, - "UpdateFolder": { - "methods": [ - "updateFolder" - ] - }, - "MoveFolder": { - "methods": [ - "moveFolder" - ] - }, - "DeleteFolder": { - "methods": [ - "deleteFolder" - ] - }, - "UndeleteFolder": { - "methods": [ - "undeleteFolder" - ] - }, - "ListFolders": { - "methods": [ - "listFolders", - "listFoldersStream", - "listFoldersAsync" - ] - }, - "SearchFolders": { - "methods": [ - "searchFolders", - "searchFoldersStream", - "searchFoldersAsync" - ] - } - } - } - } - }, - "Organizations": { - "clients": { - "grpc": { - "libraryClient": "OrganizationsClient", - "rpcs": { - "GetOrganization": { - "methods": [ - "getOrganization" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "SearchOrganizations": { - "methods": [ - "searchOrganizations", - "searchOrganizationsStream", - "searchOrganizationsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "OrganizationsClient", - "rpcs": { - "GetOrganization": { - "methods": [ - "getOrganization" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "SearchOrganizations": { - "methods": [ - "searchOrganizations", - "searchOrganizationsStream", - "searchOrganizationsAsync" - ] - } - } - } - } - }, - "Projects": { - "clients": { - "grpc": { - "libraryClient": "ProjectsClient", - "rpcs": { - "GetProject": { - "methods": [ - "getProject" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateProject": { - "methods": [ - "createProject" - ] - }, - "UpdateProject": { - "methods": [ - "updateProject" - ] - }, - "MoveProject": { - "methods": [ - "moveProject" - ] - }, - "DeleteProject": { - "methods": [ - "deleteProject" - ] - }, - "UndeleteProject": { - "methods": [ - "undeleteProject" - ] - }, - "ListProjects": { - "methods": [ - "listProjects", - "listProjectsStream", - "listProjectsAsync" - ] - }, - "SearchProjects": { - "methods": [ - "searchProjects", - "searchProjectsStream", - "searchProjectsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ProjectsClient", - "rpcs": { - "GetProject": { - "methods": [ - "getProject" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateProject": { - "methods": [ - "createProject" - ] - }, - "UpdateProject": { - "methods": [ - "updateProject" - ] - }, - "MoveProject": { - "methods": [ - "moveProject" - ] - }, - "DeleteProject": { - "methods": [ - "deleteProject" - ] - }, - "UndeleteProject": { - "methods": [ - "undeleteProject" - ] - }, - "ListProjects": { - "methods": [ - "listProjects", - "listProjectsStream", - "listProjectsAsync" - ] - }, - "SearchProjects": { - "methods": [ - "searchProjects", - "searchProjectsStream", - "searchProjectsAsync" - ] - } - } - } - } - }, - "TagBindings": { - "clients": { - "grpc": { - "libraryClient": "TagBindingsClient", - "rpcs": { - "CreateTagBinding": { - "methods": [ - "createTagBinding" - ] - }, - "DeleteTagBinding": { - "methods": [ - "deleteTagBinding" - ] - }, - "ListTagBindings": { - "methods": [ - "listTagBindings", - "listTagBindingsStream", - "listTagBindingsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TagBindingsClient", - "rpcs": { - "CreateTagBinding": { - "methods": [ - "createTagBinding" - ] - }, - "DeleteTagBinding": { - "methods": [ - "deleteTagBinding" - ] - }, - "ListTagBindings": { - "methods": [ - "listTagBindings", - "listTagBindingsStream", - "listTagBindingsAsync" - ] - } - } - } - } - }, - "TagKeys": { - "clients": { - "grpc": { - "libraryClient": "TagKeysClient", - "rpcs": { - "GetTagKey": { - "methods": [ - "getTagKey" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTagKey": { - "methods": [ - "createTagKey" - ] - }, - "UpdateTagKey": { - "methods": [ - "updateTagKey" - ] - }, - "DeleteTagKey": { - "methods": [ - "deleteTagKey" - ] - }, - "ListTagKeys": { - "methods": [ - "listTagKeys", - "listTagKeysStream", - "listTagKeysAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TagKeysClient", - "rpcs": { - "GetTagKey": { - "methods": [ - "getTagKey" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTagKey": { - "methods": [ - "createTagKey" - ] - }, - "UpdateTagKey": { - "methods": [ - "updateTagKey" - ] - }, - "DeleteTagKey": { - "methods": [ - "deleteTagKey" - ] - }, - "ListTagKeys": { - "methods": [ - "listTagKeys", - "listTagKeysStream", - "listTagKeysAsync" - ] - } - } - } - } - }, - "TagValues": { - "clients": { - "grpc": { - "libraryClient": "TagValuesClient", - "rpcs": { - "GetTagValue": { - "methods": [ - "getTagValue" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTagValue": { - "methods": [ - "createTagValue" - ] - }, - "UpdateTagValue": { - "methods": [ - "updateTagValue" - ] - }, - "DeleteTagValue": { - "methods": [ - "deleteTagValue" - ] - }, - "ListTagValues": { - "methods": [ - "listTagValues", - "listTagValuesStream", - "listTagValuesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "TagValuesClient", - "rpcs": { - "GetTagValue": { - "methods": [ - "getTagValue" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "CreateTagValue": { - "methods": [ - "createTagValue" - ] - }, - "UpdateTagValue": { - "methods": [ - "updateTagValue" - ] - }, - "DeleteTagValue": { - "methods": [ - "deleteTagValue" - ] - }, - "ListTagValues": { - "methods": [ - "listTagValues", - "listTagValuesStream", - "listTagValuesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v3/src/v3/index.ts b/owl-bot-staging/v3/src/v3/index.ts deleted file mode 100644 index dc937f5..0000000 --- a/owl-bot-staging/v3/src/v3/index.ts +++ /dev/null @@ -1,24 +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 {FoldersClient} from './folders_client'; -export {OrganizationsClient} from './organizations_client'; -export {ProjectsClient} from './projects_client'; -export {TagBindingsClient} from './tag_bindings_client'; -export {TagKeysClient} from './tag_keys_client'; -export {TagValuesClient} from './tag_values_client'; diff --git a/owl-bot-staging/v3/src/v3/organizations_client.ts b/owl-bot-staging/v3/src/v3/organizations_client.ts deleted file mode 100644 index af9b810..0000000 --- a/owl-bot-staging/v3/src/v3/organizations_client.ts +++ /dev/null @@ -1,1013 +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, 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/v3/organizations_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './organizations_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Allows users to manage their organization resources. - * @class - * @memberof v3 - */ -export class OrganizationsClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - organizationsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of OrganizationsClient. - * - * @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 OrganizationsClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - searchOrganizations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'organizations') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.Organizations', 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.organizationsStub) { - return this.organizationsStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.Organizations. - this.organizationsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Organizations') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.Organizations, - 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 organizationsStubMethods = - ['getOrganization', 'searchOrganizations', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of organizationsStubMethods) { - const callPromise = this.organizationsStub.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] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.organizationsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Fetches an organization resource identified by the specified resource name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the Organization to fetch. This is the organization's - * relative path in the API, formatted as "organizations/[organizationId]". - * For example, "organizations/1234". - * @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 [Organization]{@link google.cloud.resourcemanager.v3.Organization}. - * 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/v3/organizations.get_organization.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_GetOrganization_async - */ - getOrganization( - request?: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|undefined, {}|undefined - ]>; - getOrganization( - request: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, - {}|null|undefined>): void; - getOrganization( - request: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, - {}|null|undefined>): void; - getOrganization( - request?: protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IOrganization, - protos.google.cloud.resourcemanager.v3.IGetOrganizationRequest|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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getOrganization(request, options, callback); - } -/** - * Gets the access control policy for an organization resource. The policy may - * be empty if no such policy or resource exists. The `resource` field should - * be the organization's resource name, for example: "organizations/123". - * - * Authorization requires the IAM permission - * `resourcemanager.organizations.getIamPolicy` on the specified organization. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/organizations.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the access control policy on an organization resource. Replaces any - * existing policy. The `resource` field should be the organization's resource - * name, for example: "organizations/123". - * - * Authorization requires the IAM permission - * `resourcemanager.organizations.setIamPolicy` on the specified organization. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/organizations.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns the permissions that a caller has on the specified organization. - * The `resource` field should be the organization's resource name, - * for example: "organizations/123". - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * 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/v3/organizations.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - - /** - * Searches organization resources that are visible to the user and satisfy - * the specified filter. This method returns organizations in an unspecified - * order. New organizations do not necessarily appear at the end of the - * results, and may take a small amount of time to appear. - * - * Search will only return organizations on which the user has the permission - * `resourcemanager.organizations.get` - * - * @param {Object} request - * The request object that will be sent. - * @param {number} [request.pageSize] - * Optional. The maximum number of organizations to return in the response. - * If unspecified, server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `SearchOrganizations` - * that indicates from where listing should continue. - * @param {string} [request.query] - * Optional. An optional query string used to filter the Organizations to return in - * the response. Query rules are case-insensitive. - * - * ``` - * | Field | Description | - * |------------------|--------------------------------------------| - * | directoryCustomerId, owner.directoryCustomerId | Filters by directory - * customer id. | - * | domain | Filters by domain. | - * ``` - * - * Organizations may be queried by `directoryCustomerId` or by - * `domain`, where the domain is a G Suite domain, for example: - * - * * Query `directorycustomerid:123456789` returns Organization - * resources with `owner.directory_customer_id` equal to `123456789`. - * * Query `domain:google.com` returns Organization resources corresponding - * to the domain `google.com`. - * @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 [Organization]{@link google.cloud.resourcemanager.v3.Organization}. - * 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 `searchOrganizationsAsync()` - * 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. - */ - searchOrganizations( - request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IOrganization[], - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse - ]>; - searchOrganizations( - request: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IOrganization>): void; - searchOrganizations( - request: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IOrganization>): void; - searchOrganizations( - request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IOrganization>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IOrganization>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IOrganization[], - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchOrganizationsResponse - ]>|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 || {}; - this.initialize(); - return this.innerApiCalls.searchOrganizations(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 {number} [request.pageSize] - * Optional. The maximum number of organizations to return in the response. - * If unspecified, server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `SearchOrganizations` - * that indicates from where listing should continue. - * @param {string} [request.query] - * Optional. An optional query string used to filter the Organizations to return in - * the response. Query rules are case-insensitive. - * - * ``` - * | Field | Description | - * |------------------|--------------------------------------------| - * | directoryCustomerId, owner.directoryCustomerId | Filters by directory - * customer id. | - * | domain | Filters by domain. | - * ``` - * - * Organizations may be queried by `directoryCustomerId` or by - * `domain`, where the domain is a G Suite domain, for example: - * - * * Query `directorycustomerid:123456789` returns Organization - * resources with `owner.directory_customer_id` equal to `123456789`. - * * Query `domain:google.com` returns Organization resources corresponding - * to the domain `google.com`. - * @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 [Organization]{@link google.cloud.resourcemanager.v3.Organization} 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 `searchOrganizationsAsync()` - * 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. - */ - searchOrganizationsStream( - request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchOrganizations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchOrganizations.createStream( - this.innerApiCalls.searchOrganizations as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchOrganizations`, 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 {number} [request.pageSize] - * Optional. The maximum number of organizations to return in the response. - * If unspecified, server picks an appropriate default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `SearchOrganizations` - * that indicates from where listing should continue. - * @param {string} [request.query] - * Optional. An optional query string used to filter the Organizations to return in - * the response. Query rules are case-insensitive. - * - * ``` - * | Field | Description | - * |------------------|--------------------------------------------| - * | directoryCustomerId, owner.directoryCustomerId | Filters by directory - * customer id. | - * | domain | Filters by domain. | - * ``` - * - * Organizations may be queried by `directoryCustomerId` or by - * `domain`, where the domain is a G Suite domain, for example: - * - * * Query `directorycustomerid:123456789` returns Organization - * resources with `owner.directory_customer_id` equal to `123456789`. - * * Query `domain:google.com` returns Organization resources corresponding - * to the domain `google.com`. - * @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 - * [Organization]{@link google.cloud.resourcemanager.v3.Organization}. 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/v3/organizations.search_organizations.js - * region_tag:cloudresourcemanager_v3_generated_Organizations_SearchOrganizations_async - */ - searchOrganizationsAsync( - request?: protos.google.cloud.resourcemanager.v3.ISearchOrganizationsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchOrganizations']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchOrganizations.asyncIterate( - this.innerApiCalls['searchOrganizations'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.organizationsStub && !this._terminated) { - return this.organizationsStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v3/src/v3/organizations_client_config.json b/owl-bot-staging/v3/src/v3/organizations_client_config.json deleted file mode 100644 index ca62d91..0000000 --- a/owl-bot-staging/v3/src/v3/organizations_client_config.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.Organizations": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "GetOrganization": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SearchOrganizations": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v3/src/v3/organizations_proto_list.json b/owl-bot-staging/v3/src/v3/organizations_proto_list.json deleted file mode 100644 index 0c00660..0000000 --- a/owl-bot-staging/v3/src/v3/organizations_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/v3/src/v3/projects_client.ts b/owl-bot-staging/v3/src/v3/projects_client.ts deleted file mode 100644 index 4dcb4cd..0000000 --- a/owl-bot-staging/v3/src/v3/projects_client.ts +++ /dev/null @@ -1,1896 +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/v3/projects_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './projects_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Manages Google Cloud Projects. - * @class - * @memberof v3 - */ -export class ProjectsClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - projectsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ProjectsClient. - * - * @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 ProjectsClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listProjects: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projects'), - searchProjects: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'projects') - }; - - 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.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const createProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateProjectMetadata') as gax.protobuf.Type; - const updateProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const updateProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UpdateProjectMetadata') as gax.protobuf.Type; - const moveProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const moveProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.MoveProjectMetadata') as gax.protobuf.Type; - const deleteProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const deleteProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteProjectMetadata') as gax.protobuf.Type; - const undeleteProjectResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.Project') as gax.protobuf.Type; - const undeleteProjectMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UndeleteProjectMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createProjectResponse.decode.bind(createProjectResponse), - createProjectMetadata.decode.bind(createProjectMetadata)), - updateProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateProjectResponse.decode.bind(updateProjectResponse), - updateProjectMetadata.decode.bind(updateProjectMetadata)), - moveProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - moveProjectResponse.decode.bind(moveProjectResponse), - moveProjectMetadata.decode.bind(moveProjectMetadata)), - deleteProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteProjectResponse.decode.bind(deleteProjectResponse), - deleteProjectMetadata.decode.bind(deleteProjectMetadata)), - undeleteProject: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - undeleteProjectResponse.decode.bind(undeleteProjectResponse), - undeleteProjectMetadata.decode.bind(undeleteProjectMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.Projects', 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.projectsStub) { - return this.projectsStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.Projects. - this.projectsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.Projects') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.Projects, - 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 projectsStubMethods = - ['getProject', 'listProjects', 'searchProjects', 'createProject', 'updateProject', 'moveProject', 'deleteProject', 'undeleteProject', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of projectsStubMethods) { - const callPromise = this.projectsStub.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.projectsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Retrieves the project identified by the specified `name` (for example, - * `projects/415104041262`). - * - * The caller must have `resourcemanager.projects.get` permission - * for this project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the project (for example, `projects/415104041262`). - * @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 [Project]{@link google.cloud.resourcemanager.v3.Project}. - * 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/v3/projects.get_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_GetProject_async - */ - getProject( - request?: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|undefined, {}|undefined - ]>; - getProject( - request: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, - {}|null|undefined>): void; - getProject( - request: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, - {}|null|undefined>): void; - getProject( - request?: protos.google.cloud.resourcemanager.v3.IGetProjectRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject, - protos.google.cloud.resourcemanager.v3.IGetProjectRequest|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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getProject(request, options, callback); - } -/** - * Returns the IAM access control policy for the specified project. - * Permission is denied if the policy or the resource do not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/projects.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Projects_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the IAM access control policy for the specified project. - * - * CAUTION: This method will replace the existing policy, and cannot be used - * to append additional IAM settings. - * - * Note: Removing service accounts from policies or changing their roles can - * render services completely inoperable. It is important to understand how - * the service account is being used before removing or updating its roles. - * - * The following constraints apply when using `setIamPolicy()`: - * - * + Project does not support `allUsers` and `allAuthenticatedUsers` as - * `members` in a `Binding` of a `Policy`. - * - * + The owner role can be granted to a `user`, `serviceAccount`, or a group - * that is part of an organization. For example, - * group@myownpersonaldomain.com could be added as an owner to a project in - * the myownpersonaldomain.com organization, but not the examplepetstore.com - * organization. - * - * + Service accounts can be made owners of a project directly - * without any restrictions. However, to be added as an owner, a user must be - * invited using the Cloud Platform console and must accept the invitation. - * - * + A user cannot be granted the owner role using `setIamPolicy()`. The user - * must be granted the owner role using the Cloud Platform Console and must - * explicitly accept the invitation. - * - * + Invitations to grant the owner role cannot be sent using - * `setIamPolicy()`; - * they must be sent only using the Cloud Platform Console. - * - * + Membership changes that leave the project without any owners that have - * accepted the Terms of Service (ToS) will be rejected. - * - * + If the project is not part of an organization, there must be at least - * one owner who has accepted the Terms of Service (ToS) agreement in the - * policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner - * from the policy will fail. This restriction also applies to legacy - * projects that no longer have owners who have accepted the ToS. Edits to - * IAM policies will be rejected until the lack of a ToS-accepting owner is - * rectified. - * - * + Calling this method requires enabling the App Engine Admin API. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/projects.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_Projects_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * 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/v3/projects.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_Projects_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Request that a new project be created. The result is an `Operation` which - * can be used to track the creation process. This process usually takes a few - * seconds, but can sometimes take much longer. The tracking `Operation` is - * automatically deleted after a few hours, so there is no need to call - * `DeleteOperation`. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.Project} request.project - * Required. The Project to create. - * - * Project ID is required. If the requested ID is unavailable, the request - * fails. - * - * If the `parent` field is set, the `resourcemanager.projects.create` - * permission is checked on the parent resource. If no parent is set and - * the authorization credentials belong to an Organziation, the parent - * will be set to that Organization. - * @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/v3/projects.create_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_CreateProject_async - */ - createProject( - request?: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createProject( - request: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createProject( - request: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createProject( - request?: protos.google.cloud.resourcemanager.v3.ICreateProjectRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.createProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createProject()`. - * @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/v3/projects.create_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_CreateProject_async - */ - async checkCreateProjectProgress(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.createProject, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the `display_name` and labels of the project identified by the - * specified `name` (for example, `projects/415104041262`). Deleting all - * labels requires an update mask for labels field. - * - * The caller must have `resourcemanager.projects.update` permission for this - * project. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.Project} request.project - * Required. The new definition of the project. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. An update mask to selectively update fields. - * @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/v3/projects.update_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_UpdateProject_async - */ - updateProject( - request?: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateProject( - request: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateProject( - request: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateProject( - request?: protos.google.cloud.resourcemanager.v3.IUpdateProjectRequest, - 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.name': request.project!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateProject()`. - * @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/v3/projects.update_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_UpdateProject_async - */ - async checkUpdateProjectProgress(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.updateProject, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Move a project to another place in your resource hierarchy, under a new - * resource parent. - * - * Returns an operation which can be used to track the process of the project - * move workflow. - * Upon success, the `Operation.response` field will be populated with the - * moved project. - * - * The caller must have `resourcemanager.projects.update` permission on the - * project and have `resourcemanager.projects.move` permission on the - * project's current and proposed new parent. - * - * - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the project to move. - * @param {string} request.destinationParent - * Required. The new parent to move the Project under. - * @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/v3/projects.move_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_MoveProject_async - */ - moveProject( - request?: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - moveProject( - request: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - moveProject( - request: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - moveProject( - request?: protos.google.cloud.resourcemanager.v3.IMoveProjectRequest, - 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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.moveProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `moveProject()`. - * @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/v3/projects.move_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_MoveProject_async - */ - async checkMoveProjectProgress(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.moveProject, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Marks the project identified by the specified - * `name` (for example, `projects/415104041262`) for deletion. - * - * This method will only affect the project if it has a lifecycle state of - * {@link google.cloud.resourcemanager.v3.Project.State.ACTIVE|ACTIVE}. - * - * This method changes the Project's lifecycle state from - * {@link google.cloud.resourcemanager.v3.Project.State.ACTIVE|ACTIVE} - * to {@link google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED|DELETE_REQUESTED}. - * The deletion starts at an unspecified time, - * at which point the Project is no longer accessible. - * - * Until the deletion completes, you can check the lifecycle state - * checked by retrieving the project with [GetProject] - * [google.cloud.resourcemanager.v3.Projects.GetProject], - * and the project remains visible to [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects]. - * However, you cannot update the project. - * - * After the deletion completes, the project is not retrievable by - * the [GetProject] - * [google.cloud.resourcemanager.v3.Projects.GetProject], - * [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects], and - * {@link google.cloud.resourcemanager.v3.Projects.SearchProjects|SearchProjects} - * methods. - * - * This method behaves idempotently, such that deleting a `DELETE_REQUESTED` - * project will not cause an error, but also won't do anything. - * - * The caller must have `resourcemanager.projects.delete` permissions for this - * project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Project (for example, `projects/415104041262`). - * @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/v3/projects.delete_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_DeleteProject_async - */ - deleteProject( - request?: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteProject( - request: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProject( - request: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteProject( - request?: protos.google.cloud.resourcemanager.v3.IDeleteProjectRequest, - 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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteProject()`. - * @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/v3/projects.delete_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_DeleteProject_async - */ - async checkDeleteProjectProgress(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.deleteProject, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Restores the project identified by the specified - * `name` (for example, `projects/415104041262`). - * You can only use this method for a project that has a lifecycle state of - * [DELETE_REQUESTED] - * [Projects.State.DELETE_REQUESTED]. - * After deletion starts, the project cannot be restored. - * - * The caller must have `resourcemanager.projects.undelete` permission for - * this project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the project (for example, `projects/415104041262`). - * - * Required. - * @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/v3/projects.undelete_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_UndeleteProject_async - */ - undeleteProject( - request?: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - undeleteProject( - request: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeleteProject( - request: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - undeleteProject( - request?: protos.google.cloud.resourcemanager.v3.IUndeleteProjectRequest, - 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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.undeleteProject(request, options, callback); - } -/** - * Check the status of the long running operation returned by `undeleteProject()`. - * @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/v3/projects.undelete_project.js - * region_tag:cloudresourcemanager_v3_generated_Projects_UndeleteProject_async - */ - async checkUndeleteProjectProgress(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.undeleteProject, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists projects that are direct children of the specified folder or - * organization resource. `list()` provides a strongly consistent view of the - * projects underneath the specified parent resource. `list()` returns - * projects sorted based upon the (ascending) lexical ordering of their - * `display_name`. The caller must have `resourcemanager.projects.list` - * permission on the identified parent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent resource to list projects under. - * - * For example, setting this field to 'folders/1234' would list all projects - * directly under that folder. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects] - * that indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @param {boolean} [request.showDeleted] - * Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be - * returned. Normally only `ACTIVE` projects are returned. - * @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 [Project]{@link google.cloud.resourcemanager.v3.Project}. - * 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 `listProjectsAsync()` - * 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. - */ - listProjects( - request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject[], - protos.google.cloud.resourcemanager.v3.IListProjectsRequest|null, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse - ]>; - listProjects( - request: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): void; - listProjects( - request: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): void; - listProjects( - request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject[], - protos.google.cloud.resourcemanager.v3.IListProjectsRequest|null, - protos.google.cloud.resourcemanager.v3.IListProjectsResponse - ]>|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 || {}; - this.initialize(); - return this.innerApiCalls.listProjects(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.parent - * Required. The name of the parent resource to list projects under. - * - * For example, setting this field to 'folders/1234' would list all projects - * directly under that folder. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects] - * that indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @param {boolean} [request.showDeleted] - * Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be - * returned. Normally only `ACTIVE` projects are returned. - * @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 [Project]{@link google.cloud.resourcemanager.v3.Project} 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 `listProjectsAsync()` - * 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. - */ - listProjectsStream( - request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listProjects']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProjects.createStream( - this.innerApiCalls.listProjects as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProjects`, 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.parent - * Required. The name of the parent resource to list projects under. - * - * For example, setting this field to 'folders/1234' would list all projects - * directly under that folder. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects] - * that indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @param {boolean} [request.showDeleted] - * Optional. Indicate that projects in the `DELETE_REQUESTED` state should also be - * returned. Normally only `ACTIVE` projects are returned. - * @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 - * [Project]{@link google.cloud.resourcemanager.v3.Project}. 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/v3/projects.list_projects.js - * region_tag:cloudresourcemanager_v3_generated_Projects_ListProjects_async - */ - listProjectsAsync( - request?: protos.google.cloud.resourcemanager.v3.IListProjectsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listProjects']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProjects.asyncIterate( - this.innerApiCalls['listProjects'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * Search for projects that the caller has both `resourcemanager.projects.get` - * permission on, and also satisfy the specified query. - * - * This method returns projects in an unspecified order. - * - * This method is eventually consistent with project mutations; this means - * that a newly created project may not appear in the results or recent - * updates to an existing project may not be reflected in the results. To - * retrieve the latest state of a project, use the - * {@link google.cloud.resourcemanager.v3.Projects.GetProject|GetProject} method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} [request.query] - * Optional. A query string for searching for projects that the caller has - * `resourcemanager.projects.get` permission to. If multiple fields are - * included in the query, the it will return results that match any of the - * fields. Some eligible fields are: - * - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------------| - * | displayName, name | Filters by displayName. | - * | parent | Project's parent. (for example: folders/123, - * organizations/*) Prefer parent field over parent.type and parent.id. | - * | parent.type | Parent's type: `folder` or `organization`. | - * | parent.id | Parent's id number (for example: 123) | - * | id, projectId | Filters by projectId. | - * | state, lifecycleState | Filters by state. | - * | labels | Filters by label name or value. | - * | labels. (where *key* is the name of a label) | Filters by label - * name. | - * ``` - * - * Search expressions are case insensitive. - * - * Some examples queries: - * - * ``` - * | Query | Description | - * |------------------|-----------------------------------------------------| - * | name:how* | The project's name starts with "how". | - * | name:Howl | The project's name is `Howl` or `howl`. | - * | name:HOWL | Equivalent to above. | - * | NAME:howl | Equivalent to above. | - * | labels.color:* | The project has the label `color`. | - * | labels.color:red | The project's label `color` has the value `red`. | - * | labels.color:red labels.size:big | The project's label `color` has - * the value `red` and its label `size` has the value `big`. | - * ``` - * - * If no query is specified, the call will return projects for which the user - * has the `resourcemanager.projects.get` permission. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects] - * that indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @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 [Project]{@link google.cloud.resourcemanager.v3.Project}. - * 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 `searchProjectsAsync()` - * 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. - */ - searchProjects( - request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject[], - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse - ]>; - searchProjects( - request: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): void; - searchProjects( - request: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): void; - searchProjects( - request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.IProject>): - Promise<[ - protos.google.cloud.resourcemanager.v3.IProject[], - protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest|null, - protos.google.cloud.resourcemanager.v3.ISearchProjectsResponse - ]>|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 || {}; - this.initialize(); - return this.innerApiCalls.searchProjects(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.query] - * Optional. A query string for searching for projects that the caller has - * `resourcemanager.projects.get` permission to. If multiple fields are - * included in the query, the it will return results that match any of the - * fields. Some eligible fields are: - * - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------------| - * | displayName, name | Filters by displayName. | - * | parent | Project's parent. (for example: folders/123, - * organizations/*) Prefer parent field over parent.type and parent.id. | - * | parent.type | Parent's type: `folder` or `organization`. | - * | parent.id | Parent's id number (for example: 123) | - * | id, projectId | Filters by projectId. | - * | state, lifecycleState | Filters by state. | - * | labels | Filters by label name or value. | - * | labels. (where *key* is the name of a label) | Filters by label - * name. | - * ``` - * - * Search expressions are case insensitive. - * - * Some examples queries: - * - * ``` - * | Query | Description | - * |------------------|-----------------------------------------------------| - * | name:how* | The project's name starts with "how". | - * | name:Howl | The project's name is `Howl` or `howl`. | - * | name:HOWL | Equivalent to above. | - * | NAME:howl | Equivalent to above. | - * | labels.color:* | The project has the label `color`. | - * | labels.color:red | The project's label `color` has the value `red`. | - * | labels.color:red labels.size:big | The project's label `color` has - * the value `red` and its label `size` has the value `big`. | - * ``` - * - * If no query is specified, the call will return projects for which the user - * has the `resourcemanager.projects.get` permission. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects] - * that indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @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 [Project]{@link google.cloud.resourcemanager.v3.Project} 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 `searchProjectsAsync()` - * 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. - */ - searchProjectsStream( - request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchProjects']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchProjects.createStream( - this.innerApiCalls.searchProjects as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `searchProjects`, 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.query] - * Optional. A query string for searching for projects that the caller has - * `resourcemanager.projects.get` permission to. If multiple fields are - * included in the query, the it will return results that match any of the - * fields. Some eligible fields are: - * - * ``` - * | Field | Description | - * |-------------------------|----------------------------------------------| - * | displayName, name | Filters by displayName. | - * | parent | Project's parent. (for example: folders/123, - * organizations/*) Prefer parent field over parent.type and parent.id. | - * | parent.type | Parent's type: `folder` or `organization`. | - * | parent.id | Parent's id number (for example: 123) | - * | id, projectId | Filters by projectId. | - * | state, lifecycleState | Filters by state. | - * | labels | Filters by label name or value. | - * | labels. (where *key* is the name of a label) | Filters by label - * name. | - * ``` - * - * Search expressions are case insensitive. - * - * Some examples queries: - * - * ``` - * | Query | Description | - * |------------------|-----------------------------------------------------| - * | name:how* | The project's name starts with "how". | - * | name:Howl | The project's name is `Howl` or `howl`. | - * | name:HOWL | Equivalent to above. | - * | NAME:howl | Equivalent to above. | - * | labels.color:* | The project has the label `color`. | - * | labels.color:red | The project's label `color` has the value `red`. | - * | labels.color:red labels.size:big | The project's label `color` has - * the value `red` and its label `size` has the value `big`. | - * ``` - * - * If no query is specified, the call will return projects for which the user - * has the `resourcemanager.projects.get` permission. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to [ListProjects] - * [google.cloud.resourcemanager.v3.Projects.ListProjects] - * that indicates from where listing should continue. - * @param {number} [request.pageSize] - * Optional. The maximum number of projects to return in the response. - * The server can return fewer projects than requested. - * If unspecified, server picks an appropriate default. - * @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 - * [Project]{@link google.cloud.resourcemanager.v3.Project}. 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/v3/projects.search_projects.js - * region_tag:cloudresourcemanager_v3_generated_Projects_SearchProjects_async - */ - searchProjectsAsync( - request?: protos.google.cloud.resourcemanager.v3.ISearchProjectsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['searchProjects']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.searchProjects.asyncIterate( - this.innerApiCalls['searchProjects'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.projectsStub && !this._terminated) { - return this.projectsStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v3/src/v3/projects_client_config.json b/owl-bot-staging/v3/src/v3/projects_client_config.json deleted file mode 100644 index f1308d4..0000000 --- a/owl-bot-staging/v3/src/v3/projects_client_config.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.Projects": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "GetProject": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "ListProjects": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SearchProjects": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "MoveProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UndeleteProject": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v3/src/v3/projects_proto_list.json b/owl-bot-staging/v3/src/v3/projects_proto_list.json deleted file mode 100644 index 0c00660..0000000 --- a/owl-bot-staging/v3/src/v3/projects_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/v3/src/v3/tag_bindings_client.ts b/owl-bot-staging/v3/src/v3/tag_bindings_client.ts deleted file mode 100644 index 19e49e2..0000000 --- a/owl-bot-staging/v3/src/v3/tag_bindings_client.ts +++ /dev/null @@ -1,867 +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/v3/tag_bindings_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tag_bindings_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Allow users to create and manage TagBindings between TagValues and - * different cloud resources throughout the GCP resource hierarchy. - * @class - * @memberof v3 - */ -export class TagBindingsClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - tagBindingsStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TagBindingsClient. - * - * @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 TagBindingsClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listTagBindings: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagBindings') - }; - - 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.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createTagBindingResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagBinding') as gax.protobuf.Type; - const createTagBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateTagBindingMetadata') as gax.protobuf.Type; - const deleteTagBindingResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; - const deleteTagBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteTagBindingMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createTagBinding: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createTagBindingResponse.decode.bind(createTagBindingResponse), - createTagBindingMetadata.decode.bind(createTagBindingMetadata)), - deleteTagBinding: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteTagBindingResponse.decode.bind(deleteTagBindingResponse), - deleteTagBindingMetadata.decode.bind(deleteTagBindingMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.TagBindings', 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.tagBindingsStub) { - return this.tagBindingsStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.TagBindings. - this.tagBindingsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagBindings') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.TagBindings, - 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 tagBindingsStubMethods = - ['listTagBindings', 'createTagBinding', 'deleteTagBinding']; - for (const methodName of tagBindingsStubMethods) { - const callPromise = this.tagBindingsStub.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.tagBindingsStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- - -/** - * Creates a TagBinding between a TagValue and a cloud resource - * (currently project, folder, or organization). - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagBinding} request.tagBinding - * Required. The TagBinding to be created. - * @param {boolean} [request.validateOnly] - * Optional. Set to true to perform the validations necessary for creating the resource, - * but not actually perform the action. - * @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/v3/tag_bindings.create_tag_binding.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async - */ - createTagBinding( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createTagBinding( - request: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagBinding( - request: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagBinding( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagBindingRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.createTagBinding(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createTagBinding()`. - * @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/v3/tag_bindings.create_tag_binding.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_CreateTagBinding_async - */ - async checkCreateTagBindingProgress(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.createTagBinding, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a TagBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the TagBinding. This is a String of the form: - * `tagBindings/{id}` (e.g. - * `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). - * @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/v3/tag_bindings.delete_tag_binding.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async - */ - deleteTagBinding( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteTagBinding( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagBinding( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagBinding( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagBindingRequest, - 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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteTagBinding(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteTagBinding()`. - * @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/v3/tag_bindings.delete_tag_binding.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_DeleteTagBinding_async - */ - async checkDeleteTagBindingProgress(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.deleteTagBinding, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists the TagBindings for the given cloud resource, as specified with - * `parent`. - * - * NOTE: The `parent` field is expected to be a full resource name: - * https://cloud.google.com/apis/design/resource_names#full_resource_name - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The full resource name of a resource for which you want to list existing - * TagBindings. - * E.g. "//cloudresourcemanager.googleapis.com/projects/123" - * @param {number} [request.pageSize] - * Optional. The maximum number of TagBindings to return in the response. The server - * allows a maximum of 300 TagBindings to return. If unspecified, the server - * will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagBindings` - * that indicates where this listing should continue from. - * @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 [TagBinding]{@link google.cloud.resourcemanager.v3.TagBinding}. - * 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 `listTagBindingsAsync()` - * 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. - */ - listTagBindings( - request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagBinding[], - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse - ]>; - listTagBindings( - request: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagBinding>): void; - listTagBindings( - request: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagBinding>): void; - listTagBindings( - request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagBinding>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagBinding>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagBinding[], - protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagBindingsResponse - ]>|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 || {}; - this.initialize(); - return this.innerApiCalls.listTagBindings(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.parent - * Required. The full resource name of a resource for which you want to list existing - * TagBindings. - * E.g. "//cloudresourcemanager.googleapis.com/projects/123" - * @param {number} [request.pageSize] - * Optional. The maximum number of TagBindings to return in the response. The server - * allows a maximum of 300 TagBindings to return. If unspecified, the server - * will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagBindings` - * that indicates where this listing should continue from. - * @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 [TagBinding]{@link google.cloud.resourcemanager.v3.TagBinding} 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 `listTagBindingsAsync()` - * 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. - */ - listTagBindingsStream( - request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagBindings']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagBindings.createStream( - this.innerApiCalls.listTagBindings as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTagBindings`, 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.parent - * Required. The full resource name of a resource for which you want to list existing - * TagBindings. - * E.g. "//cloudresourcemanager.googleapis.com/projects/123" - * @param {number} [request.pageSize] - * Optional. The maximum number of TagBindings to return in the response. The server - * allows a maximum of 300 TagBindings to return. If unspecified, the server - * will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagBindings` - * that indicates where this listing should continue from. - * @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 - * [TagBinding]{@link google.cloud.resourcemanager.v3.TagBinding}. 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/v3/tag_bindings.list_tag_bindings.js - * region_tag:cloudresourcemanager_v3_generated_TagBindings_ListTagBindings_async - */ - listTagBindingsAsync( - request?: protos.google.cloud.resourcemanager.v3.IListTagBindingsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagBindings']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagBindings.asyncIterate( - this.innerApiCalls['listTagBindings'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.tagBindingsStub && !this._terminated) { - return this.tagBindingsStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v3/src/v3/tag_bindings_client_config.json b/owl-bot-staging/v3/src/v3/tag_bindings_client_config.json deleted file mode 100644 index 25129f4..0000000 --- a/owl-bot-staging/v3/src/v3/tag_bindings_client_config.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.TagBindings": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "ListTagBindings": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "CreateTagBinding": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteTagBinding": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v3/src/v3/tag_bindings_proto_list.json b/owl-bot-staging/v3/src/v3/tag_bindings_proto_list.json deleted file mode 100644 index 0c00660..0000000 --- a/owl-bot-staging/v3/src/v3/tag_bindings_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/v3/src/v3/tag_keys_client.ts b/owl-bot-staging/v3/src/v3/tag_keys_client.ts deleted file mode 100644 index 586c1de..0000000 --- a/owl-bot-staging/v3/src/v3/tag_keys_client.ts +++ /dev/null @@ -1,1299 +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/v3/tag_keys_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tag_keys_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Allow users to create and manage tag keys. - * @class - * @memberof v3 - */ -export class TagKeysClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - tagKeysStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TagKeysClient. - * - * @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 TagKeysClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listTagKeys: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagKeys') - }; - - 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.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createTagKeyResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; - const createTagKeyMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateTagKeyMetadata') as gax.protobuf.Type; - const updateTagKeyResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; - const updateTagKeyMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UpdateTagKeyMetadata') as gax.protobuf.Type; - const deleteTagKeyResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagKey') as gax.protobuf.Type; - const deleteTagKeyMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteTagKeyMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createTagKey: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createTagKeyResponse.decode.bind(createTagKeyResponse), - createTagKeyMetadata.decode.bind(createTagKeyMetadata)), - updateTagKey: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateTagKeyResponse.decode.bind(updateTagKeyResponse), - updateTagKeyMetadata.decode.bind(updateTagKeyMetadata)), - deleteTagKey: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteTagKeyResponse.decode.bind(deleteTagKeyResponse), - deleteTagKeyMetadata.decode.bind(deleteTagKeyMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.TagKeys', 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.tagKeysStub) { - return this.tagKeysStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.TagKeys. - this.tagKeysStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagKeys') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.TagKeys, - 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 tagKeysStubMethods = - ['listTagKeys', 'getTagKey', 'createTagKey', 'updateTagKey', 'deleteTagKey', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of tagKeysStubMethods) { - const callPromise = this.tagKeysStub.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.tagKeysStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the - * key does not exist or the user does not have permission to view it. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A resource name in the format `tagKeys/{id}`, such as - * `tagKeys/123`. - * @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 [TagKey]{@link google.cloud.resourcemanager.v3.TagKey}. - * 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/v3/tag_keys.get_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetTagKey_async - */ - getTagKey( - request?: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|undefined, {}|undefined - ]>; - getTagKey( - request: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, - {}|null|undefined>): void; - getTagKey( - request: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, - {}|null|undefined>): void; - getTagKey( - request?: protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey, - protos.google.cloud.resourcemanager.v3.IGetTagKeyRequest|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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getTagKey(request, options, callback); - } -/** - * Gets the access control policy for a TagKey. The returned policy may be - * empty if no such policy or resource exists. The `resource` field should - * be the TagKey's resource name. For example, "tagKeys/1234". - * The caller must have - * `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on - * the specified TagKey. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/tag_keys.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the access control policy on a TagKey, replacing any existing - * policy. The `resource` field should be the TagKey's resource name. - * For example, "tagKeys/1234". - * The caller must have `resourcemanager.tagKeys.setIamPolicy` permission - * on the identified tagValue. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/tag_keys.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified TagKey. - * The `resource` field should be the TagKey's resource name. - * For example, "tagKeys/1234". - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * 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/v3/tag_keys.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a new TagKey. If another request with the same parameters is - * sent while the original request is in process, the second request - * will receive an error. A maximum of 300 TagKeys can exist under a parent at - * any given time. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagKey} request.tagKey - * Required. The TagKey to be created. Only fields `short_name`, `description`, - * and `parent` are considered during the creation request. - * @param {boolean} [request.validateOnly] - * Optional. Set to true to perform validations necessary for creating the resource, but - * not actually perform the action. - * @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/v3/tag_keys.create_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async - */ - createTagKey( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createTagKey( - request: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagKey( - request: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagKey( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagKeyRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.createTagKey(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createTagKey()`. - * @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/v3/tag_keys.create_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_CreateTagKey_async - */ - async checkCreateTagKeyProgress(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.createTagKey, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the attributes of the TagKey resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagKey} request.tagKey - * Required. The new definition of the TagKey. Only the `description` and `etag` fields - * can be updated by this request. If the `etag` field is not empty, it - * must match the `etag` field of the existing tag key. Otherwise, - * `FAILED_PRECONDITION` will be returned. - * @param {google.protobuf.FieldMask} request.updateMask - * Fields to be updated. The mask may only contain `description` or - * `etag`. If omitted entirely, both `description` and `etag` are assumed to - * be significant. - * @param {boolean} request.validateOnly - * Set as true to perform validations necessary for updating the resource, but - * not actually perform the action. - * @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/v3/tag_keys.update_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async - */ - updateTagKey( - request?: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateTagKey( - request: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateTagKey( - request: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateTagKey( - request?: protos.google.cloud.resourcemanager.v3.IUpdateTagKeyRequest, - 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({ - 'tag_key.name': request.tagKey!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateTagKey(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateTagKey()`. - * @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/v3/tag_keys.update_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_UpdateTagKey_async - */ - async checkUpdateTagKeyProgress(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.updateTagKey, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a TagKey. The TagKey cannot be deleted if it has any child - * TagValues. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of a TagKey to be deleted in the format `tagKeys/123`. - * The TagKey cannot be a parent of any existing TagValues or it will not be - * deleted successfully. - * @param {boolean} [request.validateOnly] - * Optional. Set as true to perform validations necessary for deletion, but not actually - * perform the action. - * @param {string} [request.etag] - * Optional. The etag known to the client for the expected state of the TagKey. This is - * to be used for optimistic concurrency. - * @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/v3/tag_keys.delete_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async - */ - deleteTagKey( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteTagKey( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagKey( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagKey( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagKeyRequest, - 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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteTagKey(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteTagKey()`. - * @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/v3/tag_keys.delete_tag_key.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_DeleteTagKey_async - */ - async checkDeleteTagKeyProgress(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.deleteTagKey, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all TagKeys for a parent resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the new TagKey's parent. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagKeys to return in the response. The server allows - * a maximum of 300 TagKeys to return. If unspecified, the server will use 100 - * as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagKey` - * that indicates where this listing should continue from. - * @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 [TagKey]{@link google.cloud.resourcemanager.v3.TagKey}. - * 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 `listTagKeysAsync()` - * 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. - */ - listTagKeys( - request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey[], - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse - ]>; - listTagKeys( - request: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagKey>): void; - listTagKeys( - request: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagKey>): void; - listTagKeys( - request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagKey>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagKey>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagKey[], - protos.google.cloud.resourcemanager.v3.IListTagKeysRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagKeysResponse - ]>|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 || {}; - this.initialize(); - return this.innerApiCalls.listTagKeys(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.parent - * Required. The resource name of the new TagKey's parent. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagKeys to return in the response. The server allows - * a maximum of 300 TagKeys to return. If unspecified, the server will use 100 - * as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagKey` - * that indicates where this listing should continue from. - * @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 [TagKey]{@link google.cloud.resourcemanager.v3.TagKey} 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 `listTagKeysAsync()` - * 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. - */ - listTagKeysStream( - request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagKeys']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagKeys.createStream( - this.innerApiCalls.listTagKeys as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTagKeys`, 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.parent - * Required. The resource name of the new TagKey's parent. - * Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagKeys to return in the response. The server allows - * a maximum of 300 TagKeys to return. If unspecified, the server will use 100 - * as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagKey` - * that indicates where this listing should continue from. - * @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 - * [TagKey]{@link google.cloud.resourcemanager.v3.TagKey}. 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/v3/tag_keys.list_tag_keys.js - * region_tag:cloudresourcemanager_v3_generated_TagKeys_ListTagKeys_async - */ - listTagKeysAsync( - request?: protos.google.cloud.resourcemanager.v3.IListTagKeysRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagKeys']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagKeys.asyncIterate( - this.innerApiCalls['listTagKeys'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.tagKeysStub && !this._terminated) { - return this.tagKeysStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v3/src/v3/tag_keys_client_config.json b/owl-bot-staging/v3/src/v3/tag_keys_client_config.json deleted file mode 100644 index b72c651..0000000 --- a/owl-bot-staging/v3/src/v3/tag_keys_client_config.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.TagKeys": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "ListTagKeys": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "GetTagKey": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "CreateTagKey": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateTagKey": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteTagKey": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v3/src/v3/tag_keys_proto_list.json b/owl-bot-staging/v3/src/v3/tag_keys_proto_list.json deleted file mode 100644 index 0c00660..0000000 --- a/owl-bot-staging/v3/src/v3/tag_keys_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/v3/src/v3/tag_values_client.ts b/owl-bot-staging/v3/src/v3/tag_values_client.ts deleted file mode 100644 index 9a75b3b..0000000 --- a/owl-bot-staging/v3/src/v3/tag_values_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/v3/tag_values_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './tag_values_client_config.json'; -import { operationsProtos } from 'google-gax'; -const version = require('../../../package.json').version; - -/** - * Allow users to create and manage tag values. - * @class - * @memberof v3 - */ -export class TagValuesClient { - 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}; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - tagValuesStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of TagValuesClient. - * - * @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 TagValuesClient; - 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); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - folderPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}' - ), - organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - tagBindingPathTemplate: new this._gaxModule.PathTemplate( - 'tagBindings/{tag_binding}' - ), - tagKeyPathTemplate: new this._gaxModule.PathTemplate( - 'tagKeys/{tag_key}' - ), - tagValuePathTemplate: new this._gaxModule.PathTemplate( - 'tagValues/{tag_value}' - ), - }; - - // 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 = { - listTagValues: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tagValues') - }; - - 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.GetOperation',get: '/v3/{name=operations/**}',}]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createTagValueResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; - const createTagValueMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.CreateTagValueMetadata') as gax.protobuf.Type; - const updateTagValueResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; - const updateTagValueMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.UpdateTagValueMetadata') as gax.protobuf.Type; - const deleteTagValueResponse = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.TagValue') as gax.protobuf.Type; - const deleteTagValueMetadata = protoFilesRoot.lookup( - '.google.cloud.resourcemanager.v3.DeleteTagValueMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createTagValue: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createTagValueResponse.decode.bind(createTagValueResponse), - createTagValueMetadata.decode.bind(createTagValueMetadata)), - updateTagValue: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateTagValueResponse.decode.bind(updateTagValueResponse), - updateTagValueMetadata.decode.bind(updateTagValueMetadata)), - deleteTagValue: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteTagValueResponse.decode.bind(deleteTagValueResponse), - deleteTagValueMetadata.decode.bind(deleteTagValueMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.resourcemanager.v3.TagValues', 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.tagValuesStub) { - return this.tagValuesStub; - } - - // Put together the "service stub" for - // google.cloud.resourcemanager.v3.TagValues. - this.tagValuesStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.resourcemanager.v3.TagValues') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.resourcemanager.v3.TagValues, - 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 tagValuesStubMethods = - ['listTagValues', 'getTagValue', 'createTagValue', 'updateTagValue', 'deleteTagValue', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; - for (const methodName of tagValuesStubMethods) { - const callPromise = this.tagValuesStub.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.tagValuesStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudresourcemanager.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 'cloudresourcemanager.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/cloud-platform.read-only' - ]; - } - - 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 -- - // ------------------- -/** - * Retrieves TagValue. If the TagValue or namespaced name does not exist, or - * if the user does not have permission to view it, this method will return - * `PERMISSION_DENIED`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name for TagValue to be fetched in the format `tagValues/456`. - * @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 [TagValue]{@link google.cloud.resourcemanager.v3.TagValue}. - * 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/v3/tag_values.get_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_GetTagValue_async - */ - getTagValue( - request?: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|undefined, {}|undefined - ]>; - getTagValue( - request: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, - {}|null|undefined>): void; - getTagValue( - request: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, - callback: Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, - {}|null|undefined>): void; - getTagValue( - request?: protos.google.cloud.resourcemanager.v3.IGetTagValueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue, - protos.google.cloud.resourcemanager.v3.IGetTagValueRequest|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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getTagValue(request, options, callback); - } -/** - * Gets the access control policy for a TagValue. The returned policy may be - * empty if no such policy or resource exists. The `resource` field should - * be the TagValue's resource name. For example: `tagValues/1234`. - * The caller must have the - * `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on - * the identified TagValue to get the access control policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/tag_values.get_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Sets the access control policy on a TagValue, replacing any existing - * policy. The `resource` field should be the TagValue's resource name. - * For example: `tagValues/1234`. - * The caller must have `resourcemanager.tagValues.setIamPolicy` permission - * on the identified tagValue. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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 [Policy]{@link google.iam.v1.Policy}. - * 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/v3/tag_values.set_iam_policy.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified TagValue. - * The `resource` field should be the TagValue's resource name. For example: - * `tagValues/1234`. - * - * There are no permissions required for making this API call. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * 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/v3/tag_values.test_iam_permissions.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|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({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } - -/** - * Creates a TagValue as a child of the specified TagKey. If a another - * request with the same parameters is sent while the original request is in - * process the second request will receive an error. A maximum of 300 - * TagValues can exist under a TagKey at any given time. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagValue} request.tagValue - * Required. The TagValue to be created. Only fields `short_name`, `description`, - * and `parent` are considered during the creation request. - * @param {boolean} [request.validateOnly] - * Optional. Set as true to perform the validations necessary for creating the resource, - * but not actually perform the action. - * @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/v3/tag_values.create_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async - */ - createTagValue( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createTagValue( - request: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagValue( - request: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createTagValue( - request?: protos.google.cloud.resourcemanager.v3.ICreateTagValueRequest, - 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 || {}; - this.initialize(); - return this.innerApiCalls.createTagValue(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createTagValue()`. - * @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/v3/tag_values.create_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_CreateTagValue_async - */ - async checkCreateTagValueProgress(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.createTagValue, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Updates the attributes of the TagValue resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.resourcemanager.v3.TagValue} request.tagValue - * Required. The new definition of the TagValue. Only fields `description` and `etag` - * fields can be updated by this request. If the `etag` field is nonempty, it - * must match the `etag` field of the existing ControlGroup. Otherwise, - * `FAILED_PRECONDITION` will be returned. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Fields to be updated. - * @param {boolean} [request.validateOnly] - * Optional. True to perform validations necessary for updating the resource, but not - * actually perform the action. - * @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/v3/tag_values.update_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async - */ - updateTagValue( - request?: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - updateTagValue( - request: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateTagValue( - request: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - updateTagValue( - request?: protos.google.cloud.resourcemanager.v3.IUpdateTagValueRequest, - 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({ - 'tag_value.name': request.tagValue!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateTagValue(request, options, callback); - } -/** - * Check the status of the long running operation returned by `updateTagValue()`. - * @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/v3/tag_values.update_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_UpdateTagValue_async - */ - async checkUpdateTagValueProgress(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.updateTagValue, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Deletes a TagValue. The TagValue cannot have any bindings when it is - * deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Resource name for TagValue to be deleted in the format tagValues/456. - * @param {boolean} [request.validateOnly] - * Optional. Set as true to perform the validations necessary for deletion, but not - * actually perform the action. - * @param {string} [request.etag] - * Optional. The etag known to the client for the expected state of the TagValue. This - * is to be used for optimistic concurrency. - * @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/v3/tag_values.delete_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async - */ - deleteTagValue( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - deleteTagValue( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagValue( - request: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - deleteTagValue( - request?: protos.google.cloud.resourcemanager.v3.IDeleteTagValueRequest, - 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({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteTagValue(request, options, callback); - } -/** - * Check the status of the long running operation returned by `deleteTagValue()`. - * @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/v3/tag_values.delete_tag_value.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_DeleteTagValue_async - */ - async checkDeleteTagValueProgress(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.deleteTagValue, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all TagValues for a specific TagKey. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name for TagKey, parent of the TagValues to be listed, - * in the format `tagKeys/123`. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagValues to return in the response. The server - * allows a maximum of 300 TagValues to return. If unspecified, the server - * will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagValues` - * that indicates where this listing should continue from. - * @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 [TagValue]{@link google.cloud.resourcemanager.v3.TagValue}. - * 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 `listTagValuesAsync()` - * 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. - */ - listTagValues( - request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue[], - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse - ]>; - listTagValues( - request: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagValue>): void; - listTagValues( - request: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - callback: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagValue>): void; - listTagValues( - request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagValue>, - callback?: PaginationCallback< - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse|null|undefined, - protos.google.cloud.resourcemanager.v3.ITagValue>): - Promise<[ - protos.google.cloud.resourcemanager.v3.ITagValue[], - protos.google.cloud.resourcemanager.v3.IListTagValuesRequest|null, - protos.google.cloud.resourcemanager.v3.IListTagValuesResponse - ]>|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 || {}; - this.initialize(); - return this.innerApiCalls.listTagValues(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.parent - * Required. Resource name for TagKey, parent of the TagValues to be listed, - * in the format `tagKeys/123`. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagValues to return in the response. The server - * allows a maximum of 300 TagValues to return. If unspecified, the server - * will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagValues` - * that indicates where this listing should continue from. - * @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 [TagValue]{@link google.cloud.resourcemanager.v3.TagValue} 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 `listTagValuesAsync()` - * 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. - */ - listTagValuesStream( - request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagValues']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagValues.createStream( - this.innerApiCalls.listTagValues as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listTagValues`, 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.parent - * Required. Resource name for TagKey, parent of the TagValues to be listed, - * in the format `tagKeys/123`. - * @param {number} [request.pageSize] - * Optional. The maximum number of TagValues to return in the response. The server - * allows a maximum of 300 TagValues to return. If unspecified, the server - * will use 100 as the default. - * @param {string} [request.pageToken] - * Optional. A pagination token returned from a previous call to `ListTagValues` - * that indicates where this listing should continue from. - * @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 - * [TagValue]{@link google.cloud.resourcemanager.v3.TagValue}. 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/v3/tag_values.list_tag_values.js - * region_tag:cloudresourcemanager_v3_generated_TagValues_ListTagValues_async - */ - listTagValuesAsync( - request?: protos.google.cloud.resourcemanager.v3.IListTagValuesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - const defaultCallSettings = this._defaults['listTagValues']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listTagValues.asyncIterate( - this.innerApiCalls['listTagValues'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified folder resource name string. - * - * @param {string} folder - * @returns {string} Resource name string. - */ - folderPath(folder:string) { - return this.pathTemplates.folderPathTemplate.render({ - folder: folder, - }); - } - - /** - * Parse the folder from Folder resource. - * - * @param {string} folderName - * A fully-qualified path representing Folder resource. - * @returns {string} A string representing the folder. - */ - matchFolderFromFolderName(folderName: string) { - return this.pathTemplates.folderPathTemplate.match(folderName).folder; - } - - /** - * Return a fully-qualified organization resource name string. - * - * @param {string} organization - * @returns {string} Resource name string. - */ - organizationPath(organization:string) { - return this.pathTemplates.organizationPathTemplate.render({ - organization: organization, - }); - } - - /** - * Parse the organization from Organization resource. - * - * @param {string} organizationName - * A fully-qualified path representing Organization resource. - * @returns {string} A string representing the organization. - */ - matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; - } - - /** - * Return a fully-qualified project resource name string. - * - * @param {string} project - * @returns {string} Resource name string. - */ - projectPath(project:string) { - return this.pathTemplates.projectPathTemplate.render({ - project: project, - }); - } - - /** - * Parse the project from Project resource. - * - * @param {string} projectName - * A fully-qualified path representing Project resource. - * @returns {string} A string representing the project. - */ - matchProjectFromProjectName(projectName: string) { - return this.pathTemplates.projectPathTemplate.match(projectName).project; - } - - /** - * Return a fully-qualified tagBinding resource name string. - * - * @param {string} tag_binding - * @returns {string} Resource name string. - */ - tagBindingPath(tagBinding:string) { - return this.pathTemplates.tagBindingPathTemplate.render({ - tag_binding: tagBinding, - }); - } - - /** - * Parse the tag_binding from TagBinding resource. - * - * @param {string} tagBindingName - * A fully-qualified path representing TagBinding resource. - * @returns {string} A string representing the tag_binding. - */ - matchTagBindingFromTagBindingName(tagBindingName: string) { - return this.pathTemplates.tagBindingPathTemplate.match(tagBindingName).tag_binding; - } - - /** - * Return a fully-qualified tagKey resource name string. - * - * @param {string} tag_key - * @returns {string} Resource name string. - */ - tagKeyPath(tagKey:string) { - return this.pathTemplates.tagKeyPathTemplate.render({ - tag_key: tagKey, - }); - } - - /** - * Parse the tag_key from TagKey resource. - * - * @param {string} tagKeyName - * A fully-qualified path representing TagKey resource. - * @returns {string} A string representing the tag_key. - */ - matchTagKeyFromTagKeyName(tagKeyName: string) { - return this.pathTemplates.tagKeyPathTemplate.match(tagKeyName).tag_key; - } - - /** - * Return a fully-qualified tagValue resource name string. - * - * @param {string} tag_value - * @returns {string} Resource name string. - */ - tagValuePath(tagValue:string) { - return this.pathTemplates.tagValuePathTemplate.render({ - tag_value: tagValue, - }); - } - - /** - * Parse the tag_value from TagValue resource. - * - * @param {string} tagValueName - * A fully-qualified path representing TagValue resource. - * @returns {string} A string representing the tag_value. - */ - matchTagValueFromTagValueName(tagValueName: string) { - return this.pathTemplates.tagValuePathTemplate.match(tagValueName).tag_value; - } - - /** - * 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.tagValuesStub && !this._terminated) { - return this.tagValuesStub.then(stub => { - this._terminated = true; - stub.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v3/src/v3/tag_values_client_config.json b/owl-bot-staging/v3/src/v3/tag_values_client_config.json deleted file mode 100644 index 01ac770..0000000 --- a/owl-bot-staging/v3/src/v3/tag_values_client_config.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "interfaces": { - "google.cloud.resourcemanager.v3.TagValues": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "unavailable": [ - "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": { - "ListTagValues": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "GetTagValue": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "CreateTagValue": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateTagValue": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteTagValue": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "unavailable", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 60000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v3/src/v3/tag_values_proto_list.json b/owl-bot-staging/v3/src/v3/tag_values_proto_list.json deleted file mode 100644 index 0c00660..0000000 --- a/owl-bot-staging/v3/src/v3/tag_values_proto_list.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - "../../protos/google/cloud/resourcemanager/v3/folders.proto", - "../../protos/google/cloud/resourcemanager/v3/organizations.proto", - "../../protos/google/cloud/resourcemanager/v3/projects.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_bindings.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_keys.proto", - "../../protos/google/cloud/resourcemanager/v3/tag_values.proto" -] diff --git a/owl-bot-staging/v3/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v3/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 6fe6a2e..0000000 --- a/owl-bot-staging/v3/system-test/fixtures/sample/src/index.js +++ /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. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const resourcemanager = require('@google-cloud/resource-manager'); - -function main() { - const foldersClient = new resourcemanager.FoldersClient(); - const organizationsClient = new resourcemanager.OrganizationsClient(); - const projectsClient = new resourcemanager.ProjectsClient(); - const tagBindingsClient = new resourcemanager.TagBindingsClient(); - const tagKeysClient = new resourcemanager.TagKeysClient(); - const tagValuesClient = new resourcemanager.TagValuesClient(); -} - -main(); diff --git a/owl-bot-staging/v3/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v3/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 65f594c..0000000 --- a/owl-bot-staging/v3/system-test/fixtures/sample/src/index.ts +++ /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. ** - -import {FoldersClient, OrganizationsClient, ProjectsClient, TagBindingsClient, TagKeysClient, TagValuesClient} from '@google-cloud/resource-manager'; - -// check that the client class type name can be used -function doStuffWithFoldersClient(client: FoldersClient) { - client.close(); -} -function doStuffWithOrganizationsClient(client: OrganizationsClient) { - client.close(); -} -function doStuffWithProjectsClient(client: ProjectsClient) { - client.close(); -} -function doStuffWithTagBindingsClient(client: TagBindingsClient) { - client.close(); -} -function doStuffWithTagKeysClient(client: TagKeysClient) { - client.close(); -} -function doStuffWithTagValuesClient(client: TagValuesClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const foldersClient = new FoldersClient(); - doStuffWithFoldersClient(foldersClient); - // check that the client instance can be created - const organizationsClient = new OrganizationsClient(); - doStuffWithOrganizationsClient(organizationsClient); - // check that the client instance can be created - const projectsClient = new ProjectsClient(); - doStuffWithProjectsClient(projectsClient); - // check that the client instance can be created - const tagBindingsClient = new TagBindingsClient(); - doStuffWithTagBindingsClient(tagBindingsClient); - // check that the client instance can be created - const tagKeysClient = new TagKeysClient(); - doStuffWithTagKeysClient(tagKeysClient); - // check that the client instance can be created - const tagValuesClient = new TagValuesClient(); - doStuffWithTagValuesClient(tagValuesClient); -} - -main(); diff --git a/owl-bot-staging/v3/system-test/install.ts b/owl-bot-staging/v3/system-test/install.ts deleted file mode 100644 index 8ec4522..0000000 --- a/owl-bot-staging/v3/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/v3/test/gapic_folders_v3.ts b/owl-bot-staging/v3/test/gapic_folders_v3.ts deleted file mode 100644 index 05377b0..0000000 --- a/owl-bot-staging/v3/test/gapic_folders_v3.ts +++ /dev/null @@ -1,1803 +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 foldersModule 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('v3.FoldersClient', () => { - it('has servicePath', () => { - const servicePath = foldersModule.v3.FoldersClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = foldersModule.v3.FoldersClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = foldersModule.v3.FoldersClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new foldersModule.v3.FoldersClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new foldersModule.v3.FoldersClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.foldersStub, undefined); - await client.initialize(); - assert(client.foldersStub); - }); - - it('has close method for the initialized client', done => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.foldersStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.foldersStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new foldersModule.v3.FoldersClient({ - 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 foldersModule.v3.FoldersClient({ - 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('getFolder', () => { - it('invokes getFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()); - client.innerApiCalls.getFolder = stubSimpleCall(expectedResponse); - const [response] = await client.getFolder(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()); - client.innerApiCalls.getFolder = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFolder( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getFolder with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getFolder = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFolder(request), expectedError); - assert((client.innerApiCalls.getFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getFolder with closed client', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetFolderRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getFolder(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createFolder', () => { - it('invokes createFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateFolderRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.createFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateFolderRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createFolder( - 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.createFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateFolderRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createFolder(request), expectedError); - assert((client.innerApiCalls.createFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateFolderRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createFolder(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkCreateFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkCreateFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateFolder', () => { - it('invokes updateFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest()); - request.folder = {}; - request.folder.name = ''; - const expectedHeaderRequestParams = "folder.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest()); - request.folder = {}; - request.folder.name = ''; - const expectedHeaderRequestParams = "folder.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFolder( - 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.updateFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest()); - request.folder = {}; - request.folder.name = ''; - const expectedHeaderRequestParams = "folder.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateFolder(request), expectedError); - assert((client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateFolderRequest()); - request.folder = {}; - request.folder.name = ''; - const expectedHeaderRequestParams = "folder.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateFolder(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkUpdateFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkUpdateFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('moveFolder', () => { - it('invokes moveFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.moveFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.moveFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes moveFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.moveFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moveFolder( - 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.moveFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes moveFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.moveFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.moveFolder(request), expectedError); - assert((client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes moveFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.moveFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.moveFolder(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.moveFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkMoveFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkMoveFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkMoveFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkMoveFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteFolder', () => { - it('invokes deleteFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteFolder( - 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.deleteFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteFolder(request), expectedError); - assert((client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteFolder(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkDeleteFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkDeleteFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('undeleteFolder', () => { - it('invokes undeleteFolder without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.undeleteFolder = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeleteFolder(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes undeleteFolder without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.undeleteFolder = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeleteFolder( - 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.undeleteFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes undeleteFolder with call error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteFolder = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeleteFolder(request), expectedError); - assert((client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes undeleteFolder with LRO error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteFolderRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteFolder = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeleteFolder(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.undeleteFolder as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUndeleteFolderProgress without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkUndeleteFolderProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUndeleteFolderProgress with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - 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.checkUndeleteFolderProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listFolders', () => { - it('invokes listFolders without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.innerApiCalls.listFolders = stubSimpleCall(expectedResponse); - const [response] = await client.listFolders(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listFolders as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listFolders without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.innerApiCalls.listFolders = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFolders( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listFolders as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listFolders with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.listFolders = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFolders(request), expectedError); - assert((client.innerApiCalls.listFolders as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listFoldersStream without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.descriptors.page.listFolders.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFoldersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { - 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.listFolders.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFolders, request)); - }); - - it('invokes listFoldersStream with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); - const expectedError = new Error('expected'); - client.descriptors.page.listFolders.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFoldersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFolders.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFolders, request)); - }); - - it('uses async iteration with listFolders without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.descriptors.page.listFolders.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; - const iterable = client.listFoldersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFolders.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listFolders with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListFoldersRequest());const expectedError = new Error('expected'); - client.descriptors.page.listFolders.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFoldersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFolders.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('searchFolders', () => { - it('invokes searchFolders without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.innerApiCalls.searchFolders = stubSimpleCall(expectedResponse); - const [response] = await client.searchFolders(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchFolders as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchFolders without error using callback', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.innerApiCalls.searchFolders = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchFolders( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IFolder[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchFolders as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes searchFolders with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.searchFolders = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchFolders(request), expectedError); - assert((client.innerApiCalls.searchFolders as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchFoldersStream without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.descriptors.page.searchFolders.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchFoldersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { - 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.searchFolders.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchFolders, request)); - }); - - it('invokes searchFoldersStream with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); - const expectedError = new Error('expected'); - client.descriptors.page.searchFolders.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchFoldersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Folder[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Folder) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchFolders.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchFolders, request)); - }); - - it('uses async iteration with searchFolders without error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Folder()), - ]; - client.descriptors.page.searchFolders.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; - const iterable = client.searchFoldersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchFolders.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with searchFolders with error', async () => { - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchFoldersRequest());const expectedError = new Error('expected'); - client.descriptors.page.searchFolders.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchFoldersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IFolder[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchFolders.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new foldersModule.v3.FoldersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v3/test/gapic_organizations_v3.ts b/owl-bot-staging/v3/test/gapic_organizations_v3.ts deleted file mode 100644 index 3f2351b..0000000 --- a/owl-bot-staging/v3/test/gapic_organizations_v3.ts +++ /dev/null @@ -1,924 +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 organizationsModule from '../src'; - -import {PassThrough} from 'stream'; - -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); -} - -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('v3.OrganizationsClient', () => { - it('has servicePath', () => { - const servicePath = organizationsModule.v3.OrganizationsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = organizationsModule.v3.OrganizationsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = organizationsModule.v3.OrganizationsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new organizationsModule.v3.OrganizationsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new organizationsModule.v3.OrganizationsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.organizationsStub, undefined); - await client.initialize(); - assert(client.organizationsStub); - }); - - it('has close method for the initialized client', done => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.organizationsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.organizationsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new organizationsModule.v3.OrganizationsClient({ - 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 organizationsModule.v3.OrganizationsClient({ - 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('getOrganization', () => { - it('invokes getOrganization without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()); - client.innerApiCalls.getOrganization = stubSimpleCall(expectedResponse); - const [response] = await client.getOrganization(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOrganization as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getOrganization without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()); - client.innerApiCalls.getOrganization = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOrganization( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IOrganization|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getOrganization as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getOrganization with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getOrganization = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOrganization(request), expectedError); - assert((client.innerApiCalls.getOrganization as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getOrganization with closed client', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetOrganizationRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getOrganization(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('searchOrganizations', () => { - it('invokes searchOrganizations without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - ]; - client.innerApiCalls.searchOrganizations = stubSimpleCall(expectedResponse); - const [response] = await client.searchOrganizations(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchOrganizations as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchOrganizations without error using callback', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - ]; - client.innerApiCalls.searchOrganizations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchOrganizations( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IOrganization[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchOrganizations as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes searchOrganizations with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.searchOrganizations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchOrganizations(request), expectedError); - assert((client.innerApiCalls.searchOrganizations as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchOrganizationsStream without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - ]; - client.descriptors.page.searchOrganizations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchOrganizationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Organization[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Organization) => { - 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.searchOrganizations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchOrganizations, request)); - }); - - it('invokes searchOrganizationsStream with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); - const expectedError = new Error('expected'); - client.descriptors.page.searchOrganizations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchOrganizationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Organization[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Organization) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchOrganizations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchOrganizations, request)); - }); - - it('uses async iteration with searchOrganizations without error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Organization()), - ]; - client.descriptors.page.searchOrganizations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IOrganization[] = []; - const iterable = client.searchOrganizationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchOrganizations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with searchOrganizations with error', async () => { - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchOrganizationsRequest());const expectedError = new Error('expected'); - client.descriptors.page.searchOrganizations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchOrganizationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IOrganization[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchOrganizations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new organizationsModule.v3.OrganizationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v3/test/gapic_projects_v3.ts b/owl-bot-staging/v3/test/gapic_projects_v3.ts deleted file mode 100644 index 89f3c09..0000000 --- a/owl-bot-staging/v3/test/gapic_projects_v3.ts +++ /dev/null @@ -1,1803 +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 projectsModule 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('v3.ProjectsClient', () => { - it('has servicePath', () => { - const servicePath = projectsModule.v3.ProjectsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = projectsModule.v3.ProjectsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = projectsModule.v3.ProjectsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new projectsModule.v3.ProjectsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new projectsModule.v3.ProjectsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.projectsStub, undefined); - await client.initialize(); - assert(client.projectsStub); - }); - - it('has close method for the initialized client', done => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.projectsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.projectsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new projectsModule.v3.ProjectsClient({ - 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 projectsModule.v3.ProjectsClient({ - 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('getProject', () => { - it('invokes getProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()); - client.innerApiCalls.getProject = stubSimpleCall(expectedResponse); - const [response] = await client.getProject(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()); - client.innerApiCalls.getProject = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProject( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getProject with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getProject = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProject(request), expectedError); - assert((client.innerApiCalls.getProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getProject with closed client', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetProjectRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProject(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createProject', () => { - it('invokes createProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateProjectRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.createProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateProjectRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProject( - 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.createProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateProjectRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createProject(request), expectedError); - assert((client.innerApiCalls.createProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateProjectRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createProject(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkCreateProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkCreateProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateProject', () => { - it('invokes updateProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest()); - request.project = {}; - request.project.name = ''; - const expectedHeaderRequestParams = "project.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest()); - request.project = {}; - request.project.name = ''; - const expectedHeaderRequestParams = "project.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateProject( - 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.updateProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest()); - request.project = {}; - request.project.name = ''; - const expectedHeaderRequestParams = "project.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateProject(request), expectedError); - assert((client.innerApiCalls.updateProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateProjectRequest()); - request.project = {}; - request.project.name = ''; - const expectedHeaderRequestParams = "project.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateProject(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkUpdateProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkUpdateProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('moveProject', () => { - it('invokes moveProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.moveProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.moveProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.moveProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes moveProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.moveProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moveProject( - 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.moveProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes moveProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.moveProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.moveProject(request), expectedError); - assert((client.innerApiCalls.moveProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes moveProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.MoveProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.moveProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.moveProject(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.moveProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkMoveProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkMoveProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkMoveProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkMoveProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteProject', () => { - it('invokes deleteProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProject( - 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.deleteProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteProject(request), expectedError); - assert((client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteProject(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkDeleteProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkDeleteProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('undeleteProject', () => { - it('invokes undeleteProject without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.undeleteProject = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeleteProject(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes undeleteProject without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.undeleteProject = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeleteProject( - 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.undeleteProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes undeleteProject with call error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteProject = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeleteProject(request), expectedError); - assert((client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes undeleteProject with LRO error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UndeleteProjectRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteProject = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeleteProject(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.undeleteProject as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUndeleteProjectProgress without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkUndeleteProjectProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUndeleteProjectProgress with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - 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.checkUndeleteProjectProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listProjects', () => { - it('invokes listProjects without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.innerApiCalls.listProjects = stubSimpleCall(expectedResponse); - const [response] = await client.listProjects(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProjects as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProjects without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.innerApiCalls.listProjects = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProjects( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listProjects as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listProjects with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.listProjects = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProjects(request), expectedError); - assert((client.innerApiCalls.listProjects as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listProjectsStream without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.descriptors.page.listProjects.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProjectsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { - 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.listProjects.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProjects, request)); - }); - - it('invokes listProjectsStream with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); - const expectedError = new Error('expected'); - client.descriptors.page.listProjects.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProjectsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProjects.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProjects, request)); - }); - - it('uses async iteration with listProjects without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.descriptors.page.listProjects.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; - const iterable = client.listProjectsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProjects.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listProjects with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListProjectsRequest());const expectedError = new Error('expected'); - client.descriptors.page.listProjects.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProjectsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProjects.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('searchProjects', () => { - it('invokes searchProjects without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.innerApiCalls.searchProjects = stubSimpleCall(expectedResponse); - const [response] = await client.searchProjects(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchProjects as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchProjects without error using callback', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.innerApiCalls.searchProjects = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchProjects( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.IProject[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.searchProjects as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes searchProjects with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.searchProjects = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchProjects(request), expectedError); - assert((client.innerApiCalls.searchProjects as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes searchProjectsStream without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.descriptors.page.searchProjects.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchProjectsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { - 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.searchProjects.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchProjects, request)); - }); - - it('invokes searchProjectsStream with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); - const expectedError = new Error('expected'); - client.descriptors.page.searchProjects.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchProjectsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.Project[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.Project) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchProjects.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchProjects, request)); - }); - - it('uses async iteration with searchProjects without error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.Project()), - ]; - client.descriptors.page.searchProjects.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; - const iterable = client.searchProjectsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchProjects.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with searchProjects with error', async () => { - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.SearchProjectsRequest());const expectedError = new Error('expected'); - client.descriptors.page.searchProjects.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchProjectsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.IProject[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchProjects.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new projectsModule.v3.ProjectsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v3/test/gapic_tag_bindings_v3.ts b/owl-bot-staging/v3/test/gapic_tag_bindings_v3.ts deleted file mode 100644 index 062c5f9..0000000 --- a/owl-bot-staging/v3/test/gapic_tag_bindings_v3.ts +++ /dev/null @@ -1,808 +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 tagbindingsModule 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('v3.TagBindingsClient', () => { - it('has servicePath', () => { - const servicePath = tagbindingsModule.v3.TagBindingsClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tagbindingsModule.v3.TagBindingsClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tagbindingsModule.v3.TagBindingsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tagbindingsModule.v3.TagBindingsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagBindingsStub, undefined); - await client.initialize(); - assert(client.tagBindingsStub); - }); - - it('has close method for the initialized client', done => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tagBindingsStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagBindingsStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tagbindingsModule.v3.TagBindingsClient({ - 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 tagbindingsModule.v3.TagBindingsClient({ - 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('createTagBinding', () => { - it('invokes createTagBinding without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createTagBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTagBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createTagBinding as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createTagBinding without error using callback', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createTagBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTagBinding( - 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.createTagBinding as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createTagBinding with call error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createTagBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTagBinding(request), expectedError); - assert((client.innerApiCalls.createTagBinding as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createTagBinding with LRO error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagBindingRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createTagBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTagBinding(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createTagBinding as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateTagBindingProgress without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - 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.checkCreateTagBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateTagBindingProgress with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - 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.checkCreateTagBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteTagBinding', () => { - it('invokes deleteTagBinding without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteTagBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTagBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteTagBinding without error using callback', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteTagBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTagBinding( - 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.deleteTagBinding as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteTagBinding with call error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTagBinding(request), expectedError); - assert((client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteTagBinding with LRO error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagBindingRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTagBinding(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteTagBinding as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteTagBindingProgress without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - 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.checkDeleteTagBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteTagBindingProgress with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - 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.checkDeleteTagBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listTagBindings', () => { - it('invokes listTagBindings without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - ]; - client.innerApiCalls.listTagBindings = stubSimpleCall(expectedResponse); - const [response] = await client.listTagBindings(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listTagBindings as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listTagBindings without error using callback', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - ]; - client.innerApiCalls.listTagBindings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTagBindings( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagBinding[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listTagBindings as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listTagBindings with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.listTagBindings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTagBindings(request), expectedError); - assert((client.innerApiCalls.listTagBindings as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listTagBindingsStream without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - ]; - client.descriptors.page.listTagBindings.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTagBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagBinding[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagBinding) => { - 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.listTagBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagBindings, request)); - }); - - it('invokes listTagBindingsStream with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); - const expectedError = new Error('expected'); - client.descriptors.page.listTagBindings.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTagBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagBinding[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTagBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagBindings, request)); - }); - - it('uses async iteration with listTagBindings without error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagBinding()), - ]; - client.descriptors.page.listTagBindings.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.ITagBinding[] = []; - const iterable = client.listTagBindingsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTagBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listTagBindings with error', async () => { - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagBindingsRequest());const expectedError = new Error('expected'); - client.descriptors.page.listTagBindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTagBindingsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.ITagBinding[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTagBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new tagbindingsModule.v3.TagBindingsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v3/test/gapic_tag_keys_v3.ts b/owl-bot-staging/v3/test/gapic_tag_keys_v3.ts deleted file mode 100644 index b2ff45b..0000000 --- a/owl-bot-staging/v3/test/gapic_tag_keys_v3.ts +++ /dev/null @@ -1,1344 +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 tagkeysModule 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('v3.TagKeysClient', () => { - it('has servicePath', () => { - const servicePath = tagkeysModule.v3.TagKeysClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tagkeysModule.v3.TagKeysClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tagkeysModule.v3.TagKeysClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tagkeysModule.v3.TagKeysClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tagkeysModule.v3.TagKeysClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagKeysStub, undefined); - await client.initialize(); - assert(client.tagKeysStub); - }); - - it('has close method for the initialized client', done => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tagKeysStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagKeysStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tagkeysModule.v3.TagKeysClient({ - 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 tagkeysModule.v3.TagKeysClient({ - 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('getTagKey', () => { - it('invokes getTagKey without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()); - client.innerApiCalls.getTagKey = stubSimpleCall(expectedResponse); - const [response] = await client.getTagKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getTagKey without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()); - client.innerApiCalls.getTagKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTagKey( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getTagKey with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getTagKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTagKey(request), expectedError); - assert((client.innerApiCalls.getTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getTagKey with closed client', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagKeyRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getTagKey(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createTagKey', () => { - it('invokes createTagKey without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createTagKey = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTagKey(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createTagKey without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createTagKey = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTagKey( - 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.createTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createTagKey with call error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createTagKey = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTagKey(request), expectedError); - assert((client.innerApiCalls.createTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createTagKey with LRO error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagKeyRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createTagKey = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTagKey(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateTagKeyProgress without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - 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.checkCreateTagKeyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateTagKeyProgress with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - 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.checkCreateTagKeyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateTagKey', () => { - it('invokes updateTagKey without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest()); - request.tagKey = {}; - request.tagKey.name = ''; - const expectedHeaderRequestParams = "tag_key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateTagKey = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateTagKey(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateTagKey without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest()); - request.tagKey = {}; - request.tagKey.name = ''; - const expectedHeaderRequestParams = "tag_key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateTagKey = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTagKey( - 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.updateTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateTagKey with call error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest()); - request.tagKey = {}; - request.tagKey.name = ''; - const expectedHeaderRequestParams = "tag_key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTagKey = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateTagKey(request), expectedError); - assert((client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateTagKey with LRO error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagKeyRequest()); - request.tagKey = {}; - request.tagKey.name = ''; - const expectedHeaderRequestParams = "tag_key.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTagKey = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateTagKey(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateTagKeyProgress without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - 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.checkUpdateTagKeyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateTagKeyProgress with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - 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.checkUpdateTagKeyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteTagKey', () => { - it('invokes deleteTagKey without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteTagKey = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTagKey(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteTagKey without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteTagKey = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTagKey( - 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.deleteTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteTagKey with call error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagKey = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTagKey(request), expectedError); - assert((client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteTagKey with LRO error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagKeyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagKey = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTagKey(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteTagKey as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteTagKeyProgress without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - 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.checkDeleteTagKeyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteTagKeyProgress with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - 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.checkDeleteTagKeyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listTagKeys', () => { - it('invokes listTagKeys without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - ]; - client.innerApiCalls.listTagKeys = stubSimpleCall(expectedResponse); - const [response] = await client.listTagKeys(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listTagKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listTagKeys without error using callback', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - ]; - client.innerApiCalls.listTagKeys = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTagKeys( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagKey[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listTagKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listTagKeys with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.listTagKeys = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTagKeys(request), expectedError); - assert((client.innerApiCalls.listTagKeys as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listTagKeysStream without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - ]; - client.descriptors.page.listTagKeys.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTagKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagKey[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagKey) => { - 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.listTagKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagKeys, request)); - }); - - it('invokes listTagKeysStream with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); - const expectedError = new Error('expected'); - client.descriptors.page.listTagKeys.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTagKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagKey[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagKey) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTagKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagKeys, request)); - }); - - it('uses async iteration with listTagKeys without error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagKey()), - ]; - client.descriptors.page.listTagKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.ITagKey[] = []; - const iterable = client.listTagKeysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTagKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listTagKeys with error', async () => { - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagKeysRequest());const expectedError = new Error('expected'); - client.descriptors.page.listTagKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTagKeysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.ITagKey[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTagKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new tagkeysModule.v3.TagKeysClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v3/test/gapic_tag_values_v3.ts b/owl-bot-staging/v3/test/gapic_tag_values_v3.ts deleted file mode 100644 index 9773fd6..0000000 --- a/owl-bot-staging/v3/test/gapic_tag_values_v3.ts +++ /dev/null @@ -1,1344 +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 tagvaluesModule 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('v3.TagValuesClient', () => { - it('has servicePath', () => { - const servicePath = tagvaluesModule.v3.TagValuesClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = tagvaluesModule.v3.TagValuesClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = tagvaluesModule.v3.TagValuesClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new tagvaluesModule.v3.TagValuesClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagValuesStub, undefined); - await client.initialize(); - assert(client.tagValuesStub); - }); - - it('has close method for the initialized client', done => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.tagValuesStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tagValuesStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tagvaluesModule.v3.TagValuesClient({ - 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 tagvaluesModule.v3.TagValuesClient({ - 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('getTagValue', () => { - it('invokes getTagValue without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagValueRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()); - client.innerApiCalls.getTagValue = stubSimpleCall(expectedResponse); - const [response] = await client.getTagValue(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getTagValue without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagValueRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()); - client.innerApiCalls.getTagValue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTagValue( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getTagValue with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagValueRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getTagValue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTagValue(request), expectedError); - assert((client.innerApiCalls.getTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getTagValue with closed client', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.GetTagValueRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getTagValue(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createTagValue', () => { - it('invokes createTagValue without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createTagValue = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTagValue(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createTagValue without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createTagValue = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTagValue( - 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.createTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createTagValue with call error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createTagValue = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTagValue(request), expectedError); - assert((client.innerApiCalls.createTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createTagValue with LRO error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.CreateTagValueRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.createTagValue = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTagValue(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateTagValueProgress without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - 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.checkCreateTagValueProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateTagValueProgress with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - 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.checkCreateTagValueProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateTagValue', () => { - it('invokes updateTagValue without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest()); - request.tagValue = {}; - request.tagValue.name = ''; - const expectedHeaderRequestParams = "tag_value.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateTagValue = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateTagValue(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateTagValue without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest()); - request.tagValue = {}; - request.tagValue.name = ''; - const expectedHeaderRequestParams = "tag_value.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateTagValue = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTagValue( - 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.updateTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateTagValue with call error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest()); - request.tagValue = {}; - request.tagValue.name = ''; - const expectedHeaderRequestParams = "tag_value.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTagValue = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateTagValue(request), expectedError); - assert((client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateTagValue with LRO error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.UpdateTagValueRequest()); - request.tagValue = {}; - request.tagValue.name = ''; - const expectedHeaderRequestParams = "tag_value.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTagValue = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateTagValue(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateTagValueProgress without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - 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.checkUpdateTagValueProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateTagValueProgress with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - 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.checkUpdateTagValueProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('deleteTagValue', () => { - it('invokes deleteTagValue without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteTagValue = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteTagValue(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteTagValue without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.deleteTagValue = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTagValue( - 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.deleteTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteTagValue with call error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagValue = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteTagValue(request), expectedError); - assert((client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteTagValue with LRO error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.DeleteTagValueRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTagValue = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteTagValue(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.deleteTagValue as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkDeleteTagValueProgress without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - 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.checkDeleteTagValueProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteTagValueProgress with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - 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.checkDeleteTagValueProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listTagValues', () => { - it('invokes listTagValues without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - ]; - client.innerApiCalls.listTagValues = stubSimpleCall(expectedResponse); - const [response] = await client.listTagValues(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listTagValues as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listTagValues without error using callback', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - ]; - client.innerApiCalls.listTagValues = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTagValues( - request, - (err?: Error|null, result?: protos.google.cloud.resourcemanager.v3.ITagValue[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listTagValues as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listTagValues with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); - const expectedOptions = {otherArgs: {headers: {}}};; - const expectedError = new Error('expected'); - client.innerApiCalls.listTagValues = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTagValues(request), expectedError); - assert((client.innerApiCalls.listTagValues as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listTagValuesStream without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - ]; - client.descriptors.page.listTagValues.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTagValuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagValue[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagValue) => { - 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.listTagValues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagValues, request)); - }); - - it('invokes listTagValuesStream with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); - const expectedError = new Error('expected'); - client.descriptors.page.listTagValues.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTagValuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.resourcemanager.v3.TagValue[] = []; - stream.on('data', (response: protos.google.cloud.resourcemanager.v3.TagValue) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTagValues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTagValues, request)); - }); - - it('uses async iteration with listTagValues without error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest()); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - generateSampleMessage(new protos.google.cloud.resourcemanager.v3.TagValue()), - ]; - client.descriptors.page.listTagValues.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.resourcemanager.v3.ITagValue[] = []; - const iterable = client.listTagValuesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTagValues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - - it('uses async iteration with listTagValues with error', async () => { - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.resourcemanager.v3.ListTagValuesRequest());const expectedError = new Error('expected'); - client.descriptors.page.listTagValues.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTagValuesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.resourcemanager.v3.ITagValue[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTagValues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('folder', () => { - const fakePath = "/rendered/path/folder"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.folderPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderPath', () => { - const result = client.folderPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderName', () => { - const result = client.matchFolderFromFolderName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organization', () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagBinding', () => { - const fakePath = "/rendered/path/tagBinding"; - const expectedParameters = { - tag_binding: "tagBindingValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagBindingPath', () => { - const result = client.tagBindingPath("tagBindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagBindingFromTagBindingName', () => { - const result = client.matchTagBindingFromTagBindingName(fakePath); - assert.strictEqual(result, "tagBindingValue"); - assert((client.pathTemplates.tagBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagKey', () => { - const fakePath = "/rendered/path/tagKey"; - const expectedParameters = { - tag_key: "tagKeyValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagKeyPath', () => { - const result = client.tagKeyPath("tagKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagKeyFromTagKeyName', () => { - const result = client.matchTagKeyFromTagKeyName(fakePath); - assert.strictEqual(result, "tagKeyValue"); - assert((client.pathTemplates.tagKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('tagValue', () => { - const fakePath = "/rendered/path/tagValue"; - const expectedParameters = { - tag_value: "tagValueValue", - }; - const client = new tagvaluesModule.v3.TagValuesClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tagValuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tagValuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tagValuePath', () => { - const result = client.tagValuePath("tagValueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tagValuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchTagValueFromTagValueName', () => { - const result = client.matchTagValueFromTagValueName(fakePath); - assert.strictEqual(result, "tagValueValue"); - assert((client.pathTemplates.tagValuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v3/tsconfig.json b/owl-bot-staging/v3/tsconfig.json deleted file mode 100644 index c78f1c8..0000000 --- a/owl-bot-staging/v3/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/v3/webpack.config.js b/owl-bot-staging/v3/webpack.config.js deleted file mode 100644 index 92f3d14..0000000 --- a/owl-bot-staging/v3/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: 'Folders', - filename: './folders.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/v3/folders_client.ts b/src/v3/folders_client.ts index 0c4e779..36155cc 100644 --- a/src/v3/folders_client.ts +++ b/src/v3/folders_client.ts @@ -23,6 +23,7 @@ import { CallOptions, Descriptors, ClientOptions, + GrpcClientOptions, LROperation, PaginationCallback, GaxCall, @@ -74,7 +75,7 @@ export class FoldersClient { * * @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] @@ -97,11 +98,10 @@ export class FoldersClient { * 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. @@ -201,16 +201,24 @@ export class FoldersClient { }; 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.GetOperation', + get: '/v3/{name=operations/**}', + }, + ]; + } this.operationsClient = this._gaxModule - .lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }) + .lro(lroOptions) .operationsClient(opts); const createFolderResponse = protoFilesRoot.lookup( '.google.cloud.resourcemanager.v3.Folder' diff --git a/src/v3/organizations_client.ts b/src/v3/organizations_client.ts index c1fb430..5bde9b2 100644 --- a/src/v3/organizations_client.ts +++ b/src/v3/organizations_client.ts @@ -70,7 +70,7 @@ export class OrganizationsClient { * * @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] @@ -93,11 +93,10 @@ export class OrganizationsClient { * 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. diff --git a/src/v3/projects_client.ts b/src/v3/projects_client.ts index 26d670a..e8f36e2 100644 --- a/src/v3/projects_client.ts +++ b/src/v3/projects_client.ts @@ -23,6 +23,7 @@ import { CallOptions, Descriptors, ClientOptions, + GrpcClientOptions, LROperation, PaginationCallback, GaxCall, @@ -72,7 +73,7 @@ export class ProjectsClient { * * @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] @@ -95,11 +96,10 @@ export class ProjectsClient { * 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. @@ -199,16 +199,24 @@ export class ProjectsClient { }; 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.GetOperation', + get: '/v3/{name=operations/**}', + }, + ]; + } this.operationsClient = this._gaxModule - .lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }) + .lro(lroOptions) .operationsClient(opts); const createProjectResponse = protoFilesRoot.lookup( '.google.cloud.resourcemanager.v3.Project' diff --git a/src/v3/tag_bindings_client.ts b/src/v3/tag_bindings_client.ts index d039a63..76bed17 100644 --- a/src/v3/tag_bindings_client.ts +++ b/src/v3/tag_bindings_client.ts @@ -23,6 +23,7 @@ import { CallOptions, Descriptors, ClientOptions, + GrpcClientOptions, LROperation, PaginationCallback, GaxCall, @@ -73,7 +74,7 @@ export class TagBindingsClient { * * @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] @@ -96,11 +97,10 @@ export class TagBindingsClient { * 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. @@ -195,16 +195,24 @@ export class TagBindingsClient { }; 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.GetOperation', + get: '/v3/{name=operations/**}', + }, + ]; + } this.operationsClient = this._gaxModule - .lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }) + .lro(lroOptions) .operationsClient(opts); const createTagBindingResponse = protoFilesRoot.lookup( '.google.cloud.resourcemanager.v3.TagBinding' diff --git a/src/v3/tag_keys_client.ts b/src/v3/tag_keys_client.ts index 5267433..2606a54 100644 --- a/src/v3/tag_keys_client.ts +++ b/src/v3/tag_keys_client.ts @@ -23,6 +23,7 @@ import { CallOptions, Descriptors, ClientOptions, + GrpcClientOptions, LROperation, PaginationCallback, GaxCall, @@ -72,7 +73,7 @@ export class TagKeysClient { * * @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] @@ -95,11 +96,10 @@ export class TagKeysClient { * 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. @@ -194,16 +194,24 @@ export class TagKeysClient { }; 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.GetOperation', + get: '/v3/{name=operations/**}', + }, + ]; + } this.operationsClient = this._gaxModule - .lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }) + .lro(lroOptions) .operationsClient(opts); const createTagKeyResponse = protoFilesRoot.lookup( '.google.cloud.resourcemanager.v3.TagKey' diff --git a/src/v3/tag_values_client.ts b/src/v3/tag_values_client.ts index d0c7c66..a9c2add 100644 --- a/src/v3/tag_values_client.ts +++ b/src/v3/tag_values_client.ts @@ -23,6 +23,7 @@ import { CallOptions, Descriptors, ClientOptions, + GrpcClientOptions, LROperation, PaginationCallback, GaxCall, @@ -72,7 +73,7 @@ export class TagValuesClient { * * @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] @@ -95,11 +96,10 @@ export class TagValuesClient { * 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. @@ -194,16 +194,24 @@ export class TagValuesClient { }; 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.GetOperation', + get: '/v3/{name=operations/**}', + }, + ]; + } this.operationsClient = this._gaxModule - .lro({ - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }) + .lro(lroOptions) .operationsClient(opts); const createTagValueResponse = protoFilesRoot.lookup( '.google.cloud.resourcemanager.v3.TagValue'