fix: add logic to check for IAM RPC methods within the service before adding mixin to avoid generating duplicate methods#906
Conversation
… adding mixin to avoid generating duplicate methods
| if (serviceMixins.includes('google.iam.v1.IAMPolicy')) { | ||
| // Check if any of the services in the protos have SetIamPolicy, GetIamPolicy, or TestIamPermissions methods. | ||
| // If so, then remove the IAMPolicy mixin from the service yaml file to avoid duplicates. | ||
| const methods = API.getServiceMethods( |
There was a problem hiding this comment.
I think the API has the methods in the object itself, are you sure we need the 'get' method?
| this.request.fileToGenerate, | ||
| ); | ||
| if ( | ||
| methods.has('SetIamPolicy') || |
There was a problem hiding this comment.
we want to make sure we're applying this to any mixin method, and there are various mixins possible (location, operations, etc.).
sofisl
left a comment
There was a problem hiding this comment.
I think you're on the right track, but I think you want to create a new function that sets the mixins to 0 in augmentService if they already exist in the protos. take a look at what getSelectiveGapic does - it's kind of similar to what we want to do. I basically think we want to do something like, if there are the mixin methods already in the service's methods, then we want to set the mixin to 0 (kind of similar to the logic in lines 1063 - 1072).
Another idea is to talk to other languages to see what logic they use. I'd assume we're just doing some regex checking (i.e., if methods have 'iam' or "locations', then don't set the mixin), but I'm not sure - worth checking!
add logic to check for IAM RPC methods within the service before adding mixin to avoid generating duplicate methods
Fixes #905 🦕