Skip to content

Commit 77f9a46

Browse files
fix: fixes for routing headers (#17)
* fix: fixes for routing headers Use gapic-generator-typescript v2.15.3. Committer: @alexander-fenster PiperOrigin-RevId: 462159384 Source-Link: googleapis/googleapis@ff8159e Source-Link: googleapis/googleapis-gen@72d2f0f Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzJkMmYwZmFhNDNkZTZmYTgxOTA5NGRhOTA3MGEzMDM2ZDdjYzNlMyJ9 * 🦉 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>
1 parent cb5919f commit 77f9a46

File tree

4 files changed

+464
-158
lines changed

4 files changed

+464
-158
lines changed

packages/google-cloud-run/src/v2/revisions_client.ts

+55-50
Original file line numberDiff line numberDiff line change
@@ -454,17 +454,18 @@ export class RevisionsClient {
454454
options.otherArgs = options.otherArgs || {};
455455
options.otherArgs.headers = options.otherArgs.headers || {};
456456
const routingParameter = {};
457-
if (
458-
typeof request.name !== 'undefined' &&
459-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?').test(
460-
request.name!
461-
)
462-
) {
463-
Object.assign(routingParameter, {
464-
location: request.name!.match(RegExp('(?<location>[^/]+)'))![0],
465-
});
457+
{
458+
const fieldValue = request.name;
459+
if (fieldValue !== undefined && fieldValue !== null) {
460+
const match = fieldValue
461+
.toString()
462+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?'));
463+
if (match) {
464+
const parameterValue = match.groups?.['location'] ?? fieldValue;
465+
Object.assign(routingParameter, {location: parameterValue});
466+
}
467+
}
466468
}
467-
468469
options.otherArgs.headers['x-goog-request-params'] =
469470
gax.routingHeader.fromParams(routingParameter);
470471
this.initialize();
@@ -576,17 +577,18 @@ export class RevisionsClient {
576577
options.otherArgs = options.otherArgs || {};
577578
options.otherArgs.headers = options.otherArgs.headers || {};
578579
const routingParameter = {};
579-
if (
580-
typeof request.name !== 'undefined' &&
581-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?').test(
582-
request.name!
583-
)
584-
) {
585-
Object.assign(routingParameter, {
586-
location: request.name!.match(RegExp('(?<location>[^/]+)'))![0],
587-
});
580+
{
581+
const fieldValue = request.name;
582+
if (fieldValue !== undefined && fieldValue !== null) {
583+
const match = fieldValue
584+
.toString()
585+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?'));
586+
if (match) {
587+
const parameterValue = match.groups?.['location'] ?? fieldValue;
588+
Object.assign(routingParameter, {location: parameterValue});
589+
}
590+
}
588591
}
589-
590592
options.otherArgs.headers['x-goog-request-params'] =
591593
gax.routingHeader.fromParams(routingParameter);
592594
this.initialize();
@@ -716,17 +718,18 @@ export class RevisionsClient {
716718
options.otherArgs = options.otherArgs || {};
717719
options.otherArgs.headers = options.otherArgs.headers || {};
718720
const routingParameter = {};
719-
if (
720-
typeof request.parent !== 'undefined' &&
721-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?').test(
722-
request.parent!
723-
)
724-
) {
725-
Object.assign(routingParameter, {
726-
location: request.parent!.match(RegExp('(?<location>[^/]+)'))![0],
727-
});
721+
{
722+
const fieldValue = request.parent;
723+
if (fieldValue !== undefined && fieldValue !== null) {
724+
const match = fieldValue
725+
.toString()
726+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?'));
727+
if (match) {
728+
const parameterValue = match.groups?.['location'] ?? fieldValue;
729+
Object.assign(routingParameter, {location: parameterValue});
730+
}
731+
}
728732
}
729-
730733
options.otherArgs.headers['x-goog-request-params'] =
731734
gax.routingHeader.fromParams(routingParameter);
732735
this.initialize();
@@ -770,17 +773,18 @@ export class RevisionsClient {
770773
options.otherArgs = options.otherArgs || {};
771774
options.otherArgs.headers = options.otherArgs.headers || {};
772775
const routingParameter = {};
773-
if (
774-
typeof request.parent !== 'undefined' &&
775-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?').test(
776-
request.parent!
777-
)
778-
) {
779-
Object.assign(routingParameter, {
780-
location: request.parent!.match(RegExp('(?<location>[^/]+)'))![0],
781-
});
776+
{
777+
const fieldValue = request.parent;
778+
if (fieldValue !== undefined && fieldValue !== null) {
779+
const match = fieldValue
780+
.toString()
781+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?'));
782+
if (match) {
783+
const parameterValue = match.groups?.['location'] ?? fieldValue;
784+
Object.assign(routingParameter, {location: parameterValue});
785+
}
786+
}
782787
}
783-
784788
options.otherArgs.headers['x-goog-request-params'] =
785789
gax.routingHeader.fromParams(routingParameter);
786790
const defaultCallSettings = this._defaults['listRevisions'];
@@ -833,17 +837,18 @@ export class RevisionsClient {
833837
options.otherArgs = options.otherArgs || {};
834838
options.otherArgs.headers = options.otherArgs.headers || {};
835839
const routingParameter = {};
836-
if (
837-
typeof request.parent !== 'undefined' &&
838-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?').test(
839-
request.parent!
840-
)
841-
) {
842-
Object.assign(routingParameter, {
843-
location: request.parent!.match(RegExp('(?<location>[^/]+)'))![0],
844-
});
840+
{
841+
const fieldValue = request.parent;
842+
if (fieldValue !== undefined && fieldValue !== null) {
843+
const match = fieldValue
844+
.toString()
845+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?'));
846+
if (match) {
847+
const parameterValue = match.groups?.['location'] ?? fieldValue;
848+
Object.assign(routingParameter, {location: parameterValue});
849+
}
850+
}
845851
}
846-
847852
options.otherArgs.headers['x-goog-request-params'] =
848853
gax.routingHeader.fromParams(routingParameter);
849854
const defaultCallSettings = this._defaults['listRevisions'];

packages/google-cloud-run/src/v2/services_client.ts

+77-72
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,18 @@ export class ServicesClient {
477477
options.otherArgs = options.otherArgs || {};
478478
options.otherArgs.headers = options.otherArgs.headers || {};
479479
const routingParameter = {};
480-
if (
481-
typeof request.name !== 'undefined' &&
482-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?').test(
483-
request.name!
484-
)
485-
) {
486-
Object.assign(routingParameter, {
487-
location: request.name!.match(RegExp('(?<location>[^/]+)'))![0],
488-
});
480+
{
481+
const fieldValue = request.name;
482+
if (fieldValue !== undefined && fieldValue !== null) {
483+
const match = fieldValue
484+
.toString()
485+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?'));
486+
if (match) {
487+
const parameterValue = match.groups?.['location'] ?? fieldValue;
488+
Object.assign(routingParameter, {location: parameterValue});
489+
}
490+
}
489491
}
490-
491492
options.otherArgs.headers['x-goog-request-params'] =
492493
gax.routingHeader.fromParams(routingParameter);
493494
this.initialize();
@@ -875,17 +876,18 @@ export class ServicesClient {
875876
options.otherArgs = options.otherArgs || {};
876877
options.otherArgs.headers = options.otherArgs.headers || {};
877878
const routingParameter = {};
878-
if (
879-
typeof request.parent !== 'undefined' &&
880-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)').test(
881-
request.parent!
882-
)
883-
) {
884-
Object.assign(routingParameter, {
885-
location: request.parent!.match(RegExp('(?<location>[^/]+)'))![0],
886-
});
879+
{
880+
const fieldValue = request.parent;
881+
if (fieldValue !== undefined && fieldValue !== null) {
882+
const match = fieldValue
883+
.toString()
884+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)'));
885+
if (match) {
886+
const parameterValue = match.groups?.['location'] ?? fieldValue;
887+
Object.assign(routingParameter, {location: parameterValue});
888+
}
889+
}
887890
}
888-
889891
options.otherArgs.headers['x-goog-request-params'] =
890892
gax.routingHeader.fromParams(routingParameter);
891893
this.initialize();
@@ -1029,19 +1031,18 @@ export class ServicesClient {
10291031
options.otherArgs = options.otherArgs || {};
10301032
options.otherArgs.headers = options.otherArgs.headers || {};
10311033
const routingParameter = {};
1032-
if (
1033-
typeof request.service?.name !== 'undefined' &&
1034-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?').test(
1035-
request.service?.name!
1036-
)
1037-
) {
1038-
Object.assign(routingParameter, {
1039-
location: request.service?.name!.match(
1040-
RegExp('(?<location>[^/]+)')
1041-
)![0],
1042-
});
1034+
{
1035+
const fieldValue = request.service?.name;
1036+
if (fieldValue !== undefined && fieldValue !== null) {
1037+
const match = fieldValue
1038+
.toString()
1039+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?'));
1040+
if (match) {
1041+
const parameterValue = match.groups?.['location'] ?? fieldValue;
1042+
Object.assign(routingParameter, {location: parameterValue});
1043+
}
1044+
}
10431045
}
1044-
10451046
options.otherArgs.headers['x-goog-request-params'] =
10461047
gax.routingHeader.fromParams(routingParameter);
10471048
this.initialize();
@@ -1187,17 +1188,18 @@ export class ServicesClient {
11871188
options.otherArgs = options.otherArgs || {};
11881189
options.otherArgs.headers = options.otherArgs.headers || {};
11891190
const routingParameter = {};
1190-
if (
1191-
typeof request.name !== 'undefined' &&
1192-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?').test(
1193-
request.name!
1194-
)
1195-
) {
1196-
Object.assign(routingParameter, {
1197-
location: request.name!.match(RegExp('(?<location>[^/]+)'))![0],
1198-
});
1191+
{
1192+
const fieldValue = request.name;
1193+
if (fieldValue !== undefined && fieldValue !== null) {
1194+
const match = fieldValue
1195+
.toString()
1196+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)(?:/.*)?'));
1197+
if (match) {
1198+
const parameterValue = match.groups?.['location'] ?? fieldValue;
1199+
Object.assign(routingParameter, {location: parameterValue});
1200+
}
1201+
}
11991202
}
1200-
12011203
options.otherArgs.headers['x-goog-request-params'] =
12021204
gax.routingHeader.fromParams(routingParameter);
12031205
this.initialize();
@@ -1326,17 +1328,18 @@ export class ServicesClient {
13261328
options.otherArgs = options.otherArgs || {};
13271329
options.otherArgs.headers = options.otherArgs.headers || {};
13281330
const routingParameter = {};
1329-
if (
1330-
typeof request.parent !== 'undefined' &&
1331-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)').test(
1332-
request.parent!
1333-
)
1334-
) {
1335-
Object.assign(routingParameter, {
1336-
location: request.parent!.match(RegExp('(?<location>[^/]+)'))![0],
1337-
});
1331+
{
1332+
const fieldValue = request.parent;
1333+
if (fieldValue !== undefined && fieldValue !== null) {
1334+
const match = fieldValue
1335+
.toString()
1336+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)'));
1337+
if (match) {
1338+
const parameterValue = match.groups?.['location'] ?? fieldValue;
1339+
Object.assign(routingParameter, {location: parameterValue});
1340+
}
1341+
}
13381342
}
1339-
13401343
options.otherArgs.headers['x-goog-request-params'] =
13411344
gax.routingHeader.fromParams(routingParameter);
13421345
this.initialize();
@@ -1379,17 +1382,18 @@ export class ServicesClient {
13791382
options.otherArgs = options.otherArgs || {};
13801383
options.otherArgs.headers = options.otherArgs.headers || {};
13811384
const routingParameter = {};
1382-
if (
1383-
typeof request.parent !== 'undefined' &&
1384-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)').test(
1385-
request.parent!
1386-
)
1387-
) {
1388-
Object.assign(routingParameter, {
1389-
location: request.parent!.match(RegExp('(?<location>[^/]+)'))![0],
1390-
});
1385+
{
1386+
const fieldValue = request.parent;
1387+
if (fieldValue !== undefined && fieldValue !== null) {
1388+
const match = fieldValue
1389+
.toString()
1390+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)'));
1391+
if (match) {
1392+
const parameterValue = match.groups?.['location'] ?? fieldValue;
1393+
Object.assign(routingParameter, {location: parameterValue});
1394+
}
1395+
}
13911396
}
1392-
13931397
options.otherArgs.headers['x-goog-request-params'] =
13941398
gax.routingHeader.fromParams(routingParameter);
13951399
const defaultCallSettings = this._defaults['listServices'];
@@ -1441,17 +1445,18 @@ export class ServicesClient {
14411445
options.otherArgs = options.otherArgs || {};
14421446
options.otherArgs.headers = options.otherArgs.headers || {};
14431447
const routingParameter = {};
1444-
if (
1445-
typeof request.parent !== 'undefined' &&
1446-
RegExp('projects/[^/]+/locations/(?<location>[^/]+)').test(
1447-
request.parent!
1448-
)
1449-
) {
1450-
Object.assign(routingParameter, {
1451-
location: request.parent!.match(RegExp('(?<location>[^/]+)'))![0],
1452-
});
1448+
{
1449+
const fieldValue = request.parent;
1450+
if (fieldValue !== undefined && fieldValue !== null) {
1451+
const match = fieldValue
1452+
.toString()
1453+
.match(RegExp('projects/[^/]+/locations/(?<location>[^/]+)'));
1454+
if (match) {
1455+
const parameterValue = match.groups?.['location'] ?? fieldValue;
1456+
Object.assign(routingParameter, {location: parameterValue});
1457+
}
1458+
}
14531459
}
1454-
14551460
options.otherArgs.headers['x-goog-request-params'] =
14561461
gax.routingHeader.fromParams(routingParameter);
14571462
const defaultCallSettings = this._defaults['listServices'];

0 commit comments

Comments
 (0)