UNPKG

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