1 | ;
|
2 | // Copyright 2022 Google LLC
|
3 | //
|
4 | // Licensed under the Apache License, Version 2.0 (the "License");
|
5 | // you may not use this file except in compliance with the License.
|
6 | // You may obtain a copy of the License at
|
7 | //
|
8 | // https://www.apache.org/licenses/LICENSE-2.0
|
9 | //
|
10 | // Unless required by applicable law or agreed to in writing, software
|
11 | // distributed under the License is distributed on an "AS IS" BASIS,
|
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | // See the License for the specific language governing permissions and
|
14 | // limitations under the License.
|
15 | //
|
16 | // ** This file is automatically generated by gapic-generator-typescript. **
|
17 | // ** https://github.com/googleapis/gapic-generator-typescript **
|
18 | // ** All changes to this file may be overwritten. **
|
19 | Object.defineProperty(exports, "__esModule", { value: true });
|
20 | exports.SchemaServiceClient = void 0;
|
21 | /* global window */
|
22 | const gax = require("google-gax");
|
23 | const google_gax_1 = require("google-gax");
|
24 | const jsonProtos = require("../../protos/protos.json");
|
25 | /**
|
26 | * Client JSON configuration object, loaded from
|
27 | * `src/v1/schema_service_client_config.json`.
|
28 | * This file defines retry strategy and timeouts for all API methods in this library.
|
29 | */
|
30 | const gapicConfig = require("./schema_service_client_config.json");
|
31 | const version = require('../../../package.json').version;
|
32 | /**
|
33 | * Service for doing schema-related operations.
|
34 | * @class
|
35 | * @memberof v1
|
36 | */
|
37 | class SchemaServiceClient {
|
38 | /**
|
39 | * Construct an instance of SchemaServiceClient.
|
40 | *
|
41 | * @param {object} [options] - The configuration object.
|
42 | * The options accepted by the constructor are described in detail
|
43 | * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
|
44 | * The common options are:
|
45 | * @param {object} [options.credentials] - Credentials object.
|
46 | * @param {string} [options.credentials.client_email]
|
47 | * @param {string} [options.credentials.private_key]
|
48 | * @param {string} [options.email] - Account email address. Required when
|
49 | * using a .pem or .p12 keyFilename.
|
50 | * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
|
51 | * .p12 key downloaded from the Google Developers Console. If you provide
|
52 | * a path to a JSON file, the projectId option below is not necessary.
|
53 | * NOTE: .pem and .p12 require you to specify options.email as well.
|
54 | * @param {number} [options.port] - The port on which to connect to
|
55 | * the remote host.
|
56 | * @param {string} [options.projectId] - The project ID from the Google
|
57 | * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
|
58 | * the environment variable GCLOUD_PROJECT for your project ID. If your
|
59 | * app is running in an environment which supports
|
60 | * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
|
61 | * your project ID will be detected automatically.
|
62 | * @param {string} [options.apiEndpoint] - The domain name of the
|
63 | * API remote host.
|
64 | * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
|
65 | * Follows the structure of {@link gapicConfig}.
|
66 | * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
|
67 | * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
|
68 | * For more information, please check the
|
69 | * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
|
70 | */
|
71 | constructor(opts) {
|
72 | var _a, _b;
|
73 | this._terminated = false;
|
74 | this.descriptors = {
|
75 | page: {},
|
76 | stream: {},
|
77 | longrunning: {},
|
78 | batching: {},
|
79 | };
|
80 | // Ensure that options include all the required fields.
|
81 | const staticMembers = this.constructor;
|
82 | const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || staticMembers.servicePath;
|
83 | this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
|
84 | const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
|
85 | const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
|
86 | const fallback = (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _b !== void 0 ? _b : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
|
87 | opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
|
88 | // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
|
89 | if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
|
90 | opts['scopes'] = staticMembers.scopes;
|
91 | }
|
92 | // Choose either gRPC or proto-over-HTTP implementation of google-gax.
|
93 | this._gaxModule = opts.fallback ? gax.fallback : gax;
|
94 | // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
|
95 | this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
|
96 | // Save options to use in initialize() method.
|
97 | this._opts = opts;
|
98 | // Save the auth object to the client, for use by other methods.
|
99 | this.auth = this._gaxGrpc.auth;
|
100 | // Set useJWTAccessWithScope on the auth object.
|
101 | this.auth.useJWTAccessWithScope = true;
|
102 | // Set defaultServicePath on the auth object.
|
103 | this.auth.defaultServicePath = staticMembers.servicePath;
|
104 | // Set the default scopes in auth client if needed.
|
105 | if (servicePath === staticMembers.servicePath) {
|
106 | this.auth.defaultScopes = staticMembers.scopes;
|
107 | }
|
108 | this.iamClient = new google_gax_1.IamClient(this._gaxGrpc, opts);
|
109 | // Determine the client header string.
|
110 | const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
|
111 | if (typeof process !== 'undefined' && 'versions' in process) {
|
112 | clientHeader.push(`gl-node/${process.versions.node}`);
|
113 | }
|
114 | else {
|
115 | clientHeader.push(`gl-web/${this._gaxModule.version}`);
|
116 | }
|
117 | if (!opts.fallback) {
|
118 | clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
|
119 | }
|
120 | else if (opts.fallback === 'rest') {
|
121 | clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
|
122 | }
|
123 | if (opts.libName && opts.libVersion) {
|
124 | clientHeader.push(`${opts.libName}/${opts.libVersion}`);
|
125 | }
|
126 | // Load the applicable protos.
|
127 | this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
|
128 | // This API contains "path templates"; forward-slash-separated
|
129 | // identifiers to uniquely identify resources within the API.
|
130 | // Create useful helper objects for these.
|
131 | this.pathTemplates = {
|
132 | projectPathTemplate: new this._gaxModule.PathTemplate('projects/{project}'),
|
133 | projectTopicPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/topics/{topic}'),
|
134 | schemaPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/schemas/{schema}'),
|
135 | snapshotPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/snapshots/{snapshot}'),
|
136 | subscriptionPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/subscriptions/{subscription}'),
|
137 | };
|
138 | // Some of the methods on this service return "paged" results,
|
139 | // (e.g. 50 results at a time, with tokens to get subsequent
|
140 | // pages). Denote the keys used for pagination and results.
|
141 | this.descriptors.page = {
|
142 | listSchemas: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'schemas'),
|
143 | };
|
144 | // Put together the default options sent with requests.
|
145 | this._defaults = this._gaxGrpc.constructSettings('google.pubsub.v1.SchemaService', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
|
146 | // Set up a dictionary of "inner API calls"; the core implementation
|
147 | // of calling the API is handled in `google-gax`, with this code
|
148 | // merely providing the destination and request information.
|
149 | this.innerApiCalls = {};
|
150 | // Add a warn function to the client constructor so it can be easily tested.
|
151 | this.warn = gax.warn;
|
152 | }
|
153 | /**
|
154 | * Initialize the client.
|
155 | * Performs asynchronous operations (such as authentication) and prepares the client.
|
156 | * This function will be called automatically when any class method is called for the
|
157 | * first time, but if you need to initialize it before calling an actual method,
|
158 | * feel free to call initialize() directly.
|
159 | *
|
160 | * You can await on this method if you want to make sure the client is initialized.
|
161 | *
|
162 | * @returns {Promise} A promise that resolves to an authenticated service stub.
|
163 | */
|
164 | initialize() {
|
165 | // If the client stub promise is already initialized, return immediately.
|
166 | if (this.schemaServiceStub) {
|
167 | return this.schemaServiceStub;
|
168 | }
|
169 | // Put together the "service stub" for
|
170 | // google.pubsub.v1.SchemaService.
|
171 | this.schemaServiceStub = this._gaxGrpc.createStub(this._opts.fallback
|
172 | ? this._protos.lookupService('google.pubsub.v1.SchemaService')
|
173 | : // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
174 | this._protos.google.pubsub.v1.SchemaService, this._opts, this._providedCustomServicePath);
|
175 | // Iterate over each of the methods that the service provides
|
176 | // and create an API call method for each.
|
177 | const schemaServiceStubMethods = [
|
178 | 'createSchema',
|
179 | 'getSchema',
|
180 | 'listSchemas',
|
181 | 'deleteSchema',
|
182 | 'validateSchema',
|
183 | 'validateMessage',
|
184 | ];
|
185 | for (const methodName of schemaServiceStubMethods) {
|
186 | const callPromise = this.schemaServiceStub.then(stub => (...args) => {
|
187 | if (this._terminated) {
|
188 | return Promise.reject('The client has already been closed.');
|
189 | }
|
190 | const func = stub[methodName];
|
191 | return func.apply(stub, args);
|
192 | }, (err) => () => {
|
193 | throw err;
|
194 | });
|
195 | const descriptor = this.descriptors.page[methodName] || undefined;
|
196 | const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor);
|
197 | this.innerApiCalls[methodName] = apiCall;
|
198 | }
|
199 | return this.schemaServiceStub;
|
200 | }
|
201 | /**
|
202 | * The DNS address for this API service.
|
203 | * @returns {string} The DNS address for this service.
|
204 | */
|
205 | static get servicePath() {
|
206 | return 'pubsub.googleapis.com';
|
207 | }
|
208 | /**
|
209 | * The DNS address for this API service - same as servicePath(),
|
210 | * exists for compatibility reasons.
|
211 | * @returns {string} The DNS address for this service.
|
212 | */
|
213 | static get apiEndpoint() {
|
214 | return 'pubsub.googleapis.com';
|
215 | }
|
216 | /**
|
217 | * The port for this API service.
|
218 | * @returns {number} The default port for this service.
|
219 | */
|
220 | static get port() {
|
221 | return 443;
|
222 | }
|
223 | /**
|
224 | * The scopes needed to make gRPC calls for every method defined
|
225 | * in this service.
|
226 | * @returns {string[]} List of default scopes.
|
227 | */
|
228 | static get scopes() {
|
229 | return [
|
230 | 'https://www.googleapis.com/auth/cloud-platform',
|
231 | 'https://www.googleapis.com/auth/pubsub',
|
232 | ];
|
233 | }
|
234 | /**
|
235 | * Return the project ID used by this class.
|
236 | * @returns {Promise} A promise that resolves to string containing the project ID.
|
237 | */
|
238 | getProjectId(callback) {
|
239 | if (callback) {
|
240 | this.auth.getProjectId(callback);
|
241 | return;
|
242 | }
|
243 | return this.auth.getProjectId();
|
244 | }
|
245 | createSchema(request, optionsOrCallback, callback) {
|
246 | request = request || {};
|
247 | let options;
|
248 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
249 | callback = optionsOrCallback;
|
250 | options = {};
|
251 | }
|
252 | else {
|
253 | options = optionsOrCallback;
|
254 | }
|
255 | options = options || {};
|
256 | options.otherArgs = options.otherArgs || {};
|
257 | options.otherArgs.headers = options.otherArgs.headers || {};
|
258 | options.otherArgs.headers['x-goog-request-params'] =
|
259 | gax.routingHeader.fromParams({
|
260 | parent: request.parent || '',
|
261 | });
|
262 | this.initialize();
|
263 | return this.innerApiCalls.createSchema(request, options, callback);
|
264 | }
|
265 | getSchema(request, optionsOrCallback, callback) {
|
266 | request = request || {};
|
267 | let options;
|
268 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
269 | callback = optionsOrCallback;
|
270 | options = {};
|
271 | }
|
272 | else {
|
273 | options = optionsOrCallback;
|
274 | }
|
275 | options = options || {};
|
276 | options.otherArgs = options.otherArgs || {};
|
277 | options.otherArgs.headers = options.otherArgs.headers || {};
|
278 | options.otherArgs.headers['x-goog-request-params'] =
|
279 | gax.routingHeader.fromParams({
|
280 | name: request.name || '',
|
281 | });
|
282 | this.initialize();
|
283 | return this.innerApiCalls.getSchema(request, options, callback);
|
284 | }
|
285 | deleteSchema(request, optionsOrCallback, callback) {
|
286 | request = request || {};
|
287 | let options;
|
288 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
289 | callback = optionsOrCallback;
|
290 | options = {};
|
291 | }
|
292 | else {
|
293 | options = optionsOrCallback;
|
294 | }
|
295 | options = options || {};
|
296 | options.otherArgs = options.otherArgs || {};
|
297 | options.otherArgs.headers = options.otherArgs.headers || {};
|
298 | options.otherArgs.headers['x-goog-request-params'] =
|
299 | gax.routingHeader.fromParams({
|
300 | name: request.name || '',
|
301 | });
|
302 | this.initialize();
|
303 | return this.innerApiCalls.deleteSchema(request, options, callback);
|
304 | }
|
305 | validateSchema(request, optionsOrCallback, callback) {
|
306 | request = request || {};
|
307 | let options;
|
308 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
309 | callback = optionsOrCallback;
|
310 | options = {};
|
311 | }
|
312 | else {
|
313 | options = optionsOrCallback;
|
314 | }
|
315 | options = options || {};
|
316 | options.otherArgs = options.otherArgs || {};
|
317 | options.otherArgs.headers = options.otherArgs.headers || {};
|
318 | options.otherArgs.headers['x-goog-request-params'] =
|
319 | gax.routingHeader.fromParams({
|
320 | parent: request.parent || '',
|
321 | });
|
322 | this.initialize();
|
323 | return this.innerApiCalls.validateSchema(request, options, callback);
|
324 | }
|
325 | validateMessage(request, optionsOrCallback, callback) {
|
326 | request = request || {};
|
327 | let options;
|
328 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
329 | callback = optionsOrCallback;
|
330 | options = {};
|
331 | }
|
332 | else {
|
333 | options = optionsOrCallback;
|
334 | }
|
335 | options = options || {};
|
336 | options.otherArgs = options.otherArgs || {};
|
337 | options.otherArgs.headers = options.otherArgs.headers || {};
|
338 | options.otherArgs.headers['x-goog-request-params'] =
|
339 | gax.routingHeader.fromParams({
|
340 | parent: request.parent || '',
|
341 | });
|
342 | this.initialize();
|
343 | return this.innerApiCalls.validateMessage(request, options, callback);
|
344 | }
|
345 | listSchemas(request, optionsOrCallback, callback) {
|
346 | request = request || {};
|
347 | let options;
|
348 | if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
349 | callback = optionsOrCallback;
|
350 | options = {};
|
351 | }
|
352 | else {
|
353 | options = optionsOrCallback;
|
354 | }
|
355 | options = options || {};
|
356 | options.otherArgs = options.otherArgs || {};
|
357 | options.otherArgs.headers = options.otherArgs.headers || {};
|
358 | options.otherArgs.headers['x-goog-request-params'] =
|
359 | gax.routingHeader.fromParams({
|
360 | parent: request.parent || '',
|
361 | });
|
362 | this.initialize();
|
363 | return this.innerApiCalls.listSchemas(request, options, callback);
|
364 | }
|
365 | /**
|
366 | * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
|
367 | * @param {Object} request
|
368 | * The request object that will be sent.
|
369 | * @param {string} request.parent
|
370 | * Required. The name of the project in which to list schemas.
|
371 | * Format is `projects/{project-id}`.
|
372 | * @param {google.pubsub.v1.SchemaView} request.view
|
373 | * The set of Schema fields to return in the response. If not set, returns
|
374 | * Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
|
375 | * retrieve all fields.
|
376 | * @param {number} request.pageSize
|
377 | * Maximum number of schemas to return.
|
378 | * @param {string} request.pageToken
|
379 | * The value returned by the last `ListSchemasResponse`; indicates that
|
380 | * this is a continuation of a prior `ListSchemas` call, and that the
|
381 | * system should return the next page of data.
|
382 | * @param {object} [options]
|
383 | * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
384 | * @returns {Stream}
|
385 | * An object stream which emits an object representing [Schema]{@link google.pubsub.v1.Schema} on 'data' event.
|
386 | * The client library will perform auto-pagination by default: it will call the API as many
|
387 | * times as needed. Note that it can affect your quota.
|
388 | * We recommend using `listSchemasAsync()`
|
389 | * method described below for async iteration which you can stop as needed.
|
390 | * Please see the
|
391 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
|
392 | * for more details and examples.
|
393 | */
|
394 | listSchemasStream(request, options) {
|
395 | request = request || {};
|
396 | options = options || {};
|
397 | options.otherArgs = options.otherArgs || {};
|
398 | options.otherArgs.headers = options.otherArgs.headers || {};
|
399 | options.otherArgs.headers['x-goog-request-params'] =
|
400 | gax.routingHeader.fromParams({
|
401 | parent: request.parent || '',
|
402 | });
|
403 | const defaultCallSettings = this._defaults['listSchemas'];
|
404 | const callSettings = defaultCallSettings.merge(options);
|
405 | this.initialize();
|
406 | return this.descriptors.page.listSchemas.createStream(this.innerApiCalls.listSchemas, request, callSettings);
|
407 | }
|
408 | /**
|
409 | * Equivalent to `listSchemas`, but returns an iterable object.
|
410 | *
|
411 | * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
|
412 | * @param {Object} request
|
413 | * The request object that will be sent.
|
414 | * @param {string} request.parent
|
415 | * Required. The name of the project in which to list schemas.
|
416 | * Format is `projects/{project-id}`.
|
417 | * @param {google.pubsub.v1.SchemaView} request.view
|
418 | * The set of Schema fields to return in the response. If not set, returns
|
419 | * Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
|
420 | * retrieve all fields.
|
421 | * @param {number} request.pageSize
|
422 | * Maximum number of schemas to return.
|
423 | * @param {string} request.pageToken
|
424 | * The value returned by the last `ListSchemasResponse`; indicates that
|
425 | * this is a continuation of a prior `ListSchemas` call, and that the
|
426 | * system should return the next page of data.
|
427 | * @param {object} [options]
|
428 | * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
429 | * @returns {Object}
|
430 | * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
|
431 | * When you iterate the returned iterable, each element will be an object representing
|
432 | * [Schema]{@link google.pubsub.v1.Schema}. The API will be called under the hood as needed, once per the page,
|
433 | * so you can stop the iteration when you don't need more results.
|
434 | * Please see the
|
435 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
|
436 | * for more details and examples.
|
437 | */
|
438 | listSchemasAsync(request, options) {
|
439 | request = request || {};
|
440 | options = options || {};
|
441 | options.otherArgs = options.otherArgs || {};
|
442 | options.otherArgs.headers = options.otherArgs.headers || {};
|
443 | options.otherArgs.headers['x-goog-request-params'] =
|
444 | gax.routingHeader.fromParams({
|
445 | parent: request.parent || '',
|
446 | });
|
447 | const defaultCallSettings = this._defaults['listSchemas'];
|
448 | const callSettings = defaultCallSettings.merge(options);
|
449 | this.initialize();
|
450 | return this.descriptors.page.listSchemas.asyncIterate(this.innerApiCalls['listSchemas'], request, callSettings);
|
451 | }
|
452 | /**
|
453 | * Gets the access control policy for a resource. Returns an empty policy
|
454 | * if the resource exists and does not have a policy set.
|
455 | *
|
456 | * @param {Object} request
|
457 | * The request object that will be sent.
|
458 | * @param {string} request.resource
|
459 | * REQUIRED: The resource for which the policy is being requested.
|
460 | * See the operation documentation for the appropriate value for this field.
|
461 | * @param {Object} [request.options]
|
462 | * OPTIONAL: A `GetPolicyOptions` object for specifying options to
|
463 | * `GetIamPolicy`. This field is only used by Cloud IAM.
|
464 | *
|
465 | * This object should have the same structure as [GetPolicyOptions]{@link google.iam.v1.GetPolicyOptions}
|
466 | * @param {Object} [options]
|
467 | * Optional parameters. You can override the default settings for this call, e.g, timeout,
|
468 | * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details.
|
469 | * @param {function(?Error, ?Object)} [callback]
|
470 | * The function which will be called with the result of the API call.
|
471 | *
|
472 | * The second parameter to the callback is an object representing [Policy]{@link google.iam.v1.Policy}.
|
473 | * @returns {Promise} - The promise which resolves to an array.
|
474 | * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}.
|
475 | * The promise has a method named "cancel" which cancels the ongoing API call.
|
476 | */
|
477 | getIamPolicy(request, options, callback) {
|
478 | return this.iamClient.getIamPolicy(request, options, callback);
|
479 | }
|
480 | /**
|
481 | * Returns permissions that a caller has on the specified resource. If the
|
482 | * resource does not exist, this will return an empty set of
|
483 | * permissions, not a NOT_FOUND error.
|
484 | *
|
485 | * Note: This operation is designed to be used for building
|
486 | * permission-aware UIs and command-line tools, not for authorization
|
487 | * checking. This operation may "fail open" without warning.
|
488 | *
|
489 | * @param {Object} request
|
490 | * The request object that will be sent.
|
491 | * @param {string} request.resource
|
492 | * REQUIRED: The resource for which the policy detail is being requested.
|
493 | * See the operation documentation for the appropriate value for this field.
|
494 | * @param {string[]} request.permissions
|
495 | * The set of permissions to check for the `resource`. Permissions with
|
496 | * wildcards (such as '*' or 'storage.*') are not allowed. For more
|
497 | * information see
|
498 | * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
499 | * @param {Object} [options]
|
500 | * Optional parameters. You can override the default settings for this call, e.g, timeout,
|
501 | * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details.
|
502 | * @param {function(?Error, ?Object)} [callback]
|
503 | * The function which will be called with the result of the API call.
|
504 | *
|
505 | * The second parameter to the callback is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}.
|
506 | * @returns {Promise} - The promise which resolves to an array.
|
507 | * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}.
|
508 | * The promise has a method named "cancel" which cancels the ongoing API call.
|
509 | */
|
510 | setIamPolicy(request, options, callback) {
|
511 | return this.iamClient.setIamPolicy(request, options, callback);
|
512 | }
|
513 | /**
|
514 | * Returns permissions that a caller has on the specified resource. If the
|
515 | * resource does not exist, this will return an empty set of
|
516 | * permissions, not a NOT_FOUND error.
|
517 | *
|
518 | * Note: This operation is designed to be used for building
|
519 | * permission-aware UIs and command-line tools, not for authorization
|
520 | * checking. This operation may "fail open" without warning.
|
521 | *
|
522 | * @param {Object} request
|
523 | * The request object that will be sent.
|
524 | * @param {string} request.resource
|
525 | * REQUIRED: The resource for which the policy detail is being requested.
|
526 | * See the operation documentation for the appropriate value for this field.
|
527 | * @param {string[]} request.permissions
|
528 | * The set of permissions to check for the `resource`. Permissions with
|
529 | * wildcards (such as '*' or 'storage.*') are not allowed. For more
|
530 | * information see
|
531 | * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
532 | * @param {Object} [options]
|
533 | * Optional parameters. You can override the default settings for this call, e.g, timeout,
|
534 | * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html} for the details.
|
535 | * @param {function(?Error, ?Object)} [callback]
|
536 | * The function which will be called with the result of the API call.
|
537 | *
|
538 | * The second parameter to the callback is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}.
|
539 | * @returns {Promise} - The promise which resolves to an array.
|
540 | * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}.
|
541 | * The promise has a method named "cancel" which cancels the ongoing API call.
|
542 | *
|
543 | */
|
544 | testIamPermissions(request, options, callback) {
|
545 | return this.iamClient.testIamPermissions(request, options, callback);
|
546 | }
|
547 | // --------------------
|
548 | // -- Path templates --
|
549 | // --------------------
|
550 | /**
|
551 | * Return a fully-qualified project resource name string.
|
552 | *
|
553 | * @param {string} project
|
554 | * @returns {string} Resource name string.
|
555 | */
|
556 | projectPath(project) {
|
557 | return this.pathTemplates.projectPathTemplate.render({
|
558 | project: project,
|
559 | });
|
560 | }
|
561 | /**
|
562 | * Parse the project from Project resource.
|
563 | *
|
564 | * @param {string} projectName
|
565 | * A fully-qualified path representing Project resource.
|
566 | * @returns {string} A string representing the project.
|
567 | */
|
568 | matchProjectFromProjectName(projectName) {
|
569 | return this.pathTemplates.projectPathTemplate.match(projectName).project;
|
570 | }
|
571 | /**
|
572 | * Return a fully-qualified projectTopic resource name string.
|
573 | *
|
574 | * @param {string} project
|
575 | * @param {string} topic
|
576 | * @returns {string} Resource name string.
|
577 | */
|
578 | projectTopicPath(project, topic) {
|
579 | return this.pathTemplates.projectTopicPathTemplate.render({
|
580 | project: project,
|
581 | topic: topic,
|
582 | });
|
583 | }
|
584 | /**
|
585 | * Parse the project from ProjectTopic resource.
|
586 | *
|
587 | * @param {string} projectTopicName
|
588 | * A fully-qualified path representing project_topic resource.
|
589 | * @returns {string} A string representing the project.
|
590 | */
|
591 | matchProjectFromProjectTopicName(projectTopicName) {
|
592 | return this.pathTemplates.projectTopicPathTemplate.match(projectTopicName)
|
593 | .project;
|
594 | }
|
595 | /**
|
596 | * Parse the topic from ProjectTopic resource.
|
597 | *
|
598 | * @param {string} projectTopicName
|
599 | * A fully-qualified path representing project_topic resource.
|
600 | * @returns {string} A string representing the topic.
|
601 | */
|
602 | matchTopicFromProjectTopicName(projectTopicName) {
|
603 | return this.pathTemplates.projectTopicPathTemplate.match(projectTopicName)
|
604 | .topic;
|
605 | }
|
606 | /**
|
607 | * Return a fully-qualified schema resource name string.
|
608 | *
|
609 | * @param {string} project
|
610 | * @param {string} schema
|
611 | * @returns {string} Resource name string.
|
612 | */
|
613 | schemaPath(project, schema) {
|
614 | return this.pathTemplates.schemaPathTemplate.render({
|
615 | project: project,
|
616 | schema: schema,
|
617 | });
|
618 | }
|
619 | /**
|
620 | * Parse the project from Schema resource.
|
621 | *
|
622 | * @param {string} schemaName
|
623 | * A fully-qualified path representing Schema resource.
|
624 | * @returns {string} A string representing the project.
|
625 | */
|
626 | matchProjectFromSchemaName(schemaName) {
|
627 | return this.pathTemplates.schemaPathTemplate.match(schemaName).project;
|
628 | }
|
629 | /**
|
630 | * Parse the schema from Schema resource.
|
631 | *
|
632 | * @param {string} schemaName
|
633 | * A fully-qualified path representing Schema resource.
|
634 | * @returns {string} A string representing the schema.
|
635 | */
|
636 | matchSchemaFromSchemaName(schemaName) {
|
637 | return this.pathTemplates.schemaPathTemplate.match(schemaName).schema;
|
638 | }
|
639 | /**
|
640 | * Return a fully-qualified snapshot resource name string.
|
641 | *
|
642 | * @param {string} project
|
643 | * @param {string} snapshot
|
644 | * @returns {string} Resource name string.
|
645 | */
|
646 | snapshotPath(project, snapshot) {
|
647 | return this.pathTemplates.snapshotPathTemplate.render({
|
648 | project: project,
|
649 | snapshot: snapshot,
|
650 | });
|
651 | }
|
652 | /**
|
653 | * Parse the project from Snapshot resource.
|
654 | *
|
655 | * @param {string} snapshotName
|
656 | * A fully-qualified path representing Snapshot resource.
|
657 | * @returns {string} A string representing the project.
|
658 | */
|
659 | matchProjectFromSnapshotName(snapshotName) {
|
660 | return this.pathTemplates.snapshotPathTemplate.match(snapshotName).project;
|
661 | }
|
662 | /**
|
663 | * Parse the snapshot from Snapshot resource.
|
664 | *
|
665 | * @param {string} snapshotName
|
666 | * A fully-qualified path representing Snapshot resource.
|
667 | * @returns {string} A string representing the snapshot.
|
668 | */
|
669 | matchSnapshotFromSnapshotName(snapshotName) {
|
670 | return this.pathTemplates.snapshotPathTemplate.match(snapshotName).snapshot;
|
671 | }
|
672 | /**
|
673 | * Return a fully-qualified subscription resource name string.
|
674 | *
|
675 | * @param {string} project
|
676 | * @param {string} subscription
|
677 | * @returns {string} Resource name string.
|
678 | */
|
679 | subscriptionPath(project, subscription) {
|
680 | return this.pathTemplates.subscriptionPathTemplate.render({
|
681 | project: project,
|
682 | subscription: subscription,
|
683 | });
|
684 | }
|
685 | /**
|
686 | * Parse the project from Subscription resource.
|
687 | *
|
688 | * @param {string} subscriptionName
|
689 | * A fully-qualified path representing Subscription resource.
|
690 | * @returns {string} A string representing the project.
|
691 | */
|
692 | matchProjectFromSubscriptionName(subscriptionName) {
|
693 | return this.pathTemplates.subscriptionPathTemplate.match(subscriptionName)
|
694 | .project;
|
695 | }
|
696 | /**
|
697 | * Parse the subscription from Subscription resource.
|
698 | *
|
699 | * @param {string} subscriptionName
|
700 | * A fully-qualified path representing Subscription resource.
|
701 | * @returns {string} A string representing the subscription.
|
702 | */
|
703 | matchSubscriptionFromSubscriptionName(subscriptionName) {
|
704 | return this.pathTemplates.subscriptionPathTemplate.match(subscriptionName)
|
705 | .subscription;
|
706 | }
|
707 | /**
|
708 | * Terminate the gRPC channel and close the client.
|
709 | *
|
710 | * The client will no longer be usable and all future behavior is undefined.
|
711 | * @returns {Promise} A promise that resolves when the client is closed.
|
712 | */
|
713 | close() {
|
714 | if (this.schemaServiceStub && !this._terminated) {
|
715 | return this.schemaServiceStub.then(stub => {
|
716 | this._terminated = true;
|
717 | stub.close();
|
718 | this.iamClient.close();
|
719 | });
|
720 | }
|
721 | return Promise.resolve();
|
722 | }
|
723 | }
|
724 | exports.SchemaServiceClient = SchemaServiceClient;
|
725 | //# sourceMappingURL=schema_service_client.js.map |
\ | No newline at end of file |