Skip to content

fix: add logic to check for IAM RPC methods within the service before adding mixin to avoid generating duplicate methods#906

Open
shivanee-p wants to merge 2 commits intomainfrom
shivaneep-update-generator-logic-IAM-mixin
Open

fix: add logic to check for IAM RPC methods within the service before adding mixin to avoid generating duplicate methods#906
shivanee-p wants to merge 2 commits intomainfrom
shivaneep-update-generator-logic-IAM-mixin

Conversation

@shivanee-p
Copy link
Contributor

add logic to check for IAM RPC methods within the service before adding mixin to avoid generating duplicate methods

Fixes #905 🦕

… adding mixin to avoid generating duplicate methods
@shivanee-p shivanee-p requested a review from a team as a code owner February 23, 2026 23:32
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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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') ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want to make sure we're applying this to any mixin method, and there are various mixins possible (location, operations, etc.).

Copy link
Collaborator

@sofisl sofisl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generator: give precendence to protos if mixin is declared

2 participants