Skip to content

Commit

Permalink
fix: better support for fallback mode (#735)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 468790263

Source-Link: googleapis/googleapis@873ab45

Source-Link: googleapis/googleapis-gen@cb6f37a
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2I2ZjM3YWVmZjJhMzQ3MmU0MGE3YmJhY2U4YzY3ZDc1ZTI0YmVlNSJ9
gcf-owl-bot[bot] authored Aug 23, 2022
1 parent 07e9680 commit 11a3a9f
Showing 37 changed files with 227 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_ActivateJobTrigger_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_CancelDlpJob_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent, deidentifyTemplate) {
// [START dlp_v2_generated_DlpService_CreateDeidentifyTemplate_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent) {
// [START dlp_v2_generated_DlpService_CreateDlpJob_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent, inspectTemplate) {
// [START dlp_v2_generated_DlpService_CreateInspectTemplate_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent, jobTrigger) {
// [START dlp_v2_generated_DlpService_CreateJobTrigger_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent, config) {
// [START dlp_v2_generated_DlpService_CreateStoredInfoType_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main() {
// [START dlp_v2_generated_DlpService_DeidentifyContent_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_DeleteDeidentifyTemplate_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_DeleteDlpJob_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_DeleteInspectTemplate_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_DeleteJobTrigger_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_DeleteStoredInfoType_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_FinishDlpJob_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_GetDeidentifyTemplate_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_GetDlpJob_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_GetInspectTemplate_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_GetJobTrigger_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_GetStoredInfoType_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_HybridInspectDlpJob_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_HybridInspectJobTrigger_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main() {
// [START dlp_v2_generated_DlpService_InspectContent_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent) {
// [START dlp_v2_generated_DlpService_ListDeidentifyTemplates_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent) {
// [START dlp_v2_generated_DlpService_ListDlpJobs_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main() {
// [START dlp_v2_generated_DlpService_ListInfoTypes_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent) {
// [START dlp_v2_generated_DlpService_ListInspectTemplates_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent) {
// [START dlp_v2_generated_DlpService_ListJobTriggers_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent) {
// [START dlp_v2_generated_DlpService_ListStoredInfoTypes_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main() {
// [START dlp_v2_generated_DlpService_RedactImage_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(parent) {
// [START dlp_v2_generated_DlpService_ReidentifyContent_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_UpdateDeidentifyTemplate_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_UpdateInspectTemplate_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_UpdateJobTrigger_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
function main(name) {
// [START dlp_v2_generated_DlpService_UpdateStoredInfoType_async]
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
"segments": [
{
"start": 25,
"end": 77,
"end": 80,
"type": "FULL"
}
],
@@ -78,7 +78,7 @@
"segments": [
{
"start": 25,
"end": 77,
"end": 80,
"type": "FULL"
}
],
@@ -138,7 +138,7 @@
"segments": [
{
"start": 25,
"end": 92,
"end": 95,
"type": "FULL"
}
],
@@ -202,7 +202,7 @@
"segments": [
{
"start": 25,
"end": 99,
"end": 102,
"type": "FULL"
}
],
@@ -266,7 +266,7 @@
"segments": [
{
"start": 25,
"end": 62,
"end": 65,
"type": "FULL"
}
],
@@ -318,7 +318,7 @@
"segments": [
{
"start": 25,
"end": 77,
"end": 80,
"type": "FULL"
}
],
@@ -370,7 +370,7 @@
"segments": [
{
"start": 25,
"end": 60,
"end": 63,
"type": "FULL"
}
],
@@ -418,7 +418,7 @@
"segments": [
{
"start": 25,
"end": 52,
"end": 55,
"type": "FULL"
}
],
@@ -458,7 +458,7 @@
"segments": [
{
"start": 25,
"end": 90,
"end": 93,
"type": "FULL"
}
],
@@ -514,7 +514,7 @@
"segments": [
{
"start": 25,
"end": 52,
"end": 55,
"type": "FULL"
}
],
@@ -554,7 +554,7 @@
"segments": [
{
"start": 25,
"end": 77,
"end": 80,
"type": "FULL"
}
],
@@ -606,7 +606,7 @@
"segments": [
{
"start": 25,
"end": 60,
"end": 63,
"type": "FULL"
}
],
@@ -654,7 +654,7 @@
"segments": [
{
"start": 25,
"end": 52,
"end": 55,
"type": "FULL"
}
],
@@ -694,7 +694,7 @@
"segments": [
{
"start": 25,
"end": 90,
"end": 93,
"type": "FULL"
}
],
@@ -750,7 +750,7 @@
"segments": [
{
"start": 25,
"end": 52,
"end": 55,
"type": "FULL"
}
],
@@ -790,7 +790,7 @@
"segments": [
{
"start": 25,
"end": 73,
"end": 76,
"type": "FULL"
}
],
@@ -842,7 +842,7 @@
"segments": [
{
"start": 25,
"end": 59,
"end": 62,
"type": "FULL"
}
],
@@ -890,7 +890,7 @@
"segments": [
{
"start": 25,
"end": 55,
"end": 58,
"type": "FULL"
}
],
@@ -934,7 +934,7 @@
"segments": [
{
"start": 25,
"end": 51,
"end": 54,
"type": "FULL"
}
],
@@ -974,7 +974,7 @@
"segments": [
{
"start": 25,
"end": 114,
"end": 117,
"type": "FULL"
}
],
@@ -1038,7 +1038,7 @@
"segments": [
{
"start": 25,
"end": 51,
"end": 54,
"type": "FULL"
}
],
@@ -1078,7 +1078,7 @@
"segments": [
{
"start": 25,
"end": 51,
"end": 54,
"type": "FULL"
}
],
@@ -1118,7 +1118,7 @@
"segments": [
{
"start": 25,
"end": 77,
"end": 80,
"type": "FULL"
}
],
@@ -1174,7 +1174,7 @@
"segments": [
{
"start": 25,
"end": 114,
"end": 117,
"type": "FULL"
}
],
@@ -1238,7 +1238,7 @@
"segments": [
{
"start": 25,
"end": 50,
"end": 53,
"type": "FULL"
}
],
@@ -1278,7 +1278,7 @@
"segments": [
{
"start": 25,
"end": 50,
"end": 53,
"type": "FULL"
}
],
@@ -1318,7 +1318,7 @@
"segments": [
{
"start": 25,
"end": 50,
"end": 53,
"type": "FULL"
}
],
@@ -1358,7 +1358,7 @@
"segments": [
{
"start": 25,
"end": 77,
"end": 80,
"type": "FULL"
}
],
@@ -1410,7 +1410,7 @@
"segments": [
{
"start": 25,
"end": 62,
"end": 65,
"type": "FULL"
}
],
@@ -1458,7 +1458,7 @@
"segments": [
{
"start": 25,
"end": 52,
"end": 55,
"type": "FULL"
}
],
@@ -1498,7 +1498,7 @@
"segments": [
{
"start": 25,
"end": 91,
"end": 94,
"type": "FULL"
}
],
@@ -1554,7 +1554,7 @@
"segments": [
{
"start": 25,
"end": 52,
"end": 55,
"type": "FULL"
}
],
@@ -1594,7 +1594,7 @@
"segments": [
{
"start": 25,
"end": 55,
"end": 58,
"type": "FULL"
}
],
@@ -1638,7 +1638,7 @@
"segments": [
{
"start": 25,
"end": 50,
"end": 53,
"type": "FULL"
}
],
24 changes: 12 additions & 12 deletions packages/google-privacy-dlp/src/v2/dlp_service_client.ts
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@ import {
} 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');
/**
@@ -375,7 +374,8 @@ export class DlpServiceClient {
const apiCall = this._gaxModule.createApiCall(
callPromise,
this._defaults[methodName],
descriptor
descriptor,
this._opts.fallback
);

this.innerApiCalls[methodName] = apiCall;
@@ -3609,7 +3609,7 @@ export class DlpServiceClient {
const callSettings = defaultCallSettings.merge(options);
this.initialize();
return this.descriptors.page.listInspectTemplates.createStream(
this.innerApiCalls.listInspectTemplates as gax.GaxCall,
this.innerApiCalls.listInspectTemplates as GaxCall,
request,
callSettings
);
@@ -3694,7 +3694,7 @@ export class DlpServiceClient {
this.initialize();
return this.descriptors.page.listInspectTemplates.asyncIterate(
this.innerApiCalls['listInspectTemplates'] as GaxCall,
request as unknown as RequestType,
request as {},
callSettings
) as AsyncIterable<protos.google.privacy.dlp.v2.IInspectTemplate>;
}
@@ -3915,7 +3915,7 @@ export class DlpServiceClient {
const callSettings = defaultCallSettings.merge(options);
this.initialize();
return this.descriptors.page.listDeidentifyTemplates.createStream(
this.innerApiCalls.listDeidentifyTemplates as gax.GaxCall,
this.innerApiCalls.listDeidentifyTemplates as GaxCall,
request,
callSettings
);
@@ -4000,7 +4000,7 @@ export class DlpServiceClient {
this.initialize();
return this.descriptors.page.listDeidentifyTemplates.asyncIterate(
this.innerApiCalls['listDeidentifyTemplates'] as GaxCall,
request as unknown as RequestType,
request as {},
callSettings
) as AsyncIterable<protos.google.privacy.dlp.v2.IDeidentifyTemplate>;
}
@@ -4260,7 +4260,7 @@ export class DlpServiceClient {
const callSettings = defaultCallSettings.merge(options);
this.initialize();
return this.descriptors.page.listJobTriggers.createStream(
this.innerApiCalls.listJobTriggers as gax.GaxCall,
this.innerApiCalls.listJobTriggers as GaxCall,
request,
callSettings
);
@@ -4370,7 +4370,7 @@ export class DlpServiceClient {
this.initialize();
return this.descriptors.page.listJobTriggers.asyncIterate(
this.innerApiCalls['listJobTriggers'] as GaxCall,
request as unknown as RequestType,
request as {},
callSettings
) as AsyncIterable<protos.google.privacy.dlp.v2.IJobTrigger>;
}
@@ -4629,7 +4629,7 @@ export class DlpServiceClient {
const callSettings = defaultCallSettings.merge(options);
this.initialize();
return this.descriptors.page.listDlpJobs.createStream(
this.innerApiCalls.listDlpJobs as gax.GaxCall,
this.innerApiCalls.listDlpJobs as GaxCall,
request,
callSettings
);
@@ -4739,7 +4739,7 @@ export class DlpServiceClient {
this.initialize();
return this.descriptors.page.listDlpJobs.asyncIterate(
this.innerApiCalls['listDlpJobs'] as GaxCall,
request as unknown as RequestType,
request as {},
callSettings
) as AsyncIterable<protos.google.privacy.dlp.v2.IDlpJob>;
}
@@ -4958,7 +4958,7 @@ export class DlpServiceClient {
const callSettings = defaultCallSettings.merge(options);
this.initialize();
return this.descriptors.page.listStoredInfoTypes.createStream(
this.innerApiCalls.listStoredInfoTypes as gax.GaxCall,
this.innerApiCalls.listStoredInfoTypes as GaxCall,
request,
callSettings
);
@@ -5044,7 +5044,7 @@ export class DlpServiceClient {
this.initialize();
return this.descriptors.page.listStoredInfoTypes.asyncIterate(
this.innerApiCalls['listStoredInfoTypes'] as GaxCall,
request as unknown as RequestType,
request as {},
callSettings
) as AsyncIterable<protos.google.privacy.dlp.v2.IStoredInfoType>;
}
156 changes: 79 additions & 77 deletions packages/google-privacy-dlp/test/gapic_dlp_service_v2.ts
Original file line number Diff line number Diff line change
@@ -113,99 +113,101 @@ function stubAsyncIterationCall<ResponseType>(
}

describe('v2.DlpServiceClient', () => {
it('has servicePath', () => {
const servicePath = dlpserviceModule.v2.DlpServiceClient.servicePath;
assert(servicePath);
});

it('has apiEndpoint', () => {
const apiEndpoint = dlpserviceModule.v2.DlpServiceClient.apiEndpoint;
assert(apiEndpoint);
});

it('has port', () => {
const port = dlpserviceModule.v2.DlpServiceClient.port;
assert(port);
assert(typeof port === 'number');
});
describe('Common methods', () => {
it('has servicePath', () => {
const servicePath = dlpserviceModule.v2.DlpServiceClient.servicePath;
assert(servicePath);
});

it('should create a client with no option', () => {
const client = new dlpserviceModule.v2.DlpServiceClient();
assert(client);
});
it('has apiEndpoint', () => {
const apiEndpoint = dlpserviceModule.v2.DlpServiceClient.apiEndpoint;
assert(apiEndpoint);
});

it('should create a client with gRPC fallback', () => {
const client = new dlpserviceModule.v2.DlpServiceClient({
fallback: true,
it('has port', () => {
const port = dlpserviceModule.v2.DlpServiceClient.port;
assert(port);
assert(typeof port === 'number');
});
assert(client);
});

it('has initialize method and supports deferred initialization', async () => {
const client = new dlpserviceModule.v2.DlpServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
it('should create a client with no option', () => {
const client = new dlpserviceModule.v2.DlpServiceClient();
assert(client);
});
assert.strictEqual(client.dlpServiceStub, undefined);
await client.initialize();
assert(client.dlpServiceStub);
});

it('has close method for the initialized client', done => {
const client = new dlpserviceModule.v2.DlpServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
it('should create a client with gRPC fallback', () => {
const client = new dlpserviceModule.v2.DlpServiceClient({
fallback: true,
});
assert(client);
});
client.initialize();
assert(client.dlpServiceStub);
client.close().then(() => {
done();

it('has initialize method and supports deferred initialization', async () => {
const client = new dlpserviceModule.v2.DlpServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
assert.strictEqual(client.dlpServiceStub, undefined);
await client.initialize();
assert(client.dlpServiceStub);
});
});

it('has close method for the non-initialized client', done => {
const client = new dlpserviceModule.v2.DlpServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
it('has close method for the initialized client', done => {
const client = new dlpserviceModule.v2.DlpServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
client.initialize();
assert(client.dlpServiceStub);
client.close().then(() => {
done();
});
});
assert.strictEqual(client.dlpServiceStub, undefined);
client.close().then(() => {
done();

it('has close method for the non-initialized client', done => {
const client = new dlpserviceModule.v2.DlpServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
assert.strictEqual(client.dlpServiceStub, undefined);
client.close().then(() => {
done();
});
});
});

it('has getProjectId method', async () => {
const fakeProjectId = 'fake-project-id';
const client = new dlpserviceModule.v2.DlpServiceClient({
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
it('has getProjectId method', async () => {
const fakeProjectId = 'fake-project-id';
const client = new dlpserviceModule.v2.DlpServiceClient({
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());
});
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 dlpserviceModule.v2.DlpServiceClient({
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);
}
it('has getProjectId method with callback', async () => {
const fakeProjectId = 'fake-project-id';
const client = new dlpserviceModule.v2.DlpServiceClient({
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);
});
const result = await promise;
assert.strictEqual(result, fakeProjectId);
});

describe('inspectContent', () => {

0 comments on commit 11a3a9f

Please sign in to comment.