Skip to content

[http-client-java] mgmt premium, fix sample entry point and serviceClient reference for autorest#10082

Open
XiaofeiCao wants to merge 5 commits intomainfrom
java_mgmt_premium_sample_service_client
Open

[http-client-java] mgmt premium, fix sample entry point and serviceClient reference for autorest#10082
XiaofeiCao wants to merge 5 commits intomainfrom
java_mgmt_premium_sample_service_client

Conversation

@XiaofeiCao
Copy link
Copy Markdown
Member

@XiaofeiCao XiaofeiCao commented Mar 19, 2026

Bug

When generating premium mgmt samples from Swagger, we switched to use individual entry points in #9845. However, for multi-service scenario(appservice, resources, etc)

  1. entry point now be the aggregated Manager, instead of the individual packages, e.g. There's no PolicyManager, but rather ResourceManager.
  2. service client got separate too, instead of residing inside of the entry Manager. e.g. There's no ResourceManager.serviceClient().getPolicyDefinitions(), but rather ResourceManager.policyClient().getPolicyDefinitions().

Solution

We'll need
For 1. Add service-name config to api-specs.json, to allow for entry point discovery. E.g. ResourceManager instead of default PolicyManager. PR: Azure/azure-sdk-for-java#48490
For 2. We need secondary service client entry mapping. Fortunately, we already have metadata-suffix that we can use:
E.g. https://github.com/Azure/azure-sdk-for-java/blob/16fffda39d14c6fc6f3f24a972814c429d46c135/sdk/resourcemanager/api-specs.json#L18

Limitation

The fix is mainly for Swagger purpose. Might need a revisit for TypeSpec multi-service.
Will log an issue if we take this approach.

About this PR

@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Mar 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 19, 2026

All changed packages have been documented.

  • @typespec/http-client-java
Show changes

@typespec/http-client-java - fix ✏️

mgmt premium, fix sample entry point and serviceClient reference

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Mar 19, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

XiaofeiCao and others added 3 commits March 20, 2026 12:39
@XiaofeiCao XiaofeiCao changed the title WIP, [http-client-java] mgmt premium, fix sample entry point and serviceClient reference [http-client-java] mgmt premium, fix sample entry point and serviceClient reference Mar 20, 2026
@XiaofeiCao XiaofeiCao marked this pull request as ready for review March 20, 2026 06:26
@XiaofeiCao XiaofeiCao changed the title [http-client-java] mgmt premium, fix sample entry point and serviceClient reference [http-client-java] mgmt premium, fix sample entry point and serviceClient reference for autorest Mar 20, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the stale Mark a PR that hasn't been recently updated and will be closed. label Apr 24, 2026
@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

Hi @@XiaofeiCao. Your PR has had no update for 30 days and it is marked as a stale PR. If it is not updated within 30 days, the PR will automatically be closed. If you want to refresh the PR, please remove the stale label.

Copy link
Copy Markdown
Contributor

@weidongxu-microsoft weidongxu-microsoft left a comment

Choose a reason for hiding this comment

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

Is this PR still relevant? We probably won't release another autorest.java (I've disabled the pipeline due to CFS)

Comment on lines +119 to +130
// TypeSpec multi-client: check if the method group belongs to a non-primary service client
List<ServiceClient> allServiceClients = client.getServiceClients();
if (allServiceClients != null
&& allServiceClients.size() > 1
&& !methodGroupOwner.equals(primaryServiceClient.getClassName())) {
// Find the secondary service client that owns this method group
for (ServiceClient sc : allServiceClients) {
if (sc.getClassName().equals(methodGroupOwner)) {
return CodeNamer.toCamelCase(sc.getInterfaceName()) + "()";
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this part is valid for TypeSpec. For mixed-api-version, it is still just 1 client in mgmt.

For lib like resources, the separate clients are generated from different tsp compile command. So here one won't see multiple serviceClient.

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

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java stale Mark a PR that hasn't been recently updated and will be closed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants