Skip to content

Commit 0cba45c

Browse files
feat: [Many APIs] add methods from gax to cache proto root and process custom error details (#6421)
* feat: add methods from gax to cache proto root and process custom error details fix: distinguish plural and singular path templates PiperOrigin-RevId: 772168312 Source-Link: googleapis/googleapis@873d84e Source-Link: googleapis/googleapis-gen@f448c1b Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWdrZWh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjQ0OGMxYjRlYWFhNWZkYzcwMjFhNjgyMDY4YzMxM2Q2ZjJmMTA0YSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWdrZW11bHRpY2xvdWQvLk93bEJvdC55YW1sIiwiaCI6ImY0NDhjMWI0ZWFhYTVmZGM3MDIxYTY4MjA2OGMzMTNkNmYyZjEwNGEifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWdzdWl0ZWFkZG9ucy8uT3dsQm90LnlhbWwiLCJoIjoiZjQ0OGMxYjRlYWFhNWZkYzcwMjFhNjgyMDY4YzMxM2Q2ZjJmMTA0YSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWlhcC8uT3dsQm90LnlhbWwiLCJoIjoiZjQ0OGMxYjRlYWFhNWZkYzcwMjFhNjgyMDY4YzMxM2Q2ZjJmMTA0YSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWlkcy8uT3dsQm90LnlhbWwiLCJoIjoiZjQ0OGMxYjRlYWFhNWZkYzcwMjFhNjgyMDY4YzMxM2Q2ZjJmMTA0YSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWlvdC8uT3dsQm90LnlhbWwiLCJoIjoiZjQ0OGMxYjRlYWFhNWZkYzcwMjFhNjgyMDY4YzMxM2Q2ZjJmMTA0YSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2x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WNhY2hlLy5Pd2xCb3QueWFtbCIsImgiOiJmNDQ4YzFiNGVhYWE1ZmRjNzAyMWE2ODIwNjhjMzEzZDZmMmYxMDRhIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1lbW9yeXN0b3JlLy5Pd2xCb3QueWFtbCIsImgiOiJmNDQ4YzFiNGVhYWE1ZmRjNzAyMWE2ODIwNjhjMzEzZDZmMmYxMDRhIn0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1ldGFzdG9yZS8uT3dsQm90LnlhbWwiLCJoIjoiZjQ0OGMxYjRlYWFhNWZkYzcwMjFhNjgyMDY4YzMxM2Q2ZjJmMTA0YSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1pZ3JhdGlvbmNlbnRlci8uT3dsQm90LnlhbWwiLCJoIjoiZjQ0OGMxYjRlYWFhNWZkYzcwMjFhNjgyMDY4YzMxM2Q2ZjJmMTA0YSJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vZGVsYXJtb3IvLk93bEJvdC55YW1sIiwiaCI6ImY0NDhjMWI0ZWFhYTVmZGM3MDIxYTY4MjA2OGMzMTNkNmYyZjEwNGEifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmcvLk93bEJvdC55YW1sIiwiaCI6ImY0NDhjMWI0ZWFhYTVmZGM3MDIxYTY4MjA2OGMzMTNkNmYyZjEwNGEifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW5ldGFwcC8uT3dsQm90LnlhbWwiLCJoIjoiZjQ0OGMxYjRlYWFhNWZkYzcwMjFhNjgyMDY4YzMxM2Q2ZjJmMTA0YSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: sofisl <[email protected]>
1 parent bb07a76 commit 0cba45c

215 files changed

Lines changed: 153612 additions & 201086 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/google-cloud-gkehub/protos/protos.js

Lines changed: 864 additions & 288 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/google-cloud-gkehub/protos/protos.json

Lines changed: 39 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/google-cloud-gkehub/src/v1/gke_hub_client.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOption
2222
import {Transform} from 'stream';
2323
import * as protos from '../../protos/protos';
2424
import jsonProtos = require('../../protos/protos.json');
25-
import {loggingUtils as logging} from 'google-gax';
25+
import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax';
2626

2727
/**
2828
* Client JSON configuration object, loaded from
@@ -218,7 +218,7 @@ export class GkeHubClient {
218218
new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources')
219219
};
220220

221-
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
221+
const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos);
222222
// This API contains "long-running operations", which return a
223223
// an Operation object that allows for tracking of the operation,
224224
// rather than holding a request open.
@@ -520,6 +520,12 @@ export class GkeHubClient {
520520
]) => {
521521
this._log.info('getMembership response %j', response);
522522
return [response, options, rawResponse];
523+
}).catch((error: any) => {
524+
if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
525+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type;
526+
error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos);
527+
}
528+
throw error;
523529
});
524530
}
525531
/**
@@ -609,6 +615,12 @@ export class GkeHubClient {
609615
]) => {
610616
this._log.info('getFeature response %j', response);
611617
return [response, options, rawResponse];
618+
}).catch((error: any) => {
619+
if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
620+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type;
621+
error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos);
622+
}
623+
throw error;
612624
});
613625
}
614626
/**
@@ -725,6 +737,12 @@ export class GkeHubClient {
725737
]) => {
726738
this._log.info('generateConnectManifest response %j', response);
727739
return [response, options, rawResponse];
740+
}).catch((error: any) => {
741+
if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
742+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type;
743+
error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos);
744+
}
745+
throw error;
728746
});
729747
}
730748

packages/google-cloud-gkehub/src/v1alpha/gke_hub_client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOption
2222
import {Transform} from 'stream';
2323
import * as protos from '../../protos/protos';
2424
import jsonProtos = require('../../protos/protos.json');
25-
import {loggingUtils as logging} from 'google-gax';
25+
import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax';
2626

2727
/**
2828
* Client JSON configuration object, loaded from
@@ -204,7 +204,7 @@ export class GkeHubClient {
204204
new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources')
205205
};
206206

207-
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
207+
const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos);
208208
// This API contains "long-running operations", which return a
209209
// an Operation object that allows for tracking of the operation,
210210
// rather than holding a request open.
@@ -482,6 +482,12 @@ export class GkeHubClient {
482482
]) => {
483483
this._log.info('getFeature response %j', response);
484484
return [response, options, rawResponse];
485+
}).catch((error: any) => {
486+
if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
487+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type;
488+
error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos);
489+
}
490+
throw error;
485491
});
486492
}
487493

packages/google-cloud-gkehub/src/v1beta/gke_hub_client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOption
2222
import {Transform} from 'stream';
2323
import * as protos from '../../protos/protos';
2424
import jsonProtos = require('../../protos/protos.json');
25-
import {loggingUtils as logging} from 'google-gax';
25+
import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax';
2626

2727
/**
2828
* Client JSON configuration object, loaded from
@@ -204,7 +204,7 @@ export class GkeHubClient {
204204
new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources')
205205
};
206206

207-
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
207+
const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos);
208208
// This API contains "long-running operations", which return a
209209
// an Operation object that allows for tracking of the operation,
210210
// rather than holding a request open.
@@ -482,6 +482,12 @@ export class GkeHubClient {
482482
]) => {
483483
this._log.info('getFeature response %j', response);
484484
return [response, options, rawResponse];
485+
}).catch((error: any) => {
486+
if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
487+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type;
488+
error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos);
489+
}
490+
throw error;
485491
});
486492
}
487493

0 commit comments

Comments
 (0)