From 379841db7311ac647689ae7f1df319c1b24b1995 Mon Sep 17 00:00:00 2001 From: "Xiaofei Cao (from Dev Box)" Date: Thu, 19 Mar 2026 17:18:17 +0800 Subject: [PATCH 1/3] fix --- .../FluentClientMethodExample.java | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/examplemodel/FluentClientMethodExample.java b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/examplemodel/FluentClientMethodExample.java index 8a84ec1764c..c0f70415a8e 100644 --- a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/examplemodel/FluentClientMethodExample.java +++ b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/examplemodel/FluentClientMethodExample.java @@ -15,6 +15,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; /** * Model of example for service client method (usually for Fluent Premium). @@ -92,7 +93,13 @@ public String getMethodReference() { throw new IllegalStateException("Package '" + namespace + "' is not supported by Fluent Premium"); } - String serviceClientReference = ModelNaming.METHOD_SERVICE_CLIENT + "()"; + String serviceClientReference; + Optional metadataSuffix = FluentStatic.getFluentJavaSettings().getMetadataSuffix(); + if (metadataSuffix.isPresent() && SECONDARY_SERVICE_CLIENT_ACCESSOR.containsKey(metadataSuffix.get())) { + serviceClientReference = SECONDARY_SERVICE_CLIENT_ACCESSOR.get(metadataSuffix.get()) + "()"; + } else { + serviceClientReference = ModelNaming.METHOD_SERVICE_CLIENT + "()"; + } String methodGroupReference = "get" + CodeNamer.toPascalCase(methodGroup.getVariableName()) + "()"; return serviceClientReference + "." + methodGroupReference; } @@ -128,4 +135,30 @@ public String getMethodName() { MANAGER_REFERENCE.put("storage", "storageAccounts()"); MANAGER_REFERENCE.put("trafficmanager", "trafficManagerProfiles()"); } + + // Maps metadata-suffix (from secondary specs in multi-spec packages) to the service client + // accessor method on the SDK Manager class. When a secondary spec shares a Manager with the + // primary spec, serviceClient() returns the primary inner client. This map provides the correct + // accessor for the secondary inner client. + // Source of truth: + // https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/api-specs.json + private static final Map SECONDARY_SERVICE_CLIENT_ACCESSOR = new HashMap<>(); + static { + // resources package secondaries (ResourceManager) + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("feature", "featureClient"); + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("policy", "policyClient"); + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("lock", "managementLockClient"); + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("subscription", "subscriptionClient"); + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("change", "resourceChangeClient"); + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("databoundary", "dataBoundaryClient"); + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("deployments", "deploymentClient"); + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("deploymentstacks", "deploymentStackClient"); + // appservice package secondaries (AppServiceManager) + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("certificateregistration", "certificateRegistrationClient"); + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("domainregistration", "domainRegistrationClient"); + // containerregistry package secondary (ContainerRegistryManager) + SECONDARY_SERVICE_CLIENT_ACCESSOR.put("registrytasks", "taskClient"); + // authorization: msgraph uses default serviceClient() (AuthorizationManager implements + // HasServiceClient), no override needed + } } From 5c435cfd28cf3758743c7f531878b9e2c79a4ab4 Mon Sep 17 00:00:00 2001 From: Xiaofei Cao <92354331+XiaofeiCao@users.noreply.github.com> Date: Fri, 20 Mar 2026 12:39:43 +0800 Subject: [PATCH 2/3] changelog --- ...gmt_premium_sample_service_client-2026-2-19-9-20-23.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .chronus/changes/java_mgmt_premium_sample_service_client-2026-2-19-9-20-23.md diff --git a/.chronus/changes/java_mgmt_premium_sample_service_client-2026-2-19-9-20-23.md b/.chronus/changes/java_mgmt_premium_sample_service_client-2026-2-19-9-20-23.md new file mode 100644 index 00000000000..380d9d455d2 --- /dev/null +++ b/.chronus/changes/java_mgmt_premium_sample_service_client-2026-2-19-9-20-23.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@typespec/http-client-java" +--- + +mgmt premium, fix sample entry point and serviceClient reference From 6e69a30cf881f0b005ad30b89ab8db44f8115840 Mon Sep 17 00:00:00 2001 From: "Xiaofei Cao (from Dev Box)" Date: Fri, 20 Mar 2026 12:49:58 +0800 Subject: [PATCH 3/3] add cspell --- cspell.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/cspell.yaml b/cspell.yaml index 6d4f45eceea..eb028800fa8 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -155,6 +155,7 @@ words: - mqtt - mros - msbuild + - msgraph - mspaint - MSRC - msrest