Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Universe domain support for discovery based libraries. #746

Merged

Conversation

amanda-tarafa
Copy link
Contributor

@amanda-tarafa amanda-tarafa commented Feb 21, 2024

This has a dependency on googleapis/google-api-dotnet-client#2675 because generated code uses the methods defined there. This PR's presubmits won't be green until we have merged and released googleapis/google-api-dotnet-client#2675.

@amanda-tarafa amanda-tarafa requested a review from jskeet February 21, 2024 23:06
@amanda-tarafa amanda-tarafa requested a review from a team as a code owner February 21, 2024 23:06
Copy link
Collaborator

@jskeet jskeet left a comment

Choose a reason for hiding this comment

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

I guess there's a slight memory footprint increase here with more fields rather than calculated properties, but I very much doubt that it'll be significant.

.WithBlockBody(resourceProperties.Zip(Resources).Select(pair => pair.First.Assign(New(ctx.Type(pair.Second.Typ))(This))).ToArray())
.WithBlockBody(
resourceProperties.Zip(Resources).Select(pair => pair.First.Assign(New(ctx.Type(pair.Second.Typ))(This)))
.Append(baseUriProperty.Assign(Call("GetEffectiveUri")(IdentifierName("BaseUriOverride"), baseUriValue)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: indent these three lines more? (So they're indented relative to resourceProperties.Zip?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

amanda-tarafa added a commit to googleapis/google-api-dotnet-client that referenced this pull request Feb 22, 2024
- The universe domain may be specified through the client service initializer.
- A helper method to calculate effective URIs that takes into account the universe domain. This method is to be used by generated code, see googleapis/gapic-generator-csharp#746.
- The universe domain is passed as a request option for the credential to validate against when intercepting and before setting the token.
amanda-tarafa added a commit to googleapis/google-api-dotnet-client that referenced this pull request Feb 22, 2024
- The universe domain may be specified through the client service initializer.
- A helper method to calculate effective URIs that takes into account the universe domain. This method is to be used by generated code, see googleapis/gapic-generator-csharp#746.
- The universe domain is passed as a request option for the credential to validate against when intercepting and before setting the token.
@amanda-tarafa amanda-tarafa force-pushed the discovery-universe-domain branch from d25cb64 to f537a7a Compare February 22, 2024 17:34
Copy link
Contributor Author

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

I guess there's a slight memory footprint increase here with more fields rather than calculated properties, but I very much doubt that it'll be significant.

Yes, I did choose this actively. Calculating the properties now implies replacing "googleapis.com" with the custom domain, if there is one. And that happens for every service call, so I figured having the fields was slightly better. Happy to reconsider. Ultimately I think neither is going to make much of a difference though.

.WithBlockBody(resourceProperties.Zip(Resources).Select(pair => pair.First.Assign(New(ctx.Type(pair.Second.Typ))(This))).ToArray())
.WithBlockBody(
resourceProperties.Zip(Resources).Select(pair => pair.First.Assign(New(ctx.Type(pair.Second.Typ))(This)))
.Append(baseUriProperty.Assign(Call("GetEffectiveUri")(IdentifierName("BaseUriOverride"), baseUriValue)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Once we have released the generator and updated Discovery based generation to use the new version of the generator, we'll be able to update the Google.Apis.Discovery.v1 (1.66.0 -> 1.67.0) dependency in Google.Api.Generator.Rest instead. See b/326453788
Note that this is not an extension on another syntax element, we have plenty of those, nor a this-qualified method call. This generates a method call to an instance method without the this qualifier.
Generate code that calculates URIs taking the universe domain into account.
@amanda-tarafa amanda-tarafa force-pushed the discovery-universe-domain branch from f537a7a to 31904ad Compare February 22, 2024 19:41
@amanda-tarafa
Copy link
Contributor Author

I've updated to latest GAX and Google.Apis (tests only) latests. I'll merge on green.

@amanda-tarafa amanda-tarafa merged commit 5d06134 into googleapis:main Feb 22, 2024
4 checks passed
@amanda-tarafa amanda-tarafa deleted the discovery-universe-domain branch February 22, 2024 19:43
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.

2 participants