Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def patch(library: pathlib.Path):

# perform surgery inserting the Grafeas client.
s.replace(library / "src/v1/container_analysis_client.ts",
"""import \* as gax from \'google-gax\';""",
"""import * as gax from 'google-gax';
"""import type \* as gax from \'google-gax\';""",
"""import type * as gax from 'google-gax';
import {GrafeasClient} from '@google-cloud/grafeas';""")
s.replace(library / "src/v1/container_analysis_client.ts", "^}",
r"""
Expand Down
47 changes: 33 additions & 14 deletions src/v1/container_analysis_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
// ** All changes to this file may be overwritten. **

/* global window */
import * as gax from 'google-gax';
import type * as gax from 'google-gax';
import {GrafeasClient} from '@google-cloud/grafeas';
import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
import type {
Callback,
CallOptions,
Descriptors,
ClientOptions,
} from 'google-gax';

import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
Expand All @@ -29,7 +34,6 @@ import jsonProtos = require('../../protos/protos.json');
* This file defines retry strategy and timeouts for all API methods in this library.
*/
import * as gapicConfig from './container_analysis_client_config.json';

const version = require('../../../package.json').version;

/**
Expand Down Expand Up @@ -101,8 +105,18 @@ export class ContainerAnalysisClient {
* 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}.
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
* need to avoid loading the default gRPC version and want to use the fallback
* HTTP implementation. Load only fallback version and pass it to the constructor:
* ```
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
* const client = new ContainerAnalysisClient({fallback: 'rest'}, gax);
* ```
*/
constructor(opts?: ClientOptions) {
constructor(
opts?: ClientOptions,
gaxInstance?: typeof gax | typeof gax.fallback
) {
// Ensure that options include all the required fields.
const staticMembers = this.constructor as typeof ContainerAnalysisClient;
const servicePath =
Expand All @@ -122,8 +136,13 @@ export class ContainerAnalysisClient {
opts['scopes'] = staticMembers.scopes;
}

// Load google-gax module synchronously if needed
if (!gaxInstance) {
gaxInstance = require('google-gax') as typeof gax;
}

// Choose either gRPC or proto-over-HTTP implementation of google-gax.
this._gaxModule = opts.fallback ? gax.fallback : gax;
this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;

// Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
Expand Down Expand Up @@ -192,7 +211,7 @@ export class ContainerAnalysisClient {
this.innerApiCalls = {};

// Add a warn function to the client constructor so it can be easily tested.
this.warn = gax.warn;
this.warn = this._gaxModule.warn;
}

/**
Expand Down Expand Up @@ -412,8 +431,8 @@ export class ContainerAnalysisClient {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
resource: request.resource || '',
this._gaxModule.routingHeader.fromParams({
resource: request.resource ?? '',
});
this.initialize();
return this.innerApiCalls.setIamPolicy(request, options, callback);
Expand Down Expand Up @@ -506,8 +525,8 @@ export class ContainerAnalysisClient {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
resource: request.resource || '',
this._gaxModule.routingHeader.fromParams({
resource: request.resource ?? '',
});
this.initialize();
return this.innerApiCalls.getIamPolicy(request, options, callback);
Expand Down Expand Up @@ -601,8 +620,8 @@ export class ContainerAnalysisClient {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
resource: request.resource || '',
this._gaxModule.routingHeader.fromParams({
resource: request.resource ?? '',
});
this.initialize();
return this.innerApiCalls.testIamPermissions(request, options, callback);
Expand Down Expand Up @@ -701,8 +720,8 @@ export class ContainerAnalysisClient {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
parent: request.parent || '',
this._gaxModule.routingHeader.fromParams({
parent: request.parent ?? '',
});
this.initialize();
return this.innerApiCalls.getVulnerabilityOccurrencesSummary(
Expand Down
59 changes: 36 additions & 23 deletions src/v1beta1/container_analysis_v1_beta1_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
// ** All changes to this file may be overwritten. **

/* global window */
import * as gax from 'google-gax';
import {
import type * as gax from 'google-gax';
import type {
Callback,
CallOptions,
Descriptors,
ClientOptions,
PaginationCallback,
GaxCall,
} from 'google-gax';

import {Transform} from 'stream';
import * as protos from '../../protos/protos';
import jsonProtos = require('../../protos/protos.json');
Expand All @@ -36,7 +35,6 @@ import jsonProtos = require('../../protos/protos.json');
* This file defines retry strategy and timeouts for all API methods in this library.
*/
import * as gapicConfig from './container_analysis_v1_beta1_client_config.json';

const version = require('../../../package.json').version;

/**
Expand Down Expand Up @@ -108,8 +106,18 @@ export class ContainerAnalysisV1Beta1Client {
* 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}.
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
* need to avoid loading the default gRPC version and want to use the fallback
* HTTP implementation. Load only fallback version and pass it to the constructor:
* ```
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
* const client = new ContainerAnalysisV1Beta1Client({fallback: 'rest'}, gax);
* ```
*/
constructor(opts?: ClientOptions) {
constructor(
opts?: ClientOptions,
gaxInstance?: typeof gax | typeof gax.fallback
) {
// Ensure that options include all the required fields.
const staticMembers = this
.constructor as typeof ContainerAnalysisV1Beta1Client;
Expand All @@ -130,8 +138,13 @@ export class ContainerAnalysisV1Beta1Client {
opts['scopes'] = staticMembers.scopes;
}

// Load google-gax module synchronously if needed
if (!gaxInstance) {
gaxInstance = require('google-gax') as typeof gax;
}

// Choose either gRPC or proto-over-HTTP implementation of google-gax.
this._gaxModule = opts.fallback ? gax.fallback : gax;
this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;

// Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
Expand Down Expand Up @@ -208,7 +221,7 @@ export class ContainerAnalysisV1Beta1Client {
this.innerApiCalls = {};

// Add a warn function to the client constructor so it can be easily tested.
this.warn = gax.warn;
this.warn = this._gaxModule.warn;
}

/**
Expand Down Expand Up @@ -430,8 +443,8 @@ export class ContainerAnalysisV1Beta1Client {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
resource: request.resource || '',
this._gaxModule.routingHeader.fromParams({
resource: request.resource ?? '',
});
this.initialize();
return this.innerApiCalls.setIamPolicy(request, options, callback);
Expand Down Expand Up @@ -524,8 +537,8 @@ export class ContainerAnalysisV1Beta1Client {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
resource: request.resource || '',
this._gaxModule.routingHeader.fromParams({
resource: request.resource ?? '',
});
this.initialize();
return this.innerApiCalls.getIamPolicy(request, options, callback);
Expand Down Expand Up @@ -619,8 +632,8 @@ export class ContainerAnalysisV1Beta1Client {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
resource: request.resource || '',
this._gaxModule.routingHeader.fromParams({
resource: request.resource ?? '',
});
this.initialize();
return this.innerApiCalls.testIamPermissions(request, options, callback);
Expand Down Expand Up @@ -717,8 +730,8 @@ export class ContainerAnalysisV1Beta1Client {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
name: request.name || '',
this._gaxModule.routingHeader.fromParams({
name: request.name ?? '',
});
this.initialize();
return this.innerApiCalls.getScanConfig(request, options, callback);
Expand Down Expand Up @@ -817,8 +830,8 @@ export class ContainerAnalysisV1Beta1Client {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
name: request.name || '',
this._gaxModule.routingHeader.fromParams({
name: request.name ?? '',
});
this.initialize();
return this.innerApiCalls.updateScanConfig(request, options, callback);
Expand Down Expand Up @@ -919,8 +932,8 @@ export class ContainerAnalysisV1Beta1Client {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
parent: request.parent || '',
this._gaxModule.routingHeader.fromParams({
parent: request.parent ?? '',
});
this.initialize();
return this.innerApiCalls.listScanConfigs(request, options, callback);
Expand Down Expand Up @@ -960,8 +973,8 @@ export class ContainerAnalysisV1Beta1Client {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
parent: request.parent || '',
this._gaxModule.routingHeader.fromParams({
parent: request.parent ?? '',
});
const defaultCallSettings = this._defaults['listScanConfigs'];
const callSettings = defaultCallSettings.merge(options);
Expand Down Expand Up @@ -1010,8 +1023,8 @@ export class ContainerAnalysisV1Beta1Client {
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
parent: request.parent || '',
this._gaxModule.routingHeader.fromParams({
parent: request.parent ?? '',
});
const defaultCallSettings = this._defaults['listScanConfigs'];
const callSettings = defaultCallSettings.merge(options);
Expand Down
Loading