Skip to content

Commit

Permalink
feat: support non-slash resource for Ads (#461)
Browse files Browse the repository at this point in the history
* unit test case for non-slash resource

* logic for non-slash resource

* add one more test

* clean up

* feedback

* test

* fix

* update showcase proto

* disable optional fields

* update baseline

* depend on gax develop branch

* update baseline

* use master branch

* update baseline

* update gax dependency

Co-authored-by: Alexander Fenster <fenster@google.com>
  • Loading branch information
xiaozhenliu-gg5 and alexander-fenster committed May 21, 2020
1 parent a37f4f4 commit 68982db
Show file tree
Hide file tree
Showing 40 changed files with 1,792 additions and 72 deletions.
2 changes: 1 addition & 1 deletion baselines/asset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^2.3.1"
"google-gax": "^2.4.0"
},
"devDependencies": {
"@types/mocha": "^7.0.2",
Expand Down
2 changes: 1 addition & 1 deletion baselines/bigquery-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^2.3.1"
"google-gax": "^2.4.0"
},
"devDependencies": {
"@types/mocha": "^7.0.2",
Expand Down
2 changes: 1 addition & 1 deletion baselines/disable-packing-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^2.3.1"
"google-gax": "^2.4.0"
},
"devDependencies": {
"@types/mocha": "^7.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ service Identity {
body: "*"
};
option (google.api.method_signature) = "user.display_name,user.email";
option (google.api.method_signature) = "user.display_name,user.email,user.age,user.nickname,user.enable_notifications,user.height_feet";
}

// Retrieves the User with the given uri.
Expand Down Expand Up @@ -100,6 +101,25 @@ message User {
google.protobuf.Timestamp update_time = 5 [
(google.api.field_behavior) = OUTPUT_ONLY
];

// Typescript generator doe not support proto3 optional fields
// The age of the use in years.
// optional int32 age = 6;

// The height of the user in feet.
// optional double height_feet = 7;

// The nickname of the user.
//
// (-- aip.dev/not-precedent: An empty string is a valid nickname.
// Ordinarily, proto3_optional should not be used on a `string` field. --)
// optional string nickname = 8;

// Enables the receiving of notifications. The default is true if unset.
//
// (-- aip.dev/not-precedent: The default for the feature is true.
// Ordinarily, the default for a `bool` field should be false. --)
// optional bool enable_notifications = 9;
}

// The request message for the google.showcase.v1beta1.Identity\CreateUser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ message Blurb {
option (google.api.resource) = {
type: "showcase.googleapis.com/Blurb"
pattern: "rooms/{room_id}/blurbs/{blurb_id}"
pattern: "rooms/{room_id}/blurbs/legacy/{legacy_room_id}.{blurb_id}"
pattern: "user/{user_id}/profile/blurbs/{blurb_id}"
pattern: "user/{user_id}/profile/blurbs/legacy/{legacy_user_id}~{blurb_id}"

};

// The resource name of the chat room.
Expand Down Expand Up @@ -317,6 +320,18 @@ message Blurb {
google.protobuf.Timestamp update_time = 6 [
(google.api.field_behavior) = OUTPUT_ONLY
];

// (-- aip.dev/not-precedent: This is designed for testing non-slash
// resource patterns. Ordinarily, non-slash separators are discouraged. --)
oneof legacy_id {
// The legacy id of the room. This field is used to signal
// the use of the compound resource pattern `rooms/{room_id}/blurbs/{legacy_room_id}.{blurb_id}`
string legacy_room_id = 7;

// The legacy id of the user. This field is used to signal
// the use of the compound resource pattern `rooms/{room_id}/blurbs/{legacy_user_id}~{blurb_id}`
string legacy_user_id = 8;
}
}

// The request message for the google.showcase.v1beta1.Messaging\CreateBlurb
Expand Down
104 changes: 104 additions & 0 deletions baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ export class EchoClient {
roomIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate(
'rooms/{room_id}/blurbs/{blurb_id}'
),
roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate(
'rooms/{room_id}/blurbs/legacy/{legacy_room_id}.{blurb_id}'
),
sessionPathTemplate: new this._gaxModule.PathTemplate(
'sessions/{session}'
),
Expand All @@ -165,6 +168,9 @@ export class EchoClient {
userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate(
'user/{user_id}/profile/blurbs/{blurb_id}'
),
userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate(
'user/{user_id}/profile/blurbs/legacy/{legacy_user_id}~{blurb_id}'
),
};

// Some of the methods on this service return "paged" results,
Expand Down Expand Up @@ -893,6 +899,55 @@ export class EchoClient {
return this.pathTemplates.roomIdBlurbIdPathTemplate.match(roomIdBlurbIdName).blurb_id;
}

/**
* Return a fully-qualified roomIdBlurbsLegacyRoomIdBlurbId resource name string.
*
* @param {string} room_id
* @param {string} legacy_room_id
* @param {string} blurb_id
* @returns {string} Resource name string.
*/
roomIdBlurbsLegacyRoomIdBlurbIdPath(roomId:string,legacyRoomId:string,blurbId:string) {
return this.pathTemplates.roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate.render({
room_id: roomId,
legacy_room_id: legacyRoomId,
blurb_id: blurbId,
});
}

/**
* Parse the room_id from RoomIdBlurbsLegacyRoomIdBlurbId resource.
*
* @param {string} roomIdBlurbsLegacyRoomIdBlurbIdName
* A fully-qualified path representing room_id_blurbs_legacy_room_id_blurb_id resource.
* @returns {string} A string representing the room_id.
*/
matchRoomIdFromRoomIdBlurbsLegacyRoomIdBlurbIdName(roomIdBlurbsLegacyRoomIdBlurbIdName: string) {
return this.pathTemplates.roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate.match(roomIdBlurbsLegacyRoomIdBlurbIdName).room_id;
}

/**
* Parse the legacy_room_id from RoomIdBlurbsLegacyRoomIdBlurbId resource.
*
* @param {string} roomIdBlurbsLegacyRoomIdBlurbIdName
* A fully-qualified path representing room_id_blurbs_legacy_room_id_blurb_id resource.
* @returns {string} A string representing the legacy_room_id.
*/
matchLegacyRoomIdFromRoomIdBlurbsLegacyRoomIdBlurbIdName(roomIdBlurbsLegacyRoomIdBlurbIdName: string) {
return this.pathTemplates.roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate.match(roomIdBlurbsLegacyRoomIdBlurbIdName).legacy_room_id;
}

/**
* Parse the blurb_id from RoomIdBlurbsLegacyRoomIdBlurbId resource.
*
* @param {string} roomIdBlurbsLegacyRoomIdBlurbIdName
* A fully-qualified path representing room_id_blurbs_legacy_room_id_blurb_id resource.
* @returns {string} A string representing the blurb_id.
*/
matchBlurbIdFromRoomIdBlurbsLegacyRoomIdBlurbIdName(roomIdBlurbsLegacyRoomIdBlurbIdName: string) {
return this.pathTemplates.roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate.match(roomIdBlurbsLegacyRoomIdBlurbIdName).blurb_id;
}

/**
* Return a fully-qualified session resource name string.
*
Expand Down Expand Up @@ -1011,6 +1066,55 @@ export class EchoClient {
return this.pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id;
}

/**
* Return a fully-qualified userIdProfileBlurbsLegacyUserIdBlurbId resource name string.
*
* @param {string} user_id
* @param {string} legacy_user_id
* @param {string} blurb_id
* @returns {string} Resource name string.
*/
userIdProfileBlurbsLegacyUserIdBlurbIdPath(userId:string,legacyUserId:string,blurbId:string) {
return this.pathTemplates.userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate.render({
user_id: userId,
legacy_user_id: legacyUserId,
blurb_id: blurbId,
});
}

/**
* Parse the user_id from UserIdProfileBlurbsLegacyUserIdBlurbId resource.
*
* @param {string} userIdProfileBlurbsLegacyUserIdBlurbIdName
* A fully-qualified path representing user_id_profile_blurbs_legacy_user_id_blurb_id resource.
* @returns {string} A string representing the user_id.
*/
matchUserIdFromUserIdProfileBlurbsLegacyUserIdBlurbIdName(userIdProfileBlurbsLegacyUserIdBlurbIdName: string) {
return this.pathTemplates.userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate.match(userIdProfileBlurbsLegacyUserIdBlurbIdName).user_id;
}

/**
* Parse the legacy_user_id from UserIdProfileBlurbsLegacyUserIdBlurbId resource.
*
* @param {string} userIdProfileBlurbsLegacyUserIdBlurbIdName
* A fully-qualified path representing user_id_profile_blurbs_legacy_user_id_blurb_id resource.
* @returns {string} A string representing the legacy_user_id.
*/
matchLegacyUserIdFromUserIdProfileBlurbsLegacyUserIdBlurbIdName(userIdProfileBlurbsLegacyUserIdBlurbIdName: string) {
return this.pathTemplates.userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate.match(userIdProfileBlurbsLegacyUserIdBlurbIdName).legacy_user_id;
}

/**
* Parse the blurb_id from UserIdProfileBlurbsLegacyUserIdBlurbId resource.
*
* @param {string} userIdProfileBlurbsLegacyUserIdBlurbIdName
* A fully-qualified path representing user_id_profile_blurbs_legacy_user_id_blurb_id resource.
* @returns {string} A string representing the blurb_id.
*/
matchBlurbIdFromUserIdProfileBlurbsLegacyUserIdBlurbIdName(userIdProfileBlurbsLegacyUserIdBlurbIdName: string) {
return this.pathTemplates.userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate.match(userIdProfileBlurbsLegacyUserIdBlurbIdName).blurb_id;
}

/**
* Terminate the GRPC channel and close the client.
*
Expand Down
104 changes: 104 additions & 0 deletions baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ export class IdentityClient {
roomIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate(
'rooms/{room_id}/blurbs/{blurb_id}'
),
roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate(
'rooms/{room_id}/blurbs/legacy/{legacy_room_id}.{blurb_id}'
),
sessionPathTemplate: new this._gaxModule.PathTemplate(
'sessions/{session}'
),
Expand All @@ -160,6 +163,9 @@ export class IdentityClient {
userIdProfileBlurbIdPathTemplate: new this._gaxModule.PathTemplate(
'user/{user_id}/profile/blurbs/{blurb_id}'
),
userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate: new this._gaxModule.PathTemplate(
'user/{user_id}/profile/blurbs/legacy/{legacy_user_id}~{blurb_id}'
),
};

// Some of the methods on this service return "paged" results,
Expand Down Expand Up @@ -820,6 +826,55 @@ export class IdentityClient {
return this.pathTemplates.roomIdBlurbIdPathTemplate.match(roomIdBlurbIdName).blurb_id;
}

/**
* Return a fully-qualified roomIdBlurbsLegacyRoomIdBlurbId resource name string.
*
* @param {string} room_id
* @param {string} legacy_room_id
* @param {string} blurb_id
* @returns {string} Resource name string.
*/
roomIdBlurbsLegacyRoomIdBlurbIdPath(roomId:string,legacyRoomId:string,blurbId:string) {
return this.pathTemplates.roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate.render({
room_id: roomId,
legacy_room_id: legacyRoomId,
blurb_id: blurbId,
});
}

/**
* Parse the room_id from RoomIdBlurbsLegacyRoomIdBlurbId resource.
*
* @param {string} roomIdBlurbsLegacyRoomIdBlurbIdName
* A fully-qualified path representing room_id_blurbs_legacy_room_id_blurb_id resource.
* @returns {string} A string representing the room_id.
*/
matchRoomIdFromRoomIdBlurbsLegacyRoomIdBlurbIdName(roomIdBlurbsLegacyRoomIdBlurbIdName: string) {
return this.pathTemplates.roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate.match(roomIdBlurbsLegacyRoomIdBlurbIdName).room_id;
}

/**
* Parse the legacy_room_id from RoomIdBlurbsLegacyRoomIdBlurbId resource.
*
* @param {string} roomIdBlurbsLegacyRoomIdBlurbIdName
* A fully-qualified path representing room_id_blurbs_legacy_room_id_blurb_id resource.
* @returns {string} A string representing the legacy_room_id.
*/
matchLegacyRoomIdFromRoomIdBlurbsLegacyRoomIdBlurbIdName(roomIdBlurbsLegacyRoomIdBlurbIdName: string) {
return this.pathTemplates.roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate.match(roomIdBlurbsLegacyRoomIdBlurbIdName).legacy_room_id;
}

/**
* Parse the blurb_id from RoomIdBlurbsLegacyRoomIdBlurbId resource.
*
* @param {string} roomIdBlurbsLegacyRoomIdBlurbIdName
* A fully-qualified path representing room_id_blurbs_legacy_room_id_blurb_id resource.
* @returns {string} A string representing the blurb_id.
*/
matchBlurbIdFromRoomIdBlurbsLegacyRoomIdBlurbIdName(roomIdBlurbsLegacyRoomIdBlurbIdName: string) {
return this.pathTemplates.roomIdBlurbsLegacyRoomIdBlurbIdPathTemplate.match(roomIdBlurbsLegacyRoomIdBlurbIdName).blurb_id;
}

/**
* Return a fully-qualified session resource name string.
*
Expand Down Expand Up @@ -938,6 +993,55 @@ export class IdentityClient {
return this.pathTemplates.userIdProfileBlurbIdPathTemplate.match(userIdProfileBlurbIdName).blurb_id;
}

/**
* Return a fully-qualified userIdProfileBlurbsLegacyUserIdBlurbId resource name string.
*
* @param {string} user_id
* @param {string} legacy_user_id
* @param {string} blurb_id
* @returns {string} Resource name string.
*/
userIdProfileBlurbsLegacyUserIdBlurbIdPath(userId:string,legacyUserId:string,blurbId:string) {
return this.pathTemplates.userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate.render({
user_id: userId,
legacy_user_id: legacyUserId,
blurb_id: blurbId,
});
}

/**
* Parse the user_id from UserIdProfileBlurbsLegacyUserIdBlurbId resource.
*
* @param {string} userIdProfileBlurbsLegacyUserIdBlurbIdName
* A fully-qualified path representing user_id_profile_blurbs_legacy_user_id_blurb_id resource.
* @returns {string} A string representing the user_id.
*/
matchUserIdFromUserIdProfileBlurbsLegacyUserIdBlurbIdName(userIdProfileBlurbsLegacyUserIdBlurbIdName: string) {
return this.pathTemplates.userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate.match(userIdProfileBlurbsLegacyUserIdBlurbIdName).user_id;
}

/**
* Parse the legacy_user_id from UserIdProfileBlurbsLegacyUserIdBlurbId resource.
*
* @param {string} userIdProfileBlurbsLegacyUserIdBlurbIdName
* A fully-qualified path representing user_id_profile_blurbs_legacy_user_id_blurb_id resource.
* @returns {string} A string representing the legacy_user_id.
*/
matchLegacyUserIdFromUserIdProfileBlurbsLegacyUserIdBlurbIdName(userIdProfileBlurbsLegacyUserIdBlurbIdName: string) {
return this.pathTemplates.userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate.match(userIdProfileBlurbsLegacyUserIdBlurbIdName).legacy_user_id;
}

/**
* Parse the blurb_id from UserIdProfileBlurbsLegacyUserIdBlurbId resource.
*
* @param {string} userIdProfileBlurbsLegacyUserIdBlurbIdName
* A fully-qualified path representing user_id_profile_blurbs_legacy_user_id_blurb_id resource.
* @returns {string} A string representing the blurb_id.
*/
matchBlurbIdFromUserIdProfileBlurbsLegacyUserIdBlurbIdName(userIdProfileBlurbsLegacyUserIdBlurbIdName: string) {
return this.pathTemplates.userIdProfileBlurbsLegacyUserIdBlurbIdPathTemplate.match(userIdProfileBlurbsLegacyUserIdBlurbIdName).blurb_id;
}

/**
* Terminate the GRPC channel and close the client.
*
Expand Down

0 comments on commit 68982db

Please sign in to comment.