From 71c33ba7abe02880cc0fdb0845a21368e3bee939 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Sun, 15 Mar 2020 22:13:30 -0700 Subject: [PATCH 01/11] update baseline --- .../src/v1beta1/echo_client.ts.baseline | 41 ++++++++++++------- .../src/v1beta1/identity_client.ts.baseline | 41 ++++++++++++------- .../src/v1beta1/messaging_client.ts.baseline | 41 ++++++++++++------- .../src/v1beta1/testing_client.ts.baseline | 41 ++++++++++++------- .../src/v1beta1/echo_client.ts.baseline | 41 ++++++++++++------- .../src/v1beta1/identity_client.ts.baseline | 41 ++++++++++++------- .../src/v1beta1/messaging_client.ts.baseline | 41 ++++++++++++------- .../src/v1beta1/testing_client.ts.baseline | 41 ++++++++++++------- typescript/src/schema/resource-database.ts | 13 +++++- typescript/test/unit/resource-database.ts | 30 +++++++++++++- 10 files changed, 257 insertions(+), 114 deletions(-) diff --git a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline index 120b081d1..d716844e0 100644 --- a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline @@ -160,7 +160,7 @@ export class EchoClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -893,39 +893,52 @@ export class EchoClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdBlurbIdBlurb resource name string. * * @param {string} user_id * @param {string} blurb_id + * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ user_id: userId, blurb_id: blurbId, + blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; + } + + /** + * Parse the blurb from UserIdBlurbIdBlurb resource. + * + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @returns {string} A string representing the blurb. + */ + matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; } /** diff --git a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline index 286023774..7e3dd1759 100644 --- a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline @@ -155,7 +155,7 @@ export class IdentityClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -838,39 +838,52 @@ export class IdentityClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdBlurbIdBlurb resource name string. * * @param {string} user_id * @param {string} blurb_id + * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ user_id: userId, blurb_id: blurbId, + blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; + } + + /** + * Parse the blurb from UserIdBlurbIdBlurb resource. + * + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @returns {string} A string representing the blurb. + */ + matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; } /** diff --git a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline index 4480342b1..0c8649900 100644 --- a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline @@ -159,7 +159,7 @@ export class MessagingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1423,39 +1423,52 @@ export class MessagingClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdBlurbIdBlurb resource name string. * * @param {string} user_id * @param {string} blurb_id + * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ user_id: userId, blurb_id: blurbId, + blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; + } + + /** + * Parse the blurb from UserIdBlurbIdBlurb resource. + * + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @returns {string} A string representing the blurb. + */ + matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; } /** diff --git a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline index 5b12a6e47..6c8a348d2 100644 --- a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline @@ -156,7 +156,7 @@ export class TestingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1095,39 +1095,52 @@ export class TestingClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdBlurbIdBlurb resource name string. * * @param {string} user_id * @param {string} blurb_id + * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ user_id: userId, blurb_id: blurbId, + blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; + } + + /** + * Parse the blurb from UserIdBlurbIdBlurb resource. + * + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @returns {string} A string representing the blurb. + */ + matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; } /** diff --git a/baselines/showcase/src/v1beta1/echo_client.ts.baseline b/baselines/showcase/src/v1beta1/echo_client.ts.baseline index 120b081d1..d716844e0 100644 --- a/baselines/showcase/src/v1beta1/echo_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/echo_client.ts.baseline @@ -160,7 +160,7 @@ export class EchoClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -893,39 +893,52 @@ export class EchoClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdBlurbIdBlurb resource name string. * * @param {string} user_id * @param {string} blurb_id + * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ user_id: userId, blurb_id: blurbId, + blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; + } + + /** + * Parse the blurb from UserIdBlurbIdBlurb resource. + * + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @returns {string} A string representing the blurb. + */ + matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; } /** diff --git a/baselines/showcase/src/v1beta1/identity_client.ts.baseline b/baselines/showcase/src/v1beta1/identity_client.ts.baseline index 286023774..7e3dd1759 100644 --- a/baselines/showcase/src/v1beta1/identity_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/identity_client.ts.baseline @@ -155,7 +155,7 @@ export class IdentityClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -838,39 +838,52 @@ export class IdentityClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdBlurbIdBlurb resource name string. * * @param {string} user_id * @param {string} blurb_id + * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ user_id: userId, blurb_id: blurbId, + blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; + } + + /** + * Parse the blurb from UserIdBlurbIdBlurb resource. + * + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @returns {string} A string representing the blurb. + */ + matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; } /** diff --git a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline index 4480342b1..0c8649900 100644 --- a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline @@ -159,7 +159,7 @@ export class MessagingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1423,39 +1423,52 @@ export class MessagingClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdBlurbIdBlurb resource name string. * * @param {string} user_id * @param {string} blurb_id + * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ user_id: userId, blurb_id: blurbId, + blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; + } + + /** + * Parse the blurb from UserIdBlurbIdBlurb resource. + * + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @returns {string} A string representing the blurb. + */ + matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; } /** diff --git a/baselines/showcase/src/v1beta1/testing_client.ts.baseline b/baselines/showcase/src/v1beta1/testing_client.ts.baseline index 5b12a6e47..6c8a348d2 100644 --- a/baselines/showcase/src/v1beta1/testing_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/testing_client.ts.baseline @@ -156,7 +156,7 @@ export class TestingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1095,39 +1095,52 @@ export class TestingClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdBlurbIdBlurb resource name string. * * @param {string} user_id * @param {string} blurb_id + * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ user_id: userId, blurb_id: blurbId, + blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdBlurbIdBlurb resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; + } + + /** + * Parse the blurb from UserIdBlurbIdBlurb resource. + * + * @param {string} userIdBlurbIdBlurbName + * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @returns {string} A string representing the blurb. + */ + matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { + return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; } /** diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index 97a906a55..3b42f021d 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -90,7 +90,7 @@ export class ResourceDatabase { if (params.length === 0) { continue; } - const name = params.join('_'); + const name = this.getName(params, pattern, resource.type); let resourceDescriptor: ResourceDescriptor = { name, params, @@ -185,6 +185,17 @@ export class ResourceDatabase { return params; } + private getName(params: string[], pattern: string, type: string): string { + const typeName = type.substring(type.lastIndexOf('/') + 1).toCamelCase(); + const patternEleNum = pattern.split('/').length; + // Multi pattern like: `projects/{project}/cmekSettings`, we need to append `cmekSettings` to the name. + // Or it will be duplicate with `project/{project}` + if((params.length * 2) !== patternEleNum){ + params.push(typeName); + } + return params.join('_'); + } + private getResourceDescriptor( name: string, params: string[], diff --git a/typescript/test/unit/resource-database.ts b/typescript/test/unit/resource-database.ts index a817cf07f..e939d181f 100644 --- a/typescript/test/unit/resource-database.ts +++ b/typescript/test/unit/resource-database.ts @@ -25,6 +25,9 @@ describe('src/schema/resource-database.ts', () => { const resourceType = 'examples.googleapis.com/Example'; const resourcePattern = 'locations/{location}/examples/{example}'; const resourcePattern2 = 'project/{project}/examples/{example}'; + const resourceTypeSpecial = 'examples.googleapis.com/Case'; + const resourcePatternSpecial1 = 'location/{location}/case'; + const resourcePatternSpecial2 = 'organization/{organization}/case'; const resourceParameters = ['location', 'example']; const parentResourceName = 'Location'; const parentResourceType = 'locations.googleapis.com/Location'; @@ -80,7 +83,6 @@ describe('src/schema/resource-database.ts', () => { type: resourceType, pattern: [resourcePattern, resourcePattern2], }; - rdb.registerResource(resource, errorLocation); const resourceByType = rdb.getResourceByType(resourceType); assert.deepStrictEqual(resourceByType!.pattern, [ @@ -98,6 +100,32 @@ describe('src/schema/resource-database.ts', () => { assert.strictEqual(warnings.length, 0); }); + it('can register resource with special pattern', () => { + const rdb = new ResourceDatabase(); + const resource1: plugin.google.api.IResourceDescriptor = { + type: parentResourceType, + pattern: [parentResourcePattern], + }; + const resource2: plugin.google.api.IResourceDescriptor = { + type: resourceTypeSpecial, + pattern: [resourcePatternSpecial1, resourcePatternSpecial2], + }; + rdb.registerResource(resource1, errorLocation); + rdb.registerResource(resource2, errorLocation); + const registeredResource = rdb.getResourceByType(parentResourceType); + assert(registeredResource); + assert.strictEqual(registeredResource!.type, parentResourceType); + assert.strictEqual(registeredResource!.name, parentResourceName); + const registeredResource2 = rdb.getResourceByPattern(resourcePatternSpecial1); + assert(registeredResource2); + assert.strictEqual(registeredResource2!.type, resourceTypeSpecial); + assert.strictEqual(registeredResource2!.name, 'location_case'); + const registeredResource3 = rdb.getResourceByPattern(resourcePatternSpecial2); + assert(registeredResource3); + assert.strictEqual(registeredResource3!.type, resourceTypeSpecial); + assert.strictEqual(registeredResource3!.name, 'organization_case'); + }); + it('can get registered resource by type', () => { const rdb = new ResourceDatabase(); const resource: plugin.google.api.IResourceDescriptor = { From c38b946e4cafb951c5c89978a32c7e0febd057f2 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Sun, 15 Mar 2020 22:20:30 -0700 Subject: [PATCH 02/11] lint --- typescript/src/schema/resource-database.ts | 2 +- typescript/test/unit/resource-database.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index 3b42f021d..623e48e7c 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -190,7 +190,7 @@ export class ResourceDatabase { const patternEleNum = pattern.split('/').length; // Multi pattern like: `projects/{project}/cmekSettings`, we need to append `cmekSettings` to the name. // Or it will be duplicate with `project/{project}` - if((params.length * 2) !== patternEleNum){ + if (params.length * 2 !== patternEleNum) { params.push(typeName); } return params.join('_'); diff --git a/typescript/test/unit/resource-database.ts b/typescript/test/unit/resource-database.ts index e939d181f..050cd61c4 100644 --- a/typescript/test/unit/resource-database.ts +++ b/typescript/test/unit/resource-database.ts @@ -116,11 +116,15 @@ describe('src/schema/resource-database.ts', () => { assert(registeredResource); assert.strictEqual(registeredResource!.type, parentResourceType); assert.strictEqual(registeredResource!.name, parentResourceName); - const registeredResource2 = rdb.getResourceByPattern(resourcePatternSpecial1); + const registeredResource2 = rdb.getResourceByPattern( + resourcePatternSpecial1 + ); assert(registeredResource2); assert.strictEqual(registeredResource2!.type, resourceTypeSpecial); assert.strictEqual(registeredResource2!.name, 'location_case'); - const registeredResource3 = rdb.getResourceByPattern(resourcePatternSpecial2); + const registeredResource3 = rdb.getResourceByPattern( + resourcePatternSpecial2 + ); assert(registeredResource3); assert.strictEqual(registeredResource3!.type, resourceTypeSpecial); assert.strictEqual(registeredResource3!.name, 'organization_case'); From 50bfb8f31bad0f897d6ba947046f25c66fb75236 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Mon, 16 Mar 2020 11:36:05 -0700 Subject: [PATCH 03/11] readable name --- .../src/v1beta1/echo_client.ts.baseline | 41 +++++++------------ .../src/v1beta1/identity_client.ts.baseline | 41 +++++++------------ .../src/v1beta1/messaging_client.ts.baseline | 41 +++++++------------ .../src/v1beta1/testing_client.ts.baseline | 41 +++++++------------ .../src/v1beta1/echo_client.ts.baseline | 41 +++++++------------ .../src/v1beta1/identity_client.ts.baseline | 41 +++++++------------ .../src/v1beta1/messaging_client.ts.baseline | 41 +++++++------------ .../src/v1beta1/testing_client.ts.baseline | 41 +++++++------------ typescript/src/schema/resource-database.ts | 4 +- 9 files changed, 115 insertions(+), 217 deletions(-) diff --git a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline index d716844e0..120b081d1 100644 --- a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline @@ -160,7 +160,7 @@ export class EchoClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -893,52 +893,39 @@ export class EchoClient { } /** - * Return a fully-qualified userIdBlurbIdBlurb resource name string. + * Return a fully-qualified userIdBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id - * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ + userIdBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, - blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbIdBlurb resource. + * Parse the user_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; + matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbIdBlurb resource. + * Parse the blurb_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; - } - - /** - * Parse the blurb from UserIdBlurbIdBlurb resource. - * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. - * @returns {string} A string representing the blurb. - */ - matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; + matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; } /** diff --git a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline index 7e3dd1759..286023774 100644 --- a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline @@ -155,7 +155,7 @@ export class IdentityClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -838,52 +838,39 @@ export class IdentityClient { } /** - * Return a fully-qualified userIdBlurbIdBlurb resource name string. + * Return a fully-qualified userIdBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id - * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ + userIdBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, - blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbIdBlurb resource. + * Parse the user_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; + matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbIdBlurb resource. + * Parse the blurb_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; - } - - /** - * Parse the blurb from UserIdBlurbIdBlurb resource. - * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. - * @returns {string} A string representing the blurb. - */ - matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; + matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; } /** diff --git a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline index 0c8649900..4480342b1 100644 --- a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline @@ -159,7 +159,7 @@ export class MessagingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1423,52 +1423,39 @@ export class MessagingClient { } /** - * Return a fully-qualified userIdBlurbIdBlurb resource name string. + * Return a fully-qualified userIdBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id - * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ + userIdBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, - blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbIdBlurb resource. + * Parse the user_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; + matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbIdBlurb resource. + * Parse the blurb_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; - } - - /** - * Parse the blurb from UserIdBlurbIdBlurb resource. - * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. - * @returns {string} A string representing the blurb. - */ - matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; + matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; } /** diff --git a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline index 6c8a348d2..5b12a6e47 100644 --- a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline @@ -156,7 +156,7 @@ export class TestingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1095,52 +1095,39 @@ export class TestingClient { } /** - * Return a fully-qualified userIdBlurbIdBlurb resource name string. + * Return a fully-qualified userIdBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id - * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ + userIdBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, - blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbIdBlurb resource. + * Parse the user_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; + matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbIdBlurb resource. + * Parse the blurb_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; - } - - /** - * Parse the blurb from UserIdBlurbIdBlurb resource. - * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. - * @returns {string} A string representing the blurb. - */ - matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; + matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; } /** diff --git a/baselines/showcase/src/v1beta1/echo_client.ts.baseline b/baselines/showcase/src/v1beta1/echo_client.ts.baseline index d716844e0..120b081d1 100644 --- a/baselines/showcase/src/v1beta1/echo_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/echo_client.ts.baseline @@ -160,7 +160,7 @@ export class EchoClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -893,52 +893,39 @@ export class EchoClient { } /** - * Return a fully-qualified userIdBlurbIdBlurb resource name string. + * Return a fully-qualified userIdBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id - * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ + userIdBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, - blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbIdBlurb resource. + * Parse the user_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; + matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbIdBlurb resource. + * Parse the blurb_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; - } - - /** - * Parse the blurb from UserIdBlurbIdBlurb resource. - * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. - * @returns {string} A string representing the blurb. - */ - matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; + matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; } /** diff --git a/baselines/showcase/src/v1beta1/identity_client.ts.baseline b/baselines/showcase/src/v1beta1/identity_client.ts.baseline index 7e3dd1759..286023774 100644 --- a/baselines/showcase/src/v1beta1/identity_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/identity_client.ts.baseline @@ -155,7 +155,7 @@ export class IdentityClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -838,52 +838,39 @@ export class IdentityClient { } /** - * Return a fully-qualified userIdBlurbIdBlurb resource name string. + * Return a fully-qualified userIdBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id - * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ + userIdBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, - blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbIdBlurb resource. + * Parse the user_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; + matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbIdBlurb resource. + * Parse the blurb_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; - } - - /** - * Parse the blurb from UserIdBlurbIdBlurb resource. - * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. - * @returns {string} A string representing the blurb. - */ - matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; + matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; } /** diff --git a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline index 0c8649900..4480342b1 100644 --- a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline @@ -159,7 +159,7 @@ export class MessagingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1423,52 +1423,39 @@ export class MessagingClient { } /** - * Return a fully-qualified userIdBlurbIdBlurb resource name string. + * Return a fully-qualified userIdBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id - * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ + userIdBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, - blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbIdBlurb resource. + * Parse the user_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; + matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbIdBlurb resource. + * Parse the blurb_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; - } - - /** - * Parse the blurb from UserIdBlurbIdBlurb resource. - * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. - * @returns {string} A string representing the blurb. - */ - matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; + matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; } /** diff --git a/baselines/showcase/src/v1beta1/testing_client.ts.baseline b/baselines/showcase/src/v1beta1/testing_client.ts.baseline index 6c8a348d2..5b12a6e47 100644 --- a/baselines/showcase/src/v1beta1/testing_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/testing_client.ts.baseline @@ -156,7 +156,7 @@ export class TestingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdBlurbPathTemplate: new this._gaxModule.PathTemplate( + userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1095,52 +1095,39 @@ export class TestingClient { } /** - * Return a fully-qualified userIdBlurbIdBlurb resource name string. + * Return a fully-qualified userIdBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id - * @param {string} blurb * @returns {string} Resource name string. */ - userIdBlurbIdBlurbPath(userId:string,blurbId:string,blurb:string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.render({ + userIdBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, - blurb: blurb, }); } /** - * Parse the user_id from UserIdBlurbIdBlurb resource. + * Parse the user_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).user_id; + matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbIdBlurb resource. + * Parse the blurb_id from UserIdBlurbId resource. * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. + * @param {string} userIdBlurbIdName + * A fully-qualified path representing user_id_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb_id; - } - - /** - * Parse the blurb from UserIdBlurbIdBlurb resource. - * - * @param {string} userIdBlurbIdBlurbName - * A fully-qualified path representing user_id_blurb_id_blurb resource. - * @returns {string} A string representing the blurb. - */ - matchBlurbFromUserIdBlurbIdBlurbName(userIdBlurbIdBlurbName: string) { - return this._pathTemplates.userIdBlurbIdBlurbPathTemplate.match(userIdBlurbIdBlurbName).blurb; + matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { + return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; } /** diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index 623e48e7c..e858134d1 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -188,9 +188,11 @@ export class ResourceDatabase { private getName(params: string[], pattern: string, type: string): string { const typeName = type.substring(type.lastIndexOf('/') + 1).toCamelCase(); const patternEleNum = pattern.split('/').length; + const patternName = pattern.substring(pattern.lastIndexOf('/') + 2, pattern.length - 1); // Multi pattern like: `projects/{project}/cmekSettings`, we need to append `cmekSettings` to the name. // Or it will be duplicate with `project/{project}` - if (params.length * 2 !== patternEleNum) { + // While for `user/{user_id}/profile/blurbs/{blurb_id}`, name `userIdBlurbId` is clear and unique. + if (params.length * 2 !== patternEleNum && !params.includes(patternName)) { params.push(typeName); } return params.join('_'); From 9de6f70a646c81aa7e438ad6f4ce2a3538e933b0 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Mon, 16 Mar 2020 12:15:59 -0700 Subject: [PATCH 04/11] resonable name --- .../src/v1beta1/echo_client.ts.baseline | 28 +++---- .../src/v1beta1/identity_client.ts.baseline | 28 +++---- .../src/v1beta1/messaging_client.ts.baseline | 28 +++---- .../src/v1beta1/testing_client.ts.baseline | 28 +++---- .../src/v3/metric_service_client.ts.baseline | 84 +++++++++---------- .../src/v1beta1/echo_client.ts.baseline | 28 +++---- .../src/v1beta1/identity_client.ts.baseline | 28 +++---- .../src/v1beta1/messaging_client.ts.baseline | 28 +++---- .../src/v1beta1/testing_client.ts.baseline | 28 +++---- typescript/src/schema/resource-database.ts | 31 +++++-- typescript/test/unit/resource-database.ts | 35 +++----- 11 files changed, 189 insertions(+), 185 deletions(-) diff --git a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline index 120b081d1..7c9f1cc0b 100644 --- a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline @@ -160,7 +160,7 @@ export class EchoClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -893,39 +893,39 @@ export class EchoClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdProfileBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdProfileBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id; } /** diff --git a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline index 286023774..b3edf3441 100644 --- a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline @@ -155,7 +155,7 @@ export class IdentityClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -838,39 +838,39 @@ export class IdentityClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdProfileBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdProfileBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id; } /** diff --git a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline index 4480342b1..7c21f8e28 100644 --- a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline @@ -159,7 +159,7 @@ export class MessagingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1423,39 +1423,39 @@ export class MessagingClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdProfileBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdProfileBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id; } /** diff --git a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline index 5b12a6e47..c0adac96b 100644 --- a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline @@ -156,7 +156,7 @@ export class TestingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1095,39 +1095,39 @@ export class TestingClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdProfileBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdProfileBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id; } /** diff --git a/baselines/monitoring/src/v3/metric_service_client.ts.baseline b/baselines/monitoring/src/v3/metric_service_client.ts.baseline index 7c4ba58b0..1bd1f4f1f 100644 --- a/baselines/monitoring/src/v3/metric_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/metric_service_client.ts.baseline @@ -150,7 +150,7 @@ export class MetricServiceClient { folderGroupPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/groups/{group}' ), - folderMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( + folderMetricDescriptorsMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/metricDescriptors/{metric_descriptor=**}' ), folderMonitoredResourceDescriptorPathTemplate: new this._gaxModule.PathTemplate( @@ -180,7 +180,7 @@ export class MetricServiceClient { organizationGroupPathTemplate: new this._gaxModule.PathTemplate( 'organizations/{organization}/groups/{group}' ), - organizationMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( + organizationMetricDescriptorsMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( 'organizations/{organization}/metricDescriptors/{metric_descriptor=**}' ), organizationMonitoredResourceDescriptorPathTemplate: new this._gaxModule.PathTemplate( @@ -210,7 +210,7 @@ export class MetricServiceClient { projectGroupPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/groups/{group}' ), - projectMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( + projectMetricDescriptorsMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/metricDescriptors/{metric_descriptor=**}' ), projectMonitoredResourceDescriptorPathTemplate: new this._gaxModule.PathTemplate( @@ -1348,39 +1348,39 @@ export class MetricServiceClient { } /** - * Return a fully-qualified folderMetricDescriptor resource name string. + * Return a fully-qualified folderMetricDescriptorsMetricDescriptor resource name string. * * @param {string} folder * @param {string} metric_descriptor * @returns {string} Resource name string. */ - folderMetricDescriptorPath(folder:string,metricDescriptor:string) { - return this._pathTemplates.folderMetricDescriptorPathTemplate.render({ + folderMetricDescriptorsMetricDescriptorPath(folder:string,metricDescriptor:string) { + return this._pathTemplates.folderMetricDescriptorsMetricDescriptorPathTemplate.render({ folder: folder, metric_descriptor: metricDescriptor, }); } /** - * Parse the folder from FolderMetricDescriptor resource. + * Parse the folder from FolderMetricDescriptorsMetricDescriptor resource. * - * @param {string} folderMetricDescriptorName - * A fully-qualified path representing folder_metric_descriptor resource. + * @param {string} folderMetricDescriptorsMetricDescriptorName + * A fully-qualified path representing folder_metricDescriptors_{metric_descriptor=**} resource. * @returns {string} A string representing the folder. */ - matchFolderFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { - return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).folder; + matchFolderFromFolderMetricDescriptorsMetricDescriptorName(folderMetricDescriptorsMetricDescriptorName: string) { + return this._pathTemplates.folderMetricDescriptorsMetricDescriptorPathTemplate.match(folderMetricDescriptorsMetricDescriptorName).folder; } /** - * Parse the metric_descriptor from FolderMetricDescriptor resource. + * Parse the metric_descriptor from FolderMetricDescriptorsMetricDescriptor resource. * - * @param {string} folderMetricDescriptorName - * A fully-qualified path representing folder_metric_descriptor resource. + * @param {string} folderMetricDescriptorsMetricDescriptorName + * A fully-qualified path representing folder_metricDescriptors_{metric_descriptor=**} resource. * @returns {string} A string representing the metric_descriptor. */ - matchMetricDescriptorFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { - return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).metric_descriptor; + matchMetricDescriptorFromFolderMetricDescriptorsMetricDescriptorName(folderMetricDescriptorsMetricDescriptorName: string) { + return this._pathTemplates.folderMetricDescriptorsMetricDescriptorPathTemplate.match(folderMetricDescriptorsMetricDescriptorName).metric_descriptor; } /** @@ -1734,39 +1734,39 @@ export class MetricServiceClient { } /** - * Return a fully-qualified organizationMetricDescriptor resource name string. + * Return a fully-qualified organizationMetricDescriptorsMetricDescriptor resource name string. * * @param {string} organization * @param {string} metric_descriptor * @returns {string} Resource name string. */ - organizationMetricDescriptorPath(organization:string,metricDescriptor:string) { - return this._pathTemplates.organizationMetricDescriptorPathTemplate.render({ + organizationMetricDescriptorsMetricDescriptorPath(organization:string,metricDescriptor:string) { + return this._pathTemplates.organizationMetricDescriptorsMetricDescriptorPathTemplate.render({ organization: organization, metric_descriptor: metricDescriptor, }); } /** - * Parse the organization from OrganizationMetricDescriptor resource. + * Parse the organization from OrganizationMetricDescriptorsMetricDescriptor resource. * - * @param {string} organizationMetricDescriptorName - * A fully-qualified path representing organization_metric_descriptor resource. + * @param {string} organizationMetricDescriptorsMetricDescriptorName + * A fully-qualified path representing organization_metricDescriptors_{metric_descriptor=**} resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { - return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).organization; + matchOrganizationFromOrganizationMetricDescriptorsMetricDescriptorName(organizationMetricDescriptorsMetricDescriptorName: string) { + return this._pathTemplates.organizationMetricDescriptorsMetricDescriptorPathTemplate.match(organizationMetricDescriptorsMetricDescriptorName).organization; } /** - * Parse the metric_descriptor from OrganizationMetricDescriptor resource. + * Parse the metric_descriptor from OrganizationMetricDescriptorsMetricDescriptor resource. * - * @param {string} organizationMetricDescriptorName - * A fully-qualified path representing organization_metric_descriptor resource. + * @param {string} organizationMetricDescriptorsMetricDescriptorName + * A fully-qualified path representing organization_metricDescriptors_{metric_descriptor=**} resource. * @returns {string} A string representing the metric_descriptor. */ - matchMetricDescriptorFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { - return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).metric_descriptor; + matchMetricDescriptorFromOrganizationMetricDescriptorsMetricDescriptorName(organizationMetricDescriptorsMetricDescriptorName: string) { + return this._pathTemplates.organizationMetricDescriptorsMetricDescriptorPathTemplate.match(organizationMetricDescriptorsMetricDescriptorName).metric_descriptor; } /** @@ -2120,39 +2120,39 @@ export class MetricServiceClient { } /** - * Return a fully-qualified projectMetricDescriptor resource name string. + * Return a fully-qualified projectMetricDescriptorsMetricDescriptor resource name string. * * @param {string} project * @param {string} metric_descriptor * @returns {string} Resource name string. */ - projectMetricDescriptorPath(project:string,metricDescriptor:string) { - return this._pathTemplates.projectMetricDescriptorPathTemplate.render({ + projectMetricDescriptorsMetricDescriptorPath(project:string,metricDescriptor:string) { + return this._pathTemplates.projectMetricDescriptorsMetricDescriptorPathTemplate.render({ project: project, metric_descriptor: metricDescriptor, }); } /** - * Parse the project from ProjectMetricDescriptor resource. + * Parse the project from ProjectMetricDescriptorsMetricDescriptor resource. * - * @param {string} projectMetricDescriptorName - * A fully-qualified path representing project_metric_descriptor resource. + * @param {string} projectMetricDescriptorsMetricDescriptorName + * A fully-qualified path representing project_metricDescriptors_{metric_descriptor=**} resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { - return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).project; + matchProjectFromProjectMetricDescriptorsMetricDescriptorName(projectMetricDescriptorsMetricDescriptorName: string) { + return this._pathTemplates.projectMetricDescriptorsMetricDescriptorPathTemplate.match(projectMetricDescriptorsMetricDescriptorName).project; } /** - * Parse the metric_descriptor from ProjectMetricDescriptor resource. + * Parse the metric_descriptor from ProjectMetricDescriptorsMetricDescriptor resource. * - * @param {string} projectMetricDescriptorName - * A fully-qualified path representing project_metric_descriptor resource. + * @param {string} projectMetricDescriptorsMetricDescriptorName + * A fully-qualified path representing project_metricDescriptors_{metric_descriptor=**} resource. * @returns {string} A string representing the metric_descriptor. */ - matchMetricDescriptorFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { - return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).metric_descriptor; + matchMetricDescriptorFromProjectMetricDescriptorsMetricDescriptorName(projectMetricDescriptorsMetricDescriptorName: string) { + return this._pathTemplates.projectMetricDescriptorsMetricDescriptorPathTemplate.match(projectMetricDescriptorsMetricDescriptorName).metric_descriptor; } /** diff --git a/baselines/showcase/src/v1beta1/echo_client.ts.baseline b/baselines/showcase/src/v1beta1/echo_client.ts.baseline index 120b081d1..7c9f1cc0b 100644 --- a/baselines/showcase/src/v1beta1/echo_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/echo_client.ts.baseline @@ -160,7 +160,7 @@ export class EchoClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -893,39 +893,39 @@ export class EchoClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdProfileBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdProfileBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id; } /** diff --git a/baselines/showcase/src/v1beta1/identity_client.ts.baseline b/baselines/showcase/src/v1beta1/identity_client.ts.baseline index 286023774..b3edf3441 100644 --- a/baselines/showcase/src/v1beta1/identity_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/identity_client.ts.baseline @@ -155,7 +155,7 @@ export class IdentityClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -838,39 +838,39 @@ export class IdentityClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdProfileBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdProfileBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id; } /** diff --git a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline index 4480342b1..7c21f8e28 100644 --- a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline @@ -159,7 +159,7 @@ export class MessagingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1423,39 +1423,39 @@ export class MessagingClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdProfileBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdProfileBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id; } /** diff --git a/baselines/showcase/src/v1beta1/testing_client.ts.baseline b/baselines/showcase/src/v1beta1/testing_client.ts.baseline index 5b12a6e47..c0adac96b 100644 --- a/baselines/showcase/src/v1beta1/testing_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/testing_client.ts.baseline @@ -156,7 +156,7 @@ export class TestingClient { userPathTemplate: new this._gaxModule.PathTemplate( 'users/{user_id}' ), - userIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate( + userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate( 'user/{user_id}/profile/blurbs/{blurb_id}' ), }; @@ -1095,39 +1095,39 @@ export class TestingClient { } /** - * Return a fully-qualified userIdBlurbId resource name string. + * Return a fully-qualified userIdProfileBlurbId resource name string. * * @param {string} user_id * @param {string} blurb_id * @returns {string} Resource name string. */ - userIdBlurbIdPath(userId:string,blurbId:string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.render({ + userIdProfileBlurbIdPath(userId:string,blurbId:string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.render({ user_id: userId, blurb_id: blurbId, }); } /** - * Parse the user_id from UserIdBlurbId resource. + * Parse the user_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the user_id. */ - matchUserIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).user_id; + matchUserIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).user_id; } /** - * Parse the blurb_id from UserIdBlurbId resource. + * Parse the blurb_id from UserIdProfileBlurbId resource. * - * @param {string} userIdBlurbIdName - * A fully-qualified path representing user_id_blurb_id resource. + * @param {string} userIdProfileBlurbIdName + * A fully-qualified path representing user_id_profile_blurb_id resource. * @returns {string} A string representing the blurb_id. */ - matchBlurbIdFromUserIdBlurbIdName(userIdBlurbIdName: string) { - return this._pathTemplates.userIdBlurbIdPathTemplate.match(userIdBlurbIdName).blurb_id; + matchBlurbIdFromUserIdProfileBlurbIdName(userIdProfileBlurbIdName: string) { + return this._pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id; } /** diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index e858134d1..d34798b8d 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -90,7 +90,7 @@ export class ResourceDatabase { if (params.length === 0) { continue; } - const name = this.getName(params, pattern, resource.type); + const name = this.getName(pattern); let resourceDescriptor: ResourceDescriptor = { name, params, @@ -185,17 +185,30 @@ export class ResourceDatabase { return params; } - private getName(params: string[], pattern: string, type: string): string { - const typeName = type.substring(type.lastIndexOf('/') + 1).toCamelCase(); - const patternEleNum = pattern.split('/').length; - const patternName = pattern.substring(pattern.lastIndexOf('/') + 2, pattern.length - 1); + private getName(pattern: string): string { + const elements = pattern.split('/'); + let name = []; + while(elements.length > 0){ + const eleName = elements.shift(); + if(elements.length === 0) { + name.push(eleName); + break; + } + else { + const nextEle = elements[0]; + if(nextEle.match('{[a-zA-Z_]+}')){ + elements.shift(); + name.push(nextEle.substring(1, nextEle.length - 1)); + } + else{ + name.push(eleName); + } + } + } // Multi pattern like: `projects/{project}/cmekSettings`, we need to append `cmekSettings` to the name. // Or it will be duplicate with `project/{project}` // While for `user/{user_id}/profile/blurbs/{blurb_id}`, name `userIdBlurbId` is clear and unique. - if (params.length * 2 !== patternEleNum && !params.includes(patternName)) { - params.push(typeName); - } - return params.join('_'); + return name.join('_'); } private getResourceDescriptor( diff --git a/typescript/test/unit/resource-database.ts b/typescript/test/unit/resource-database.ts index 050cd61c4..37acd379a 100644 --- a/typescript/test/unit/resource-database.ts +++ b/typescript/test/unit/resource-database.ts @@ -25,8 +25,7 @@ describe('src/schema/resource-database.ts', () => { const resourceType = 'examples.googleapis.com/Example'; const resourcePattern = 'locations/{location}/examples/{example}'; const resourcePattern2 = 'project/{project}/examples/{example}'; - const resourceTypeSpecial = 'examples.googleapis.com/Case'; - const resourcePatternSpecial1 = 'location/{location}/case'; + const resourcePatternSpecial1 = 'location/{location}/profile/case/{case_id}'; const resourcePatternSpecial2 = 'organization/{organization}/case'; const resourceParameters = ['location', 'example']; const parentResourceName = 'Location'; @@ -100,34 +99,26 @@ describe('src/schema/resource-database.ts', () => { assert.strictEqual(warnings.length, 0); }); - it('can register resource with special pattern', () => { + it('get correct resource name for special patterns', () => { const rdb = new ResourceDatabase(); - const resource1: plugin.google.api.IResourceDescriptor = { - type: parentResourceType, - pattern: [parentResourcePattern], - }; - const resource2: plugin.google.api.IResourceDescriptor = { - type: resourceTypeSpecial, + const resource: plugin.google.api.IResourceDescriptor = { + type: 'examples.googleapis.com/Case', pattern: [resourcePatternSpecial1, resourcePatternSpecial2], }; - rdb.registerResource(resource1, errorLocation); - rdb.registerResource(resource2, errorLocation); - const registeredResource = rdb.getResourceByType(parentResourceType); + rdb.registerResource(resource, errorLocation); + const registeredResource = rdb.getResourceByType('examples.googleapis.com/Case'); assert(registeredResource); - assert.strictEqual(registeredResource!.type, parentResourceType); - assert.strictEqual(registeredResource!.name, parentResourceName); - const registeredResource2 = rdb.getResourceByPattern( + assert.strictEqual(registeredResource!.type, 'examples.googleapis.com/Case'); + const registeredResourceByPattern = rdb.getResourceByPattern( resourcePatternSpecial1 ); - assert(registeredResource2); - assert.strictEqual(registeredResource2!.type, resourceTypeSpecial); - assert.strictEqual(registeredResource2!.name, 'location_case'); - const registeredResource3 = rdb.getResourceByPattern( + assert(registeredResourceByPattern); + assert.strictEqual(registeredResourceByPattern!.name, 'location_profile_case_id'); + const registeredResourceByPattern2 = rdb.getResourceByPattern( resourcePatternSpecial2 ); - assert(registeredResource3); - assert.strictEqual(registeredResource3!.type, resourceTypeSpecial); - assert.strictEqual(registeredResource3!.name, 'organization_case'); + assert(registeredResourceByPattern2); + assert.strictEqual(registeredResourceByPattern2!.name, 'organization_case'); }); it('can get registered resource by type', () => { From 81aec85ba872e8ff74067b29daf8f66d707e6ab6 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Mon, 16 Mar 2020 12:16:27 -0700 Subject: [PATCH 05/11] lint --- typescript/src/schema/resource-database.ts | 14 ++++++-------- typescript/test/unit/resource-database.ts | 14 +++++++++++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index d34798b8d..1b6d0fc17 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -187,20 +187,18 @@ export class ResourceDatabase { private getName(pattern: string): string { const elements = pattern.split('/'); - let name = []; - while(elements.length > 0){ + const name = []; + while (elements.length > 0) { const eleName = elements.shift(); - if(elements.length === 0) { + if (elements.length === 0) { name.push(eleName); break; - } - else { + } else { const nextEle = elements[0]; - if(nextEle.match('{[a-zA-Z_]+}')){ + if (nextEle.match('{[a-zA-Z_]+}')) { elements.shift(); name.push(nextEle.substring(1, nextEle.length - 1)); - } - else{ + } else { name.push(eleName); } } diff --git a/typescript/test/unit/resource-database.ts b/typescript/test/unit/resource-database.ts index 37acd379a..6bef75caf 100644 --- a/typescript/test/unit/resource-database.ts +++ b/typescript/test/unit/resource-database.ts @@ -106,14 +106,22 @@ describe('src/schema/resource-database.ts', () => { pattern: [resourcePatternSpecial1, resourcePatternSpecial2], }; rdb.registerResource(resource, errorLocation); - const registeredResource = rdb.getResourceByType('examples.googleapis.com/Case'); + const registeredResource = rdb.getResourceByType( + 'examples.googleapis.com/Case' + ); assert(registeredResource); - assert.strictEqual(registeredResource!.type, 'examples.googleapis.com/Case'); + assert.strictEqual( + registeredResource!.type, + 'examples.googleapis.com/Case' + ); const registeredResourceByPattern = rdb.getResourceByPattern( resourcePatternSpecial1 ); assert(registeredResourceByPattern); - assert.strictEqual(registeredResourceByPattern!.name, 'location_profile_case_id'); + assert.strictEqual( + registeredResourceByPattern!.name, + 'location_profile_case_id' + ); const registeredResourceByPattern2 = rdb.getResourceByPattern( resourcePatternSpecial2 ); From dc73b46c75c1ccf1c066fc17d8b4ab1084700231 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Mon, 16 Mar 2020 12:22:21 -0700 Subject: [PATCH 06/11] comments --- typescript/src/schema/resource-database.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index 1b6d0fc17..537143186 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -188,6 +188,11 @@ export class ResourceDatabase { private getName(pattern: string): string { const elements = pattern.split('/'); const name = []; + // Multi pattern like: `projects/{project}/cmekSettings`, we need to append `cmekSettings` to the name. + // Or it will be duplicate with `project/{project}` + // Iterate the elements, if it comes in pairs: user/{userId}, we take `userId` as part of the name. + // if it comes as `profile` with no following `/{profile_id}`, we take `profile` as part of the name. + // So for pattern: `user/{user_id}/profile/blurbs/{blurb_id}`, name will be `userId_profile_blurbId` while (elements.length > 0) { const eleName = elements.shift(); if (elements.length === 0) { @@ -203,9 +208,6 @@ export class ResourceDatabase { } } } - // Multi pattern like: `projects/{project}/cmekSettings`, we need to append `cmekSettings` to the name. - // Or it will be duplicate with `project/{project}` - // While for `user/{user_id}/profile/blurbs/{blurb_id}`, name `userIdBlurbId` is clear and unique. return name.join('_'); } From 42e081cef32fcbd0fde9b6a524ff3f7caa9d38ee Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Mon, 16 Mar 2020 12:59:00 -0700 Subject: [PATCH 07/11] feedback --- .../src/v3/metric_service_client.ts.baseline | 84 +++++++++---------- typescript/src/schema/resource-database.ts | 2 +- typescript/test/unit/resource-database.ts | 2 +- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/baselines/monitoring/src/v3/metric_service_client.ts.baseline b/baselines/monitoring/src/v3/metric_service_client.ts.baseline index 1bd1f4f1f..a5dd2679d 100644 --- a/baselines/monitoring/src/v3/metric_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/metric_service_client.ts.baseline @@ -150,7 +150,7 @@ export class MetricServiceClient { folderGroupPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/groups/{group}' ), - folderMetricDescriptorsMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( + folderMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( 'folders/{folder}/metricDescriptors/{metric_descriptor=**}' ), folderMonitoredResourceDescriptorPathTemplate: new this._gaxModule.PathTemplate( @@ -180,7 +180,7 @@ export class MetricServiceClient { organizationGroupPathTemplate: new this._gaxModule.PathTemplate( 'organizations/{organization}/groups/{group}' ), - organizationMetricDescriptorsMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( + organizationMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( 'organizations/{organization}/metricDescriptors/{metric_descriptor=**}' ), organizationMonitoredResourceDescriptorPathTemplate: new this._gaxModule.PathTemplate( @@ -210,7 +210,7 @@ export class MetricServiceClient { projectGroupPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/groups/{group}' ), - projectMetricDescriptorsMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( + projectMetricDescriptorPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/metricDescriptors/{metric_descriptor=**}' ), projectMonitoredResourceDescriptorPathTemplate: new this._gaxModule.PathTemplate( @@ -1348,39 +1348,39 @@ export class MetricServiceClient { } /** - * Return a fully-qualified folderMetricDescriptorsMetricDescriptor resource name string. + * Return a fully-qualified folderMetricDescriptor resource name string. * * @param {string} folder * @param {string} metric_descriptor * @returns {string} Resource name string. */ - folderMetricDescriptorsMetricDescriptorPath(folder:string,metricDescriptor:string) { - return this._pathTemplates.folderMetricDescriptorsMetricDescriptorPathTemplate.render({ + folderMetricDescriptorPath(folder:string,metricDescriptor:string) { + return this._pathTemplates.folderMetricDescriptorPathTemplate.render({ folder: folder, metric_descriptor: metricDescriptor, }); } /** - * Parse the folder from FolderMetricDescriptorsMetricDescriptor resource. + * Parse the folder from FolderMetricDescriptor resource. * - * @param {string} folderMetricDescriptorsMetricDescriptorName - * A fully-qualified path representing folder_metricDescriptors_{metric_descriptor=**} resource. + * @param {string} folderMetricDescriptorName + * A fully-qualified path representing folder_metric_descriptor=** resource. * @returns {string} A string representing the folder. */ - matchFolderFromFolderMetricDescriptorsMetricDescriptorName(folderMetricDescriptorsMetricDescriptorName: string) { - return this._pathTemplates.folderMetricDescriptorsMetricDescriptorPathTemplate.match(folderMetricDescriptorsMetricDescriptorName).folder; + matchFolderFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { + return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).folder; } /** - * Parse the metric_descriptor from FolderMetricDescriptorsMetricDescriptor resource. + * Parse the metric_descriptor from FolderMetricDescriptor resource. * - * @param {string} folderMetricDescriptorsMetricDescriptorName - * A fully-qualified path representing folder_metricDescriptors_{metric_descriptor=**} resource. + * @param {string} folderMetricDescriptorName + * A fully-qualified path representing folder_metric_descriptor=** resource. * @returns {string} A string representing the metric_descriptor. */ - matchMetricDescriptorFromFolderMetricDescriptorsMetricDescriptorName(folderMetricDescriptorsMetricDescriptorName: string) { - return this._pathTemplates.folderMetricDescriptorsMetricDescriptorPathTemplate.match(folderMetricDescriptorsMetricDescriptorName).metric_descriptor; + matchMetricDescriptorFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { + return this._pathTemplates.folderMetricDescriptorPathTemplate.match(folderMetricDescriptorName).metric_descriptor; } /** @@ -1734,39 +1734,39 @@ export class MetricServiceClient { } /** - * Return a fully-qualified organizationMetricDescriptorsMetricDescriptor resource name string. + * Return a fully-qualified organizationMetricDescriptor resource name string. * * @param {string} organization * @param {string} metric_descriptor * @returns {string} Resource name string. */ - organizationMetricDescriptorsMetricDescriptorPath(organization:string,metricDescriptor:string) { - return this._pathTemplates.organizationMetricDescriptorsMetricDescriptorPathTemplate.render({ + organizationMetricDescriptorPath(organization:string,metricDescriptor:string) { + return this._pathTemplates.organizationMetricDescriptorPathTemplate.render({ organization: organization, metric_descriptor: metricDescriptor, }); } /** - * Parse the organization from OrganizationMetricDescriptorsMetricDescriptor resource. + * Parse the organization from OrganizationMetricDescriptor resource. * - * @param {string} organizationMetricDescriptorsMetricDescriptorName - * A fully-qualified path representing organization_metricDescriptors_{metric_descriptor=**} resource. + * @param {string} organizationMetricDescriptorName + * A fully-qualified path representing organization_metric_descriptor=** resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationMetricDescriptorsMetricDescriptorName(organizationMetricDescriptorsMetricDescriptorName: string) { - return this._pathTemplates.organizationMetricDescriptorsMetricDescriptorPathTemplate.match(organizationMetricDescriptorsMetricDescriptorName).organization; + matchOrganizationFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { + return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).organization; } /** - * Parse the metric_descriptor from OrganizationMetricDescriptorsMetricDescriptor resource. + * Parse the metric_descriptor from OrganizationMetricDescriptor resource. * - * @param {string} organizationMetricDescriptorsMetricDescriptorName - * A fully-qualified path representing organization_metricDescriptors_{metric_descriptor=**} resource. + * @param {string} organizationMetricDescriptorName + * A fully-qualified path representing organization_metric_descriptor=** resource. * @returns {string} A string representing the metric_descriptor. */ - matchMetricDescriptorFromOrganizationMetricDescriptorsMetricDescriptorName(organizationMetricDescriptorsMetricDescriptorName: string) { - return this._pathTemplates.organizationMetricDescriptorsMetricDescriptorPathTemplate.match(organizationMetricDescriptorsMetricDescriptorName).metric_descriptor; + matchMetricDescriptorFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { + return this._pathTemplates.organizationMetricDescriptorPathTemplate.match(organizationMetricDescriptorName).metric_descriptor; } /** @@ -2120,39 +2120,39 @@ export class MetricServiceClient { } /** - * Return a fully-qualified projectMetricDescriptorsMetricDescriptor resource name string. + * Return a fully-qualified projectMetricDescriptor resource name string. * * @param {string} project * @param {string} metric_descriptor * @returns {string} Resource name string. */ - projectMetricDescriptorsMetricDescriptorPath(project:string,metricDescriptor:string) { - return this._pathTemplates.projectMetricDescriptorsMetricDescriptorPathTemplate.render({ + projectMetricDescriptorPath(project:string,metricDescriptor:string) { + return this._pathTemplates.projectMetricDescriptorPathTemplate.render({ project: project, metric_descriptor: metricDescriptor, }); } /** - * Parse the project from ProjectMetricDescriptorsMetricDescriptor resource. + * Parse the project from ProjectMetricDescriptor resource. * - * @param {string} projectMetricDescriptorsMetricDescriptorName - * A fully-qualified path representing project_metricDescriptors_{metric_descriptor=**} resource. + * @param {string} projectMetricDescriptorName + * A fully-qualified path representing project_metric_descriptor=** resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectMetricDescriptorsMetricDescriptorName(projectMetricDescriptorsMetricDescriptorName: string) { - return this._pathTemplates.projectMetricDescriptorsMetricDescriptorPathTemplate.match(projectMetricDescriptorsMetricDescriptorName).project; + matchProjectFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { + return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).project; } /** - * Parse the metric_descriptor from ProjectMetricDescriptorsMetricDescriptor resource. + * Parse the metric_descriptor from ProjectMetricDescriptor resource. * - * @param {string} projectMetricDescriptorsMetricDescriptorName - * A fully-qualified path representing project_metricDescriptors_{metric_descriptor=**} resource. + * @param {string} projectMetricDescriptorName + * A fully-qualified path representing project_metric_descriptor=** resource. * @returns {string} A string representing the metric_descriptor. */ - matchMetricDescriptorFromProjectMetricDescriptorsMetricDescriptorName(projectMetricDescriptorsMetricDescriptorName: string) { - return this._pathTemplates.projectMetricDescriptorsMetricDescriptorPathTemplate.match(projectMetricDescriptorsMetricDescriptorName).metric_descriptor; + matchMetricDescriptorFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { + return this._pathTemplates.projectMetricDescriptorPathTemplate.match(projectMetricDescriptorName).metric_descriptor; } /** diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index 537143186..1e64b8090 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -200,7 +200,7 @@ export class ResourceDatabase { break; } else { const nextEle = elements[0]; - if (nextEle.match('{[a-zA-Z_]+}')) { + if (nextEle.match(/{[a-zA-Z_]+(?:=.*?)?}/g)) { elements.shift(); name.push(nextEle.substring(1, nextEle.length - 1)); } else { diff --git a/typescript/test/unit/resource-database.ts b/typescript/test/unit/resource-database.ts index 6bef75caf..10e92addf 100644 --- a/typescript/test/unit/resource-database.ts +++ b/typescript/test/unit/resource-database.ts @@ -26,7 +26,7 @@ describe('src/schema/resource-database.ts', () => { const resourcePattern = 'locations/{location}/examples/{example}'; const resourcePattern2 = 'project/{project}/examples/{example}'; const resourcePatternSpecial1 = 'location/{location}/profile/case/{case_id}'; - const resourcePatternSpecial2 = 'organization/{organization}/case'; + const resourcePatternSpecial2 = 'organization/{organization=**}/case'; const resourceParameters = ['location', 'example']; const parentResourceName = 'Location'; const parentResourceType = 'locations.googleapis.com/Location'; From 9b1696b06063183d51333dbbd1df7675cc951c6d Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Mon, 16 Mar 2020 13:26:44 -0700 Subject: [PATCH 08/11] special handling =** --- .../src/v3/metric_service_client.ts.baseline | 12 ++++++------ typescript/src/schema/resource-database.ts | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/baselines/monitoring/src/v3/metric_service_client.ts.baseline b/baselines/monitoring/src/v3/metric_service_client.ts.baseline index a5dd2679d..7c4ba58b0 100644 --- a/baselines/monitoring/src/v3/metric_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/metric_service_client.ts.baseline @@ -1365,7 +1365,7 @@ export class MetricServiceClient { * Parse the folder from FolderMetricDescriptor resource. * * @param {string} folderMetricDescriptorName - * A fully-qualified path representing folder_metric_descriptor=** resource. + * A fully-qualified path representing folder_metric_descriptor resource. * @returns {string} A string representing the folder. */ matchFolderFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { @@ -1376,7 +1376,7 @@ export class MetricServiceClient { * Parse the metric_descriptor from FolderMetricDescriptor resource. * * @param {string} folderMetricDescriptorName - * A fully-qualified path representing folder_metric_descriptor=** resource. + * A fully-qualified path representing folder_metric_descriptor resource. * @returns {string} A string representing the metric_descriptor. */ matchMetricDescriptorFromFolderMetricDescriptorName(folderMetricDescriptorName: string) { @@ -1751,7 +1751,7 @@ export class MetricServiceClient { * Parse the organization from OrganizationMetricDescriptor resource. * * @param {string} organizationMetricDescriptorName - * A fully-qualified path representing organization_metric_descriptor=** resource. + * A fully-qualified path representing organization_metric_descriptor resource. * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { @@ -1762,7 +1762,7 @@ export class MetricServiceClient { * Parse the metric_descriptor from OrganizationMetricDescriptor resource. * * @param {string} organizationMetricDescriptorName - * A fully-qualified path representing organization_metric_descriptor=** resource. + * A fully-qualified path representing organization_metric_descriptor resource. * @returns {string} A string representing the metric_descriptor. */ matchMetricDescriptorFromOrganizationMetricDescriptorName(organizationMetricDescriptorName: string) { @@ -2137,7 +2137,7 @@ export class MetricServiceClient { * Parse the project from ProjectMetricDescriptor resource. * * @param {string} projectMetricDescriptorName - * A fully-qualified path representing project_metric_descriptor=** resource. + * A fully-qualified path representing project_metric_descriptor resource. * @returns {string} A string representing the project. */ matchProjectFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { @@ -2148,7 +2148,7 @@ export class MetricServiceClient { * Parse the metric_descriptor from ProjectMetricDescriptor resource. * * @param {string} projectMetricDescriptorName - * A fully-qualified path representing project_metric_descriptor=** resource. + * A fully-qualified path representing project_metric_descriptor resource. * @returns {string} A string representing the metric_descriptor. */ matchMetricDescriptorFromProjectMetricDescriptorName(projectMetricDescriptorName: string) { diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index 1e64b8090..3be57607a 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -202,7 +202,12 @@ export class ResourceDatabase { const nextEle = elements[0]; if (nextEle.match(/{[a-zA-Z_]+(?:=.*?)?}/g)) { elements.shift(); - name.push(nextEle.substring(1, nextEle.length - 1)); + name.push( + nextEle.substring( + 1, + nextEle.includes('=') ? nextEle.indexOf('=') : nextEle.length - 1 + ) + ); } else { name.push(eleName); } From 00f936c7d774e470f04bb7d1de44e8ef79d1b6c7 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Mon, 16 Mar 2020 13:28:50 -0700 Subject: [PATCH 09/11] move function to helper --- typescript/src/schema/resource-database.ts | 34 ++-------------------- typescript/src/util.ts | 31 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index 3be57607a..5d145fff4 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -13,6 +13,7 @@ // limitations under the License. import * as plugin from '../../../pbjs-genfiles/plugin'; +import {getResourceNameByPattern} from '../util'; export interface ResourceDescriptor extends plugin.google.api.IResourceDescriptor { @@ -90,7 +91,7 @@ export class ResourceDatabase { if (params.length === 0) { continue; } - const name = this.getName(pattern); + const name = getResourceNameByPattern(pattern); let resourceDescriptor: ResourceDescriptor = { name, params, @@ -185,37 +186,6 @@ export class ResourceDatabase { return params; } - private getName(pattern: string): string { - const elements = pattern.split('/'); - const name = []; - // Multi pattern like: `projects/{project}/cmekSettings`, we need to append `cmekSettings` to the name. - // Or it will be duplicate with `project/{project}` - // Iterate the elements, if it comes in pairs: user/{userId}, we take `userId` as part of the name. - // if it comes as `profile` with no following `/{profile_id}`, we take `profile` as part of the name. - // So for pattern: `user/{user_id}/profile/blurbs/{blurb_id}`, name will be `userId_profile_blurbId` - while (elements.length > 0) { - const eleName = elements.shift(); - if (elements.length === 0) { - name.push(eleName); - break; - } else { - const nextEle = elements[0]; - if (nextEle.match(/{[a-zA-Z_]+(?:=.*?)?}/g)) { - elements.shift(); - name.push( - nextEle.substring( - 1, - nextEle.includes('=') ? nextEle.indexOf('=') : nextEle.length - 1 - ) - ); - } else { - name.push(eleName); - } - } - } - return name.join('_'); - } - private getResourceDescriptor( name: string, params: string[], diff --git a/typescript/src/util.ts b/typescript/src/util.ts index 230b79a1a..ded9079eb 100644 --- a/typescript/src/util.ts +++ b/typescript/src/util.ts @@ -141,3 +141,34 @@ Array.prototype.toSnakeCaseString = function( ): string { return this.map(part => part.toSnakeCase()).join(joiner); }; + +export function getResourceNameByPattern(pattern: string): string { + const elements = pattern.split('/'); + const name = []; + // Multi pattern like: `projects/{project}/cmekSettings`, we need to append `cmekSettings` to the name. + // Or it will be duplicate with `project/{project}` + // Iterate the elements, if it comes in pairs: user/{userId}, we take `userId` as part of the name. + // if it comes as `profile` with no following `/{profile_id}`, we take `profile` as part of the name. + // So for pattern: `user/{user_id}/profile/blurbs/{blurb_id}`, name will be `userId_profile_blurbId` + while (elements.length > 0) { + const eleName = elements.shift(); + if (elements.length === 0) { + name.push(eleName); + break; + } else { + const nextEle = elements[0]; + if (nextEle.match(/{[a-zA-Z_]+(?:=.*?)?}/g)) { + elements.shift(); + name.push( + nextEle.substring( + 1, + nextEle.includes('=') ? nextEle.indexOf('=') : nextEle.length - 1 + ) + ); + } else { + name.push(eleName); + } + } + } + return name.join('_'); +} From 2dd33c1da80f7c4ca5249043552b078d0d9d0a05 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Mon, 16 Mar 2020 13:31:29 -0700 Subject: [PATCH 10/11] lint --- typescript/src/schema/resource-database.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/src/schema/resource-database.ts b/typescript/src/schema/resource-database.ts index 5d145fff4..08f7943e8 100644 --- a/typescript/src/schema/resource-database.ts +++ b/typescript/src/schema/resource-database.ts @@ -13,7 +13,7 @@ // limitations under the License. import * as plugin from '../../../pbjs-genfiles/plugin'; -import {getResourceNameByPattern} from '../util'; +import { getResourceNameByPattern } from '../util'; export interface ResourceDescriptor extends plugin.google.api.IResourceDescriptor { From 47847a8feca6ab9490aeff91aca14a5319399016 Mon Sep 17 00:00:00 2001 From: xiaozhenliugg Date: Mon, 16 Mar 2020 20:55:04 -0700 Subject: [PATCH 11/11] one more special use case --- typescript/src/util.ts | 6 +++++- typescript/test/unit/resource-database.ts | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/typescript/src/util.ts b/typescript/src/util.ts index ded9079eb..ec547afb4 100644 --- a/typescript/src/util.ts +++ b/typescript/src/util.ts @@ -166,7 +166,11 @@ export function getResourceNameByPattern(pattern: string): string { ) ); } else { - name.push(eleName); + if (eleName!.match(/{[a-zA-Z_]+(?:=.*?)?}/g)) { + continue; + } else { + name.push(eleName); + } } } } diff --git a/typescript/test/unit/resource-database.ts b/typescript/test/unit/resource-database.ts index 10e92addf..07ee70a62 100644 --- a/typescript/test/unit/resource-database.ts +++ b/typescript/test/unit/resource-database.ts @@ -27,6 +27,7 @@ describe('src/schema/resource-database.ts', () => { const resourcePattern2 = 'project/{project}/examples/{example}'; const resourcePatternSpecial1 = 'location/{location}/profile/case/{case_id}'; const resourcePatternSpecial2 = 'organization/{organization=**}/case'; + const resourcePatternSpecial3 = '{organization=**}/tasks/{task}/result'; const resourceParameters = ['location', 'example']; const parentResourceName = 'Location'; const parentResourceType = 'locations.googleapis.com/Location'; @@ -103,7 +104,11 @@ describe('src/schema/resource-database.ts', () => { const rdb = new ResourceDatabase(); const resource: plugin.google.api.IResourceDescriptor = { type: 'examples.googleapis.com/Case', - pattern: [resourcePatternSpecial1, resourcePatternSpecial2], + pattern: [ + resourcePatternSpecial1, + resourcePatternSpecial2, + resourcePatternSpecial3, + ], }; rdb.registerResource(resource, errorLocation); const registeredResource = rdb.getResourceByType( @@ -127,6 +132,12 @@ describe('src/schema/resource-database.ts', () => { ); assert(registeredResourceByPattern2); assert.strictEqual(registeredResourceByPattern2!.name, 'organization_case'); + + const registeredResourceByPattern3 = rdb.getResourceByPattern( + resourcePatternSpecial3 + ); + assert(registeredResourceByPattern3); + assert.strictEqual(registeredResourceByPattern3!.name, 'task_result'); }); it('can get registered resource by type', () => {