From 7c81a0039fb664d6b3d65826e17b30093c82dcf0 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 21 Oct 2025 14:35:58 +0800 Subject: [PATCH 01/50] fallback to version compare by date --- .../http-client-java/emitter/src/models.ts | 14 ++ .../emitter/src/versioning-utils.ts | 75 ++++++++++ .../emitter/test/utils.test.ts | 137 +++++++++++++++++- 3 files changed, 225 insertions(+), 1 deletion(-) diff --git a/packages/http-client-java/emitter/src/models.ts b/packages/http-client-java/emitter/src/models.ts index 83d65aedbbd..de6f038ff61 100644 --- a/packages/http-client-java/emitter/src/models.ts +++ b/packages/http-client-java/emitter/src/models.ts @@ -1,6 +1,7 @@ import { ApiVersions, Parameter } from "@autorest/codemodel"; import { Operation } from "@typespec/compiler"; import { Version } from "@typespec/versioning"; +import { isVersionEarlierThan, isVersionedByDate } from "./versioning-utils.js"; export class ClientContext { baseUri: string; @@ -47,6 +48,19 @@ export class ClientContext { addedVersions.push(version); } } + + if (addedVersions.length === 0 && isVersionedByDate(addedVersion)) { + // try again with versioning by YYYY-MM-DD(-preview) + let includeVersion = false; + for (const version of this.apiVersions) { + if (isVersionedByDate(version) && isVersionEarlierThan(addedVersion, version)) { + includeVersion = true; + } + if (includeVersion) { + addedVersions.push(version); + } + } + } } return addedVersions; } diff --git a/packages/http-client-java/emitter/src/versioning-utils.ts b/packages/http-client-java/emitter/src/versioning-utils.ts index aaa9f5f4059..74bb57feeb8 100644 --- a/packages/http-client-java/emitter/src/versioning-utils.ts +++ b/packages/http-client-java/emitter/src/versioning-utils.ts @@ -60,3 +60,78 @@ function isStableApiVersion(program: Program, version: Version): boolean { export function isStableApiVersionString(version: string): boolean { return !version.toLowerCase().endsWith("-preview"); } + +/** + * Checks whether a version follows the YYYY-MM-DD(-preview) format. + * The "-preview" suffix is optional. + * + * @param version the version string to validate + * @returns true if the version follows the YYYY-MM-DD(-preview) format, false otherwise + */ +export function isVersionedByDate(version: string): boolean { + if (!version) { + return false; + } + + // Regular expression to match YYYY-MM-DD(-preview) format + // YYYY: 4 digits for year + // MM: 2 digits for month (01-12) + // DD: 2 digits for day (01-31) + // (-preview): optional preview suffix + const dateVersionRegex = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(-preview)?$/; + + return dateVersionRegex.test(version); +} + +/** + * Compares two date-based versions to determine if the first version is earlier than the second. + * Assumes both versions have already passed isVersionedByDate validation. + * + * Comparison logic: + * 1. Compare by date (YYYY-MM-DD) first + * 2. If dates are equal, stable version is considered later than preview version + * + * @param version the version to check + * @param compareTo the version to compare against + * @returns true if version is earlier than compareTo, false otherwise + */ +export function isVersionEarlierThan(version: string, compareTo: string): boolean { + if (!version || !compareTo) { + return false; + } + + // Extract date parts and preview status + const parseVersion = (ver: string) => { + const isPreview = ver.endsWith("-preview"); + const datePart = isPreview ? ver.slice(0, -8) : ver; // Remove "-preview" if present + const [year, month, day] = datePart.split("-").map(Number); + return { year, month, day, isPreview }; + }; + + const versionParts = parseVersion(version); + const compareToParts = parseVersion(compareTo); + + // Compare by year first + if (versionParts.year !== compareToParts.year) { + return versionParts.year < compareToParts.year; + } + + // Compare by month if years are equal + if (versionParts.month !== compareToParts.month) { + return versionParts.month < compareToParts.month; + } + + // Compare by day if years and months are equal + if (versionParts.day !== compareToParts.day) { + return versionParts.day < compareToParts.day; + } + + // If dates are identical, compare preview status + // Preview version is considered earlier than stable version + if (versionParts.isPreview !== compareToParts.isPreview) { + return versionParts.isPreview && !compareToParts.isPreview; + } + + // Versions are identical + return false; +} diff --git a/packages/http-client-java/emitter/test/utils.test.ts b/packages/http-client-java/emitter/test/utils.test.ts index 29f6d814c37..07a652477ab 100644 --- a/packages/http-client-java/emitter/test/utils.test.ts +++ b/packages/http-client-java/emitter/test/utils.test.ts @@ -6,7 +6,11 @@ import { removeClientSuffix, stringArrayContainsIgnoreCase, } from "../src/utils.js"; -import { isStableApiVersionString } from "../src/versioning-utils.js"; +import { + isStableApiVersionString, + isVersionEarlierThan, + isVersionedByDate, +} from "../src/versioning-utils.js"; describe("utils", () => { it("pascalCase", () => { @@ -42,6 +46,137 @@ describe("versioning-utils", () => { expect(isStableApiVersionString("2022-09-01")).toBe(true); expect(isStableApiVersionString("2023-12-01-preview")).toBe(false); }); + + it("isVersionedByDate - valid date versions", () => { + // Valid stable versions + expect(isVersionedByDate("2024-01-15")).toBe(true); + expect(isVersionedByDate("2023-12-31")).toBe(true); + expect(isVersionedByDate("2025-06-01")).toBe(true); + expect(isVersionedByDate("2022-02-28")).toBe(true); + expect(isVersionedByDate("2020-02-29")).toBe(true); // leap year + + // Valid preview versions + expect(isVersionedByDate("2024-01-15-preview")).toBe(true); + expect(isVersionedByDate("2023-12-31-preview")).toBe(true); + expect(isVersionedByDate("2025-06-01-preview")).toBe(true); + + // Edge cases for valid dates + expect(isVersionedByDate("2024-01-01")).toBe(true); + expect(isVersionedByDate("2024-12-31")).toBe(true); + }); + + it("isVersionedByDate - invalid date versions", () => { + // Invalid format - single digit month/day + expect(isVersionedByDate("2024-1-15")).toBe(false); + expect(isVersionedByDate("2024-01-5")).toBe(false); + expect(isVersionedByDate("2024-1-5")).toBe(false); + + // Invalid format - wrong year length + expect(isVersionedByDate("24-01-15")).toBe(false); + expect(isVersionedByDate("202-01-15")).toBe(false); + expect(isVersionedByDate("20244-01-15")).toBe(false); + + // Invalid separators + expect(isVersionedByDate("2024/01/15")).toBe(false); + expect(isVersionedByDate("2024.01.15")).toBe(false); + expect(isVersionedByDate("20240115")).toBe(false); + + // Invalid month values + expect(isVersionedByDate("2024-00-15")).toBe(false); + expect(isVersionedByDate("2024-13-15")).toBe(false); + + // Invalid day values + expect(isVersionedByDate("2024-01-00")).toBe(false); + expect(isVersionedByDate("2024-01-32")).toBe(false); + + // Invalid suffix + expect(isVersionedByDate("2024-01-15-beta")).toBe(false); + expect(isVersionedByDate("2024-01-15-alpha")).toBe(false); + expect(isVersionedByDate("2024-01-15-rc")).toBe(false); + expect(isVersionedByDate("2024-01-15-PREVIEW")).toBe(false); // case sensitive + + // Additional characters + expect(isVersionedByDate("2024-01-15-preview-extra")).toBe(false); + expect(isVersionedByDate("prefix-2024-01-15")).toBe(false); + expect(isVersionedByDate("2024-01-15 ")).toBe(false); // trailing space + expect(isVersionedByDate(" 2024-01-15")).toBe(false); // leading space + + // Empty or null values + expect(isVersionedByDate("")).toBe(false); + expect(isVersionedByDate(null as any)).toBe(false); + expect(isVersionedByDate(undefined as any)).toBe(false); + + // Non-date formats + expect(isVersionedByDate("v1.0.0")).toBe(false); + expect(isVersionedByDate("1.2.3")).toBe(false); + expect(isVersionedByDate("stable")).toBe(false); + expect(isVersionedByDate("latest")).toBe(false); + }); + + it("isVersionEarlierThan - date comparisons", () => { + // Year comparisons + expect(isVersionEarlierThan("2023-01-01", "2024-01-01")).toBe(true); + expect(isVersionEarlierThan("2024-01-01", "2023-01-01")).toBe(false); + + // Month comparisons (same year) + expect(isVersionEarlierThan("2024-01-01", "2024-12-01")).toBe(true); + expect(isVersionEarlierThan("2024-12-01", "2024-01-01")).toBe(false); + expect(isVersionEarlierThan("2024-06-01", "2024-07-01")).toBe(true); + + // Day comparisons (same year and month) + expect(isVersionEarlierThan("2024-01-01", "2024-01-31")).toBe(true); + expect(isVersionEarlierThan("2024-01-31", "2024-01-01")).toBe(false); + expect(isVersionEarlierThan("2024-01-15", "2024-01-16")).toBe(true); + + // Cross month/year boundaries + expect(isVersionEarlierThan("2023-12-31", "2024-01-01")).toBe(true); + expect(isVersionEarlierThan("2024-01-31", "2024-02-01")).toBe(true); + }); + + it("isVersionEarlierThan - preview vs stable", () => { + // Same date: preview is earlier than stable + expect(isVersionEarlierThan("2024-01-15-preview", "2024-01-15")).toBe(true); + expect(isVersionEarlierThan("2024-01-15", "2024-01-15-preview")).toBe(false); + + // Different dates: date takes precedence over preview status + expect(isVersionEarlierThan("2024-01-14-preview", "2024-01-15-preview")).toBe(true); + expect(isVersionEarlierThan("2024-01-14", "2024-01-15-preview")).toBe(true); + expect(isVersionEarlierThan("2024-01-16-preview", "2024-01-15")).toBe(false); + + // Both preview versions + expect(isVersionEarlierThan("2024-01-14-preview", "2024-01-15-preview")).toBe(true); + expect(isVersionEarlierThan("2024-01-15-preview", "2024-01-14-preview")).toBe(false); + + // Both stable versions + expect(isVersionEarlierThan("2024-01-14", "2024-01-15")).toBe(true); + expect(isVersionEarlierThan("2024-01-15", "2024-01-14")).toBe(false); + }); + + it("isVersionEarlierThan - identical versions", () => { + // Same stable versions + expect(isVersionEarlierThan("2024-01-15", "2024-01-15")).toBe(false); + expect(isVersionEarlierThan("2023-12-31", "2023-12-31")).toBe(false); + + // Same preview versions + expect(isVersionEarlierThan("2024-01-15-preview", "2024-01-15-preview")).toBe(false); + expect(isVersionEarlierThan("2023-12-31-preview", "2023-12-31-preview")).toBe(false); + }); + + it("isVersionEarlierThan - edge cases", () => { + // Empty or null values + expect(isVersionEarlierThan("", "2024-01-15")).toBe(false); + expect(isVersionEarlierThan("2024-01-15", "")).toBe(false); + expect(isVersionEarlierThan("", "")).toBe(false); + expect(isVersionEarlierThan(null as any, "2024-01-15")).toBe(false); + expect(isVersionEarlierThan("2024-01-15", null as any)).toBe(false); + expect(isVersionEarlierThan(undefined as any, undefined as any)).toBe(false); + + // Real-world examples + expect(isVersionEarlierThan("2022-09-01", "2023-01-01")).toBe(true); + expect(isVersionEarlierThan("2023-01-01-preview", "2023-01-01")).toBe(true); + expect(isVersionEarlierThan("2023-01-01", "2023-01-01-preview")).toBe(false); + expect(isVersionEarlierThan("2024-02-29", "2024-03-01")).toBe(true); // leap year + }); }); describe("type-utils", () => { From 941939b0ce123a0e76cabc07a47ecd83114f7691 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 21 Oct 2025 14:41:00 +0800 Subject: [PATCH 02/50] set to undefined, if cannot find version in apiVersions --- packages/http-client-java/emitter/src/models.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/http-client-java/emitter/src/models.ts b/packages/http-client-java/emitter/src/models.ts index de6f038ff61..6f7dd1e1304 100644 --- a/packages/http-client-java/emitter/src/models.ts +++ b/packages/http-client-java/emitter/src/models.ts @@ -34,9 +34,9 @@ export class ClientContext { } } - getAddedVersions(versions: Version[]): string[] { + getAddedVersions(versions: Version[]): string[] | undefined { // currently only allow one added version - const addedVersions: string[] = []; + let addedVersions: string[] = []; const addedVersion = versions.shift()!.value; if (this.apiVersions) { let includeVersion = false; @@ -61,6 +61,11 @@ export class ClientContext { } } } + + if (addedVersions.length === 0) { + // could not find matching version in client apiVersions + return undefined; + } } return addedVersions; } From c598d4eedb4fc463cbff1db39ebc97d0057a881c Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 21 Oct 2025 15:05:45 +0800 Subject: [PATCH 03/50] nit --- packages/http-client-java/emitter/src/models.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/http-client-java/emitter/src/models.ts b/packages/http-client-java/emitter/src/models.ts index 6f7dd1e1304..73230b8d9cd 100644 --- a/packages/http-client-java/emitter/src/models.ts +++ b/packages/http-client-java/emitter/src/models.ts @@ -61,12 +61,13 @@ export class ClientContext { } } } + } - if (addedVersions.length === 0) { - // could not find matching version in client apiVersions - return undefined; - } + if (addedVersions.length === 0) { + // could not find matching version in client apiVersions + return undefined; + } else { + return addedVersions; } - return addedVersions; } } From e49c321f4d3045d8e239dce93757d8f22c84f0c8 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 21 Oct 2025 15:11:54 +0800 Subject: [PATCH 04/50] fix lint --- packages/http-client-java/emitter/src/models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-client-java/emitter/src/models.ts b/packages/http-client-java/emitter/src/models.ts index 73230b8d9cd..307091ceb69 100644 --- a/packages/http-client-java/emitter/src/models.ts +++ b/packages/http-client-java/emitter/src/models.ts @@ -36,7 +36,7 @@ export class ClientContext { getAddedVersions(versions: Version[]): string[] | undefined { // currently only allow one added version - let addedVersions: string[] = []; + const addedVersions: string[] = []; const addedVersion = versions.shift()!.value; if (this.apiVersions) { let includeVersion = false; From 225dd5952be49f73c1b37c016707198b55a428f2 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 21 Oct 2025 16:12:57 +0800 Subject: [PATCH 05/50] test case --- .../tsp/arm-versioned.tsp | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp new file mode 100644 index 00000000000..1e1d1f1dcf4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp @@ -0,0 +1,58 @@ +import "@typespec/http"; +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ClientGenerator.Core; +using Azure.ClientGenerator.Core.Legacy; + +@armProviderNamespace +@service(#{ title: "ArmVersioned" }) +@versioned(Versions) +@doc("Arm Resource Provider management API.") +namespace TspTest.ArmVersioned; + +enum Versions { + v2023_12_01: "2023-12-01", + v2024_12_01: "2024-12-01", +} + +@resource("topLevelArmResources") +model TopLevelArmResource is TrackedResource { + ...ResourceNameParameter; +} + +@doc("Top Level Arm Resource Properties.") +model TopLevelArmResourceProperties { + @visibility(Lifecycle.Read) + provisioningState?: ResourceProvisioningState; +} + +model OpParameters { + @query + parameter?: string; + + @added(Versions.v2024_12_01) + @query + newParameter?: string; +} + +model Response {} + +interface TopLevelArmResources { + createOrUpdate is ArmResourceCreateOrUpdateAsync; + listBySubscription is ArmListBySubscription; + action is ArmResourceActionSync< + TopLevelArmResource, + Request = void, + Response = Response, + Parameters = OpParameters + >; +} From a668d88f01dddb888dfc18935a1d4539641905de Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 21 Oct 2025 16:15:17 +0800 Subject: [PATCH 06/50] nit to cover the case of the erasure of preview api-version --- .../http-client-generator-test/tsp/arm-versioned.tsp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp index 1e1d1f1dcf4..c97b3d0f8f4 100644 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp @@ -8,10 +8,7 @@ import "@azure-tools/typespec-client-generator-core"; using TypeSpec.Http; using TypeSpec.Rest; using TypeSpec.Versioning; -using Azure.Core; using Azure.ResourceManager; -using Azure.ClientGenerator.Core; -using Azure.ClientGenerator.Core.Legacy; @armProviderNamespace @service(#{ title: "ArmVersioned" }) @@ -21,6 +18,7 @@ namespace TspTest.ArmVersioned; enum Versions { v2023_12_01: "2023-12-01", + v2024_10_01_preview: "2024-10-01-preview", v2024_12_01: "2024-12-01", } @@ -39,7 +37,7 @@ model OpParameters { @query parameter?: string; - @added(Versions.v2024_12_01) + @added(Versions.v2024_10_01_preview) @query newParameter?: string; } From 8d2f7ab63361d2d2b1891ebc12f4ee10aa5ed895 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 22 Oct 2025 15:56:53 +0800 Subject: [PATCH 07/50] partial tool --- .../core/mapper/ClientMethodMapper.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index dcf145a086d..06cde0bb9e8 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -355,16 +355,29 @@ private static JavaVisibility methodVisibilityInWrapperClient(Operation operatio } } - private static void createOverloadForVersioning(boolean isProtocolMethod, List methods, - ClientMethod baseMethod) { + private void createOverloadForVersioning(List methods, ClientMethod baseMethod, + JavaVisibility methodWithContextVisibility, MethodPageDetails methodPageDetailsWithContext, + boolean isProtocolMethod) { final List parameters = baseMethod.getParameters(); - if (!isProtocolMethod && JavaSettings.getInstance().isDataPlaneClient()) { + if (!isProtocolMethod) { if (parameters.stream().anyMatch(p -> p.getVersioning() != null && p.getVersioning().getAdded() != null)) { final List> signatures = findOverloadedSignatures(parameters); for (List overloadedParameters : signatures) { - final ClientMethod overloadedMethod - = baseMethod.newBuilder().parameters(overloadedParameters).build(); - methods.add(overloadedMethod); + if (JavaSettings.getInstance().isDataPlaneClient()) { + final ClientMethod overloadedMethod + = baseMethod.newBuilder().parameters(overloadedParameters).build(); + methods.add(overloadedMethod); + } else { + ClientMethod.Builder overloadedMethodBuilder + = baseMethod.newBuilder().parameters(overloadedParameters); + if (methodPageDetailsWithContext != null) { + overloadedMethodBuilder + = overloadedMethodBuilder.methodPageDetails(methodPageDetailsWithContext); + } + final ClientMethod overloadedMethod = overloadedMethodBuilder.build(); + addClientMethodWithContext(methods, overloadedMethod, methodWithContextVisibility, + isProtocolMethod); + } } } } @@ -509,7 +522,8 @@ private void createPageStreamingClientMethods(boolean isSync, ClientMethod baseM // generate the overload, if "sync-methods != NONE" methods.add(pagingMethod); // overload for versioning - createOverloadForVersioning(isProtocolMethod, methods, pagingMethod); + createOverloadForVersioning(methods, pagingMethod, methodWithContextVisibility, + methodPageDetailsWithContext, isProtocolMethod); } if (generateRequiredOnlyParametersOverload) { @@ -705,7 +719,7 @@ private void createLroBeginClientMethods(boolean isSync, ClientMethod lroBaseMet methods.add(beginLroMethod); // LRO 'begin[Operation]' sync or async method overloads with versioning. - createOverloadForVersioning(isProtocolMethod, methods, beginLroMethod); + createOverloadForVersioning(methods, beginLroMethod, methodWithContextVisibility, null, isProtocolMethod); if (generateRequiredOnlyParametersOverload) { // LRO 'begin[Operation]' sync or async method overload with only required parameters. @@ -808,7 +822,7 @@ private void createSimpleValueClientMethods(boolean isSync, ClientMethod baseMet methods.add(simpleMethod); // overload for versioning - createOverloadForVersioning(isProtocolMethod, methods, simpleMethod); + createOverloadForVersioning(methods, simpleMethod, methodWithContextVisibility, null, isProtocolMethod); if (generateRequiredOnlyParametersOverload) { final ClientMethod simpleMethodWithRequiredParameters = simpleMethod.newBuilder() From ff2e84e06c91925bcaf52932f28d4e24da36c1c3 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 22 Oct 2025 16:21:33 +0800 Subject: [PATCH 08/50] simple method uses WithResponse --- .../client/generator/core/mapper/ClientMethodMapper.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index 06cde0bb9e8..622ff6668b1 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -358,16 +358,17 @@ private static JavaVisibility methodVisibilityInWrapperClient(Operation operatio private void createOverloadForVersioning(List methods, ClientMethod baseMethod, JavaVisibility methodWithContextVisibility, MethodPageDetails methodPageDetailsWithContext, boolean isProtocolMethod) { + final ClientMethodType clientMethodType = baseMethod.getType(); final List parameters = baseMethod.getParameters(); if (!isProtocolMethod) { if (parameters.stream().anyMatch(p -> p.getVersioning() != null && p.getVersioning().getAdded() != null)) { final List> signatures = findOverloadedSignatures(parameters); for (List overloadedParameters : signatures) { - if (JavaSettings.getInstance().isDataPlaneClient()) { + if (JavaSettings.getInstance().isDataPlaneClient() && (clientMethodType != ClientMethodType.SimpleSyncRestResponse && clientMethodType != ClientMethodType.SimpleAsyncRestResponse)) { final ClientMethod overloadedMethod = baseMethod.newBuilder().parameters(overloadedParameters).build(); methods.add(overloadedMethod); - } else { + } else if (!JavaSettings.getInstance().isDataPlaneClient() && (clientMethodType != ClientMethodType.SimpleAsync && clientMethodType != ClientMethodType.SimpleSync)) { ClientMethod.Builder overloadedMethodBuilder = baseMethod.newBuilder().parameters(overloadedParameters); if (methodPageDetailsWithContext != null) { @@ -778,6 +779,10 @@ private void createSimpleWithResponseClientMethods(boolean isSync, ClientMethod .hasWithContextOverload(hasContextOverload) .methodVisibility(methodVisibility) .build(); + + // overload for versioning + createOverloadForVersioning(methods, withResponseMethod, methodWithContextVisibility, null, isProtocolMethod); + // Always generate an overload of WithResponse with non-required parameters without Context. It is only for sync // proxy method, and is usually filtered out in methodVisibility function. methods.add(withResponseMethod); From bb96c021cb426df0c90b58d317411caa3b033550 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Thu, 23 Oct 2025 13:26:45 +0800 Subject: [PATCH 09/50] enhance --- .../client/generator/core/mapper/ClientMethodMapper.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index 622ff6668b1..2222bd709d9 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -364,11 +364,15 @@ private void createOverloadForVersioning(List methods, ClientMetho if (parameters.stream().anyMatch(p -> p.getVersioning() != null && p.getVersioning().getAdded() != null)) { final List> signatures = findOverloadedSignatures(parameters); for (List overloadedParameters : signatures) { - if (JavaSettings.getInstance().isDataPlaneClient() && (clientMethodType != ClientMethodType.SimpleSyncRestResponse && clientMethodType != ClientMethodType.SimpleAsyncRestResponse)) { + if (JavaSettings.getInstance().isDataPlaneClient() + && (clientMethodType != ClientMethodType.SimpleSyncRestResponse + && clientMethodType != ClientMethodType.SimpleAsyncRestResponse)) { final ClientMethod overloadedMethod = baseMethod.newBuilder().parameters(overloadedParameters).build(); methods.add(overloadedMethod); - } else if (!JavaSettings.getInstance().isDataPlaneClient() && (clientMethodType != ClientMethodType.SimpleAsync && clientMethodType != ClientMethodType.SimpleSync)) { + } else if (!JavaSettings.getInstance().isDataPlaneClient() + && (clientMethodType != ClientMethodType.SimpleAsync + && clientMethodType != ClientMethodType.SimpleSync)) { ClientMethod.Builder overloadedMethodBuilder = baseMethod.newBuilder().parameters(overloadedParameters); if (methodPageDetailsWithContext != null) { From 99ae8805c8bfe644f18ef169dc4dc66eb6c57142 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 18 Nov 2025 15:39:10 +0800 Subject: [PATCH 10/50] improve client method template to recognize parameter that need to be locally initialized --- .../core/template/ClientMethodTemplate.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index ddf94cc41e9..9ca08700590 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -140,6 +140,8 @@ protected static void addOptionalVariables(JavaBlock function, ClientMethod clie protected static void addOptionalAndConstantVariables(JavaBlock function, ClientMethod clientMethod, JavaSettings settings) { final List proxyMethodParameters = clientMethod.getProxyMethod().getParameters(); + List methodParameters + = MethodUtil.getParameters(clientMethod, false); for (ProxyMethodParameter parameter : proxyMethodParameters) { if (parameter.isFromClient()) { // parameter is scoped to the client, hence no local variable instantiation for it. @@ -164,7 +166,17 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client // If the parameter isn't required and the client method only uses required parameters, optional // parameters are omitted and will need to instantiated in the method. - boolean optionalOmitted = clientMethod.getOnlyRequiredParameters() && !parameter.isRequired(); + boolean optionalOmitted = !parameter.isRequired() && parameter.getClientType() != ClassType.CONTEXT; + if (optionalOmitted) { + boolean parameterInClientMethodSignature = methodParameters.stream() + .filter(p -> p.getProxyMethodParameter() == parameter) + .findFirst() + .map(p -> p.getClientMethodParameter()) + .isPresent(); + // if the parameter is defined in client method signature, + // it does not need to be instantiated in local variable. + optionalOmitted = !parameterInClientMethodSignature; + } // Optional variables and constants are always null if their wire type and client type differ and applying // conversions between the types is ignored. From f01061b409ebddd15c23fa7553e055d5a7b0ce89 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 18 Nov 2025 15:49:13 +0800 Subject: [PATCH 11/50] format --- .../generator/core/template/ClientMethodTemplate.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index 9ca08700590..1fdf7aa49c1 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -169,10 +169,10 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client boolean optionalOmitted = !parameter.isRequired() && parameter.getClientType() != ClassType.CONTEXT; if (optionalOmitted) { boolean parameterInClientMethodSignature = methodParameters.stream() - .filter(p -> p.getProxyMethodParameter() == parameter) - .findFirst() - .map(p -> p.getClientMethodParameter()) - .isPresent(); + .filter(p -> p.getProxyMethodParameter() == parameter) + .findFirst() + .map(p -> p.getClientMethodParameter()) + .isPresent(); // if the parameter is defined in client method signature, // it does not need to be instantiated in local variable. optionalOmitted = !parameterInClientMethodSignature; From d6652f0ce5c2944229318916a26b64cfb0810fa9 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 18 Nov 2025 16:06:29 +0800 Subject: [PATCH 12/50] regen --- .../armversioned/ArmVersionedManager.java | 282 +++++++ .../fluent/ArmVersionedClient.java | 55 ++ .../fluent/TopLevelArmResourcesClient.java | 141 ++++ .../models/TopLevelArmResourceInner.java | 181 +++++ .../fluent/models/package-info.java | 9 + .../armversioned/fluent/package-info.java | 9 + .../ArmVersionedClientBuilder.java | 138 ++++ .../ArmVersionedClientImpl.java | 308 ++++++++ .../implementation/ResourceManagerUtils.java | 195 +++++ .../TopLevelArmResourceImpl.java | 200 +++++ .../TopLevelArmResourcesClientImpl.java | 696 ++++++++++++++++++ .../TopLevelArmResourcesImpl.java | 60 ++ .../models/TopLevelArmResourceListResult.java | 97 +++ .../implementation/package-info.java | 9 + .../models/ResourceProvisioningState.java | 56 ++ .../models/TopLevelArmResource.java | 326 ++++++++ .../models/TopLevelArmResourceProperties.java | 75 ++ .../models/TopLevelArmResources.java | 71 ++ .../armversioned/models/package-info.java | 9 + .../tsptest/armversioned/package-info.java | 9 + ...ersioned-generated_apiview_properties.json | 17 + ...nager-armversioned-generated_metadata.json | 1 + .../proxy-config.json | 1 + .../reflect-config.json | 1 + ...emanager-armversioned-generated.properties | 1 + .../TopLevelArmResourceInnerTests.java | 45 ++ .../TopLevelArmResourceListResultTests.java | 21 + .../TopLevelArmResourcePropertiesTests.java | 22 + 28 files changed, 3035 insertions(+) create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/ArmVersionedManager.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/ArmVersionedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/models/TopLevelArmResourceInner.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/models/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ArmVersionedClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ResourceManagerUtils.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/models/TopLevelArmResourceListResult.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/ResourceProvisioningState.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResourceProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armversioned-generated/proxy-config.json create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armversioned-generated/reflect-config.json create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-armversioned-generated.properties create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourceInnerTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourceListResultTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourcePropertiesTests.java diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/ArmVersionedManager.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/ArmVersionedManager.java new file mode 100644 index 00000000000..316d4b6e8e4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/ArmVersionedManager.java @@ -0,0 +1,282 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import tsptest.armversioned.fluent.ArmVersionedClient; +import tsptest.armversioned.implementation.ArmVersionedClientBuilder; +import tsptest.armversioned.implementation.TopLevelArmResourcesImpl; +import tsptest.armversioned.models.TopLevelArmResources; + +/** + * Entry point to ArmVersionedManager. + * Arm Resource Provider management API. + */ +public final class ArmVersionedManager { + private TopLevelArmResources topLevelArmResources; + + private final ArmVersionedClient clientObject; + + private ArmVersionedManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new ArmVersionedClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of ArmVersioned service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ArmVersioned service API instance. + */ + public static ArmVersionedManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of ArmVersioned service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the ArmVersioned service API instance. + */ + public static ArmVersionedManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ArmVersionedManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ArmVersionedManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ArmVersionedManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-armversioned-generated.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of ArmVersioned service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ArmVersioned service API instance. + */ + public ArmVersionedManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("tsptest.armversioned") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new ArmVersionedManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of TopLevelArmResources. It manages TopLevelArmResource. + * + * @return Resource collection API of TopLevelArmResources. + */ + public TopLevelArmResources topLevelArmResources() { + if (this.topLevelArmResources == null) { + this.topLevelArmResources = new TopLevelArmResourcesImpl(clientObject.getTopLevelArmResources(), this); + } + return topLevelArmResources; + } + + /** + * Gets wrapped service client ArmVersionedClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client ArmVersionedClient. + */ + public ArmVersionedClient serviceClient() { + return this.clientObject; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/ArmVersionedClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/ArmVersionedClient.java new file mode 100644 index 00000000000..0c52b974851 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/ArmVersionedClient.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for ArmVersionedClient class. + */ +public interface ArmVersionedClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the TopLevelArmResourcesClient object to access its operations. + * + * @return the TopLevelArmResourcesClient object. + */ + TopLevelArmResourcesClient getTopLevelArmResources(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java new file mode 100644 index 00000000000..b9ae081b543 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; + +/** + * An instance of this class provides access to all the operations defined in TopLevelArmResourcesClient. + */ +public interface TopLevelArmResourcesClient { + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource); + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, String newParameter, Context context); + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource); + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String parameter, String newParameter, Context context); + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context); + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void action(String resourceGroupName, String topLevelArmResourcePropertiesName); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/models/TopLevelArmResourceInner.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/models/TopLevelArmResourceInner.java new file mode 100644 index 00000000000..54adc39e6a9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/models/TopLevelArmResourceInner.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; +import tsptest.armversioned.models.TopLevelArmResourceProperties; + +/** + * Concrete tracked resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class TopLevelArmResourceInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private TopLevelArmResourceProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of TopLevelArmResourceInner class. + */ + public TopLevelArmResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public TopLevelArmResourceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the TopLevelArmResourceInner object itself. + */ + public TopLevelArmResourceInner withProperties(TopLevelArmResourceProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public TopLevelArmResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public TopLevelArmResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TopLevelArmResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopLevelArmResourceInner if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TopLevelArmResourceInner. + */ + public static TopLevelArmResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopLevelArmResourceInner deserializedTopLevelArmResourceInner = new TopLevelArmResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedTopLevelArmResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedTopLevelArmResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedTopLevelArmResourceInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedTopLevelArmResourceInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedTopLevelArmResourceInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedTopLevelArmResourceInner.properties = TopLevelArmResourceProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedTopLevelArmResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedTopLevelArmResourceInner; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/models/package-info.java new file mode 100644 index 00000000000..efa70b16308 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for ArmVersioned. + * Arm Resource Provider management API. + */ +package tsptest.armversioned.fluent.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/package-info.java new file mode 100644 index 00000000000..304185e7846 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for ArmVersioned. + * Arm Resource Provider management API. + */ +package tsptest.armversioned.fluent; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ArmVersionedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ArmVersionedClientBuilder.java new file mode 100644 index 00000000000..6498c099e69 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ArmVersionedClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the ArmVersionedClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { ArmVersionedClientImpl.class }) +public final class ArmVersionedClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the ArmVersionedClientBuilder. + */ + public ArmVersionedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the ArmVersionedClientBuilder. + */ + public ArmVersionedClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the ArmVersionedClientBuilder. + */ + public ArmVersionedClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the ArmVersionedClientBuilder. + */ + public ArmVersionedClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the ArmVersionedClientBuilder. + */ + public ArmVersionedClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the ArmVersionedClientBuilder. + */ + public ArmVersionedClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ArmVersionedClientImpl with the provided parameters. + * + * @return an instance of ArmVersionedClientImpl. + */ + public ArmVersionedClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + ArmVersionedClientImpl client = new ArmVersionedClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java new file mode 100644 index 00000000000..60ee7879dcf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import tsptest.armversioned.fluent.ArmVersionedClient; +import tsptest.armversioned.fluent.TopLevelArmResourcesClient; + +/** + * Initializes a new instance of the ArmVersionedClientImpl type. + */ +@ServiceClient(builder = ArmVersionedClientBuilder.class) +public final class ArmVersionedClientImpl implements ArmVersionedClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The TopLevelArmResourcesClient object to access its operations. + */ + private final TopLevelArmResourcesClient topLevelArmResources; + + /** + * Gets the TopLevelArmResourcesClient object to access its operations. + * + * @return the TopLevelArmResourcesClient object. + */ + public TopLevelArmResourcesClient getTopLevelArmResources() { + return this.topLevelArmResources; + } + + /** + * Initializes an instance of ArmVersionedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + ArmVersionedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2024-12-01"; + this.topLevelArmResources = new TopLevelArmResourcesClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, () -> activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ArmVersionedClientImpl.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ResourceManagerUtils.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ResourceManagerUtils.java new file mode 100644 index 00000000000..f52d86253ad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java new file mode 100644 index 00000000000..0d4654dd035 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.implementation; + +import com.azure.core.http.rest.Response; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Collections; +import java.util.Map; +import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; +import tsptest.armversioned.models.TopLevelArmResource; +import tsptest.armversioned.models.TopLevelArmResourceProperties; + +public final class TopLevelArmResourceImpl + implements TopLevelArmResource, TopLevelArmResource.Definition, TopLevelArmResource.Update { + private TopLevelArmResourceInner innerObject; + + private final tsptest.armversioned.ArmVersionedManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public TopLevelArmResourceProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public TopLevelArmResourceInner innerModel() { + return this.innerObject; + } + + private tsptest.armversioned.ArmVersionedManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String topLevelArmResourcePropertiesName; + + private String createParameter; + + private String createNewParameter; + + private String updateParameter; + + private String updateNewParameter; + + public TopLevelArmResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public TopLevelArmResource create() { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResources() + .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, + createNewParameter, Context.NONE); + return this; + } + + public TopLevelArmResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResources() + .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, + createNewParameter, context); + return this; + } + + TopLevelArmResourceImpl(String name, tsptest.armversioned.ArmVersionedManager serviceManager) { + this.innerObject = new TopLevelArmResourceInner(); + this.serviceManager = serviceManager; + this.topLevelArmResourcePropertiesName = name; + this.createParameter = null; + this.createNewParameter = null; + } + + public TopLevelArmResourceImpl update() { + this.updateParameter = null; + this.updateNewParameter = null; + return this; + } + + public TopLevelArmResource apply() { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResources() + .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, + updateNewParameter, Context.NONE); + return this; + } + + public TopLevelArmResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResources() + .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, + updateNewParameter, context); + return this; + } + + TopLevelArmResourceImpl(TopLevelArmResourceInner innerObject, + tsptest.armversioned.ArmVersionedManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.topLevelArmResourcePropertiesName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "topLevelArmResources"); + } + + public Response actionWithResponse(String parameter, String newParameter, Context context) { + return serviceManager.topLevelArmResources() + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); + } + + public void action() { + serviceManager.topLevelArmResources().action(resourceGroupName, topLevelArmResourcePropertiesName); + } + + public TopLevelArmResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public TopLevelArmResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public TopLevelArmResourceImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public TopLevelArmResourceImpl withProperties(TopLevelArmResourceProperties properties) { + this.innerModel().withProperties(properties); + return this; + } + + public TopLevelArmResourceImpl withParameter(String parameter) { + if (isInCreateMode()) { + this.createParameter = parameter; + return this; + } else { + this.updateParameter = parameter; + return this; + } + } + + public TopLevelArmResourceImpl withNewParameter(String newParameter) { + if (isInCreateMode()) { + this.createNewParameter = newParameter; + return this; + } else { + this.updateNewParameter = newParameter; + return this; + } + } + + private boolean isInCreateMode() { + return this.innerModel() == null || this.innerModel().id() == null; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java new file mode 100644 index 00000000000..ec992783194 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -0,0 +1,696 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import tsptest.armversioned.fluent.TopLevelArmResourcesClient; +import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; +import tsptest.armversioned.implementation.models.TopLevelArmResourceListResult; + +/** + * An instance of this class provides access to all the operations defined in TopLevelArmResourcesClient. + */ +public final class TopLevelArmResourcesClientImpl implements TopLevelArmResourcesClient { + /** + * The proxy service used to perform REST calls. + */ + private final TopLevelArmResourcesService service; + + /** + * The service client containing this operation class. + */ + private final ArmVersionedClientImpl client; + + /** + * Initializes an instance of TopLevelArmResourcesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + TopLevelArmResourcesClientImpl(ArmVersionedClientImpl client) { + this.service = RestProxy.create(TopLevelArmResourcesService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArmVersionedClientTopLevelArmResources to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArmVersionedClientTopLevelArmResources") + public interface TopLevelArmResourcesService { + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") TopLevelArmResourceInner resource, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") TopLevelArmResourceInner resource, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/TspTest.ArmVersioned/topLevelArmResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/TspTest.ArmVersioned/topLevelArmResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}/action") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> action(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}/action") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response actionSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listBySubscriptionNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, + String newParameter) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, + String newParameter) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, contentType, accept, resource, Context.NONE); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, + String newParameter, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, contentType, accept, resource, context); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelArmResourceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, String newParameter) { + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, + topLevelArmResourcePropertiesName, resource, parameter, newParameter); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, + this.client.getContext()); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, TopLevelArmResourceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource) { + final String parameter = null; + final String newParameter = null; + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, + topLevelArmResourcePropertiesName, resource, parameter, newParameter); + return this.client.getLroResult(mono, + this.client.getHttpPipeline(), TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, + this.client.getContext()); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, String newParameter) { + Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, + resource, parameter, newParameter); + return this.client.getLroResult(response, + TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, Context.NONE); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource) { + final String parameter = null; + final String newParameter = null; + Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, + resource, parameter, newParameter); + return this.client.getLroResult(response, + TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, Context.NONE); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, String newParameter, Context context) { + Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, + resource, parameter, newParameter, context); + return this.client.getLroResult(response, + TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, + String newParameter) { + return beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, + newParameter).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource) { + final String parameter = null; + final String newParameter = null; + return beginCreateOrUpdateAsync(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, + newParameter).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource) { + final String parameter = null; + final String newParameter = null; + return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, + newParameter).getFinalResult(); + } + + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource, String parameter, String newParameter, Context context) { + return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, + newParameter, context).getFinalResult(); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(String parameter, String newParameter) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), parameter, newParameter, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(String parameter, String newParameter) { + return new PagedFlux<>(() -> listSinglePageAsync(parameter, newParameter), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + final String parameter = null; + final String newParameter = null; + return new PagedFlux<>(() -> listSinglePageAsync(parameter, newParameter), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String parameter, String newParameter) { + final String accept = "application/json"; + Response res + = service.listSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + parameter, newParameter, accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String parameter, String newParameter, + Context context) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), parameter, newParameter, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + final String parameter = null; + final String newParameter = null; + return new PagedIterable<>(() -> listSinglePage(parameter, newParameter), + nextLink -> listBySubscriptionNextSinglePage(nextLink)); + } + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String parameter, String newParameter, Context context) { + return new PagedIterable<>(() -> listSinglePage(parameter, newParameter, context), + nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); + } + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> actionWithResponseAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter) { + return FluxUtil + .withContext(context -> service.action(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono actionAsync(String resourceGroupName, String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + return actionWithResponseAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter) + .flatMap(ignored -> Mono.empty()); + } + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context) { + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void action(String resourceGroupName, String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, Context.NONE); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listBySubscriptionNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listBySubscriptionNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listBySubscriptionNextSinglePage(String nextLink, Context context) { + final String accept = "application/json"; + Response res + = service.listBySubscriptionNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java new file mode 100644 index 00000000000..939c9182d96 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import tsptest.armversioned.fluent.TopLevelArmResourcesClient; +import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; +import tsptest.armversioned.models.TopLevelArmResource; +import tsptest.armversioned.models.TopLevelArmResources; + +public final class TopLevelArmResourcesImpl implements TopLevelArmResources { + private static final ClientLogger LOGGER = new ClientLogger(TopLevelArmResourcesImpl.class); + + private final TopLevelArmResourcesClient innerClient; + + private final tsptest.armversioned.ArmVersionedManager serviceManager; + + public TopLevelArmResourcesImpl(TopLevelArmResourcesClient innerClient, + tsptest.armversioned.ArmVersionedManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(String parameter, String newParameter, Context context) { + PagedIterable inner = this.serviceClient().list(parameter, newParameter, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context) { + return this.serviceClient() + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); + } + + public void action(String resourceGroupName, String topLevelArmResourcePropertiesName) { + this.serviceClient().action(resourceGroupName, topLevelArmResourcePropertiesName); + } + + private TopLevelArmResourcesClient serviceClient() { + return this.innerClient; + } + + private tsptest.armversioned.ArmVersionedManager manager() { + return this.serviceManager; + } + + public TopLevelArmResourceImpl define(String name) { + return new TopLevelArmResourceImpl(name, this.manager()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/models/TopLevelArmResourceListResult.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/models/TopLevelArmResourceListResult.java new file mode 100644 index 00000000000..89c6c334369 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/models/TopLevelArmResourceListResult.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; + +/** + * The response of a TopLevelArmResource list operation. + */ +@Immutable +public final class TopLevelArmResourceListResult implements JsonSerializable { + /* + * The TopLevelArmResource items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of TopLevelArmResourceListResult class. + */ + private TopLevelArmResourceListResult() { + } + + /** + * Get the value property: The TopLevelArmResource items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TopLevelArmResourceListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopLevelArmResourceListResult if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TopLevelArmResourceListResult. + */ + public static TopLevelArmResourceListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopLevelArmResourceListResult deserializedTopLevelArmResourceListResult + = new TopLevelArmResourceListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> TopLevelArmResourceInner.fromJson(reader1)); + deserializedTopLevelArmResourceListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedTopLevelArmResourceListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedTopLevelArmResourceListResult; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/package-info.java new file mode 100644 index 00000000000..414dcf31448 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for ArmVersioned. + * Arm Resource Provider management API. + */ +package tsptest.armversioned.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/ResourceProvisioningState.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/ResourceProvisioningState.java new file mode 100644 index 00000000000..2ebeed742f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/ResourceProvisioningState.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The provisioning state of a resource type. + */ +public final class ResourceProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ResourceProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ResourceProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ResourceProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ResourceProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ResourceProvisioningState() { + } + + /** + * Creates or finds a ResourceProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResourceProvisioningState. + */ + public static ResourceProvisioningState fromString(String name) { + return fromString(name, ResourceProvisioningState.class); + } + + /** + * Gets known ResourceProvisioningState values. + * + * @return known ResourceProvisioningState values. + */ + public static Collection values() { + return values(ResourceProvisioningState.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java new file mode 100644 index 00000000000..48b1e22b1fe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -0,0 +1,326 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Map; +import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; + +/** + * An immutable client-side representation of TopLevelArmResource. + */ +public interface TopLevelArmResource { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + TopLevelArmResourceProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner tsptest.armversioned.fluent.models.TopLevelArmResourceInner object. + * + * @return the inner object. + */ + TopLevelArmResourceInner innerModel(); + + /** + * The entirety of the TopLevelArmResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The TopLevelArmResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the TopLevelArmResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the TopLevelArmResource definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the TopLevelArmResource definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the TopLevelArmResource definition which contains all the minimum required properties for the + * resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties, + DefinitionStages.WithParameter, DefinitionStages.WithNewParameter { + /** + * Executes the create request. + * + * @return the created resource. + */ + TopLevelArmResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + TopLevelArmResource create(Context context); + } + + /** + * The stage of the TopLevelArmResource definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the TopLevelArmResource definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(TopLevelArmResourceProperties properties); + } + + /** + * The stage of the TopLevelArmResource definition allowing to specify parameter. + */ + interface WithParameter { + /** + * Specifies the parameter property: The parameter parameter. + * + * @param parameter The parameter parameter. + * @return the next definition stage. + */ + WithCreate withParameter(String parameter); + } + + /** + * The stage of the TopLevelArmResource definition allowing to specify newParameter. + */ + interface WithNewParameter { + /** + * Specifies the newParameter property: The newParameter parameter. + * + * @param newParameter The newParameter parameter. + * @return the next definition stage. + */ + WithCreate withNewParameter(String newParameter); + } + } + + /** + * Begins update for the TopLevelArmResource resource. + * + * @return the stage of resource update. + */ + TopLevelArmResource.Update update(); + + /** + * The template for TopLevelArmResource update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties, UpdateStages.WithParameter, + UpdateStages.WithNewParameter { + /** + * Executes the update request. + * + * @return the updated resource. + */ + TopLevelArmResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + TopLevelArmResource apply(Context context); + } + + /** + * The TopLevelArmResource update stages. + */ + interface UpdateStages { + /** + * The stage of the TopLevelArmResource update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the TopLevelArmResource update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(TopLevelArmResourceProperties properties); + } + + /** + * The stage of the TopLevelArmResource update allowing to specify parameter. + */ + interface WithParameter { + /** + * Specifies the parameter property: The parameter parameter. + * + * @param parameter The parameter parameter. + * @return the next definition stage. + */ + Update withParameter(String parameter); + } + + /** + * The stage of the TopLevelArmResource update allowing to specify newParameter. + */ + interface WithNewParameter { + /** + * Specifies the newParameter property: The newParameter parameter. + * + * @param newParameter The newParameter parameter. + * @return the next definition stage. + */ + Update withNewParameter(String newParameter); + } + } + + /** + * A synchronous resource action. + * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response actionWithResponse(String parameter, String newParameter, Context context); + + /** + * A synchronous resource action. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void action(); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResourceProperties.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResourceProperties.java new file mode 100644 index 00000000000..4cf68776cea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResourceProperties.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Top Level Arm Resource Properties. + */ +@Immutable +public final class TopLevelArmResourceProperties implements JsonSerializable { + /* + * The provisioningState property. + */ + private ResourceProvisioningState provisioningState; + + /** + * Creates an instance of TopLevelArmResourceProperties class. + */ + public TopLevelArmResourceProperties() { + } + + /** + * Get the provisioningState property: The provisioningState property. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TopLevelArmResourceProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TopLevelArmResourceProperties if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the TopLevelArmResourceProperties. + */ + public static TopLevelArmResourceProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + TopLevelArmResourceProperties deserializedTopLevelArmResourceProperties + = new TopLevelArmResourceProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedTopLevelArmResourceProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedTopLevelArmResourceProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java new file mode 100644 index 00000000000..6bbc222bfbd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of TopLevelArmResources. + */ +public interface TopLevelArmResources { + /** + * List TopLevelArmResource resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(String parameter, String newParameter, Context context); + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context); + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void action(String resourceGroupName, String topLevelArmResourcePropertiesName); + + /** + * Begins definition for a new TopLevelArmResource resource. + * + * @param name resource name. + * @return the first stage of the new TopLevelArmResource definition. + */ + TopLevelArmResource.DefinitionStages.Blank define(String name); +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/package-info.java new file mode 100644 index 00000000000..aca33de66ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for ArmVersioned. + * Arm Resource Provider management API. + */ +package tsptest.armversioned.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/package-info.java new file mode 100644 index 00000000000..b306aaf7b89 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for ArmVersioned. + * Arm Resource Provider management API. + */ +package tsptest.armversioned; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json new file mode 100644 index 00000000000..496a507b97a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json @@ -0,0 +1,17 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "tsptest.armversioned.fluent.ArmVersionedClient": "TspTest.ArmVersioned", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient": "TspTest.ArmVersioned.TopLevelArmResources", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.action": "TspTest.ArmVersioned.TopLevelArmResources.action", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.actionWithResponse": "TspTest.ArmVersioned.TopLevelArmResources.action", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginCreateOrUpdate": "TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.createOrUpdate": "TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.list": "TspTest.ArmVersioned.TopLevelArmResources.listBySubscription", + "tsptest.armversioned.fluent.models.TopLevelArmResourceInner": "TspTest.ArmVersioned.TopLevelArmResource", + "tsptest.armversioned.implementation.ArmVersionedClientBuilder": "TspTest.ArmVersioned", + "tsptest.armversioned.implementation.models.TopLevelArmResourceListResult": "Azure.ResourceManager.ResourceListResult", + "tsptest.armversioned.models.ResourceProvisioningState": "Azure.ResourceManager.ResourceProvisioningState", + "tsptest.armversioned.models.TopLevelArmResourceProperties": "TspTest.ArmVersioned.TopLevelArmResourceProperties" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json new file mode 100644 index 00000000000..3bad5e67907 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json @@ -0,0 +1 @@ +{"flavor":"Azure","apiVersion":"2024-12-01","crossLanguageDefinitions":{"tsptest.armversioned.fluent.ArmVersionedClient":"TspTest.ArmVersioned","tsptest.armversioned.fluent.TopLevelArmResourcesClient":"TspTest.ArmVersioned.TopLevelArmResources","tsptest.armversioned.fluent.TopLevelArmResourcesClient.action":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.actionWithResponse":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginCreateOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.createOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.list":"TspTest.ArmVersioned.TopLevelArmResources.listBySubscription","tsptest.armversioned.fluent.models.TopLevelArmResourceInner":"TspTest.ArmVersioned.TopLevelArmResource","tsptest.armversioned.implementation.ArmVersionedClientBuilder":"TspTest.ArmVersioned","tsptest.armversioned.implementation.models.TopLevelArmResourceListResult":"Azure.ResourceManager.ResourceListResult","tsptest.armversioned.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","tsptest.armversioned.models.TopLevelArmResourceProperties":"TspTest.ArmVersioned.TopLevelArmResourceProperties"},"generatedFiles":["src/main/java/module-info.java","src/main/java/tsptest/armversioned/ArmVersionedManager.java","src/main/java/tsptest/armversioned/fluent/ArmVersionedClient.java","src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java","src/main/java/tsptest/armversioned/fluent/models/TopLevelArmResourceInner.java","src/main/java/tsptest/armversioned/fluent/models/package-info.java","src/main/java/tsptest/armversioned/fluent/package-info.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientBuilder.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java","src/main/java/tsptest/armversioned/implementation/ResourceManagerUtils.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java","src/main/java/tsptest/armversioned/implementation/models/TopLevelArmResourceListResult.java","src/main/java/tsptest/armversioned/implementation/package-info.java","src/main/java/tsptest/armversioned/models/ResourceProvisioningState.java","src/main/java/tsptest/armversioned/models/TopLevelArmResource.java","src/main/java/tsptest/armversioned/models/TopLevelArmResourceProperties.java","src/main/java/tsptest/armversioned/models/TopLevelArmResources.java","src/main/java/tsptest/armversioned/models/package-info.java","src/main/java/tsptest/armversioned/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armversioned-generated/proxy-config.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armversioned-generated/proxy-config.json new file mode 100644 index 00000000000..12fd27ce30c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armversioned-generated/proxy-config.json @@ -0,0 +1 @@ +[["tsptest.armversioned.implementation.TopLevelArmResourcesClientImpl$TopLevelArmResourcesService"]] \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armversioned-generated/reflect-config.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armversioned-generated/reflect-config.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armversioned-generated/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-armversioned-generated.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-armversioned-generated.properties new file mode 100644 index 00000000000..defbd48204e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/azure-resourcemanager-armversioned-generated.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourceInnerTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourceInnerTests.java new file mode 100644 index 00000000000..c0f8f2fc1ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourceInnerTests.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.generated; + +import com.azure.core.util.BinaryData; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; +import tsptest.armversioned.models.TopLevelArmResourceProperties; + +public final class TopLevelArmResourceInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TopLevelArmResourceInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Succeeded\"},\"location\":\"uv\",\"tags\":{\"phrupidgsybbejhp\":\"pybczmehmtzopb\"},\"id\":\"oycmsxaobhdxbmt\",\"name\":\"ioq\",\"type\":\"zehtbmu\"}") + .toObject(TopLevelArmResourceInner.class); + Assertions.assertEquals("uv", model.location()); + Assertions.assertEquals("pybczmehmtzopb", model.tags().get("phrupidgsybbejhp")); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TopLevelArmResourceInner model = new TopLevelArmResourceInner().withLocation("uv") + .withTags(mapOf("phrupidgsybbejhp", "pybczmehmtzopb")) + .withProperties(new TopLevelArmResourceProperties()); + model = BinaryData.fromObject(model).toObject(TopLevelArmResourceInner.class); + Assertions.assertEquals("uv", model.location()); + Assertions.assertEquals("pybczmehmtzopb", model.tags().get("phrupidgsybbejhp")); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourceListResultTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourceListResultTests.java new file mode 100644 index 00000000000..bc7524675a2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourceListResultTests.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.generated; + +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.Assertions; +import tsptest.armversioned.implementation.models.TopLevelArmResourceListResult; + +public final class TopLevelArmResourceListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TopLevelArmResourceListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"provisioningState\":\"Failed\"},\"location\":\"hwlrx\",\"tags\":{\"dmbpazlobcufpdz\":\"soqijg\",\"qqjnqgl\":\"rbt\",\"foooj\":\"qgn\"},\"id\":\"wifsq\",\"name\":\"saagdf\",\"type\":\"glzlhjxrifkwmrv\"}],\"nextLink\":\"siznto\"}") + .toObject(TopLevelArmResourceListResult.class); + Assertions.assertEquals("hwlrx", model.value().get(0).location()); + Assertions.assertEquals("soqijg", model.value().get(0).tags().get("dmbpazlobcufpdz")); + Assertions.assertEquals("siznto", model.nextLink()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourcePropertiesTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourcePropertiesTests.java new file mode 100644 index 00000000000..fe3644035e9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/generated/TopLevelArmResourcePropertiesTests.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armversioned.generated; + +import com.azure.core.util.BinaryData; +import tsptest.armversioned.models.TopLevelArmResourceProperties; + +public final class TopLevelArmResourcePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TopLevelArmResourceProperties model = BinaryData.fromString("{\"provisioningState\":\"Canceled\"}") + .toObject(TopLevelArmResourceProperties.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TopLevelArmResourceProperties model = new TopLevelArmResourceProperties(); + model = BinaryData.fromObject(model).toObject(TopLevelArmResourceProperties.class); + } +} From 0aa271ab052618cfad0471eaabbf59e7534e1d25 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 18 Nov 2025 16:15:58 +0800 Subject: [PATCH 13/50] advanced versioning for arm-versioned test --- .../generator/http-client-generator-test/Generate.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 index d344a462f98..2ca6a7e0283 100644 --- a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 +++ b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 @@ -107,6 +107,9 @@ $generateScript = { $tspOptions += " --option ""@typespec/http-client-java.generate-tests=false""" # add customization code $tspOptions += " --option ""@typespec/http-client-java.customization-class=../../customization/src/main/java/KeyVaultCustomization.java""" + } elseif ($tspFile -match "tsp[\\/]arm-versioned.tsp") { + # enable advanced versioning for resiliency test + $tspOptions += " --option ""@typespec/http-client-java.advanced-versioning=true""" } elseif ($tspFile -match "tsp[\\/]subclient.tsp") { $tspOptions += " --option ""@typespec/http-client-java.enable-subclient=true""" # test for include-api-view-properties From 5e17044594001b8930d85b0b61fe33244a181e9c Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 18 Nov 2025 16:30:35 +0800 Subject: [PATCH 14/50] regen with advanced-versioning --- .../fluent/TopLevelArmResourcesClient.java | 48 +++++++++++++++ .../TopLevelArmResourceImpl.java | 5 ++ .../TopLevelArmResourcesClientImpl.java | 61 +++++++++++++++++++ .../TopLevelArmResourcesImpl.java | 11 ++++ .../models/TopLevelArmResource.java | 12 ++++ .../models/TopLevelArmResources.java | 27 ++++++++ 6 files changed, 164 insertions(+) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java index b9ae081b543..c03819d2a36 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -17,6 +17,25 @@ * An instance of this class provides access to all the operations defined in TopLevelArmResourcesClient. */ public interface TopLevelArmResourcesClient { + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, Context context); + /** * Create a TopLevelArmResource. * @@ -86,6 +105,19 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String parameter, Context context); + /** * List TopLevelArmResource resources by subscription ID. * @@ -110,6 +142,22 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve @ServiceMethod(returns = ReturnType.COLLECTION) PagedIterable list(String parameter, String newParameter, Context context); + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java index 0d4654dd035..5e802b42faf 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -145,6 +145,11 @@ public TopLevelArmResource apply(Context context) { = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "topLevelArmResources"); } + public Response actionWithResponse(String parameter, Context context) { + return serviceManager.topLevelArmResources() + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + public Response actionWithResponse(String parameter, String newParameter, Context context) { return serviceManager.topLevelArmResources() .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java index ec992783194..19159871fc6 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -301,6 +301,30 @@ public SyncPoller, TopLevelArmResourceInner TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, Context.NONE); } + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, Context context) { + Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, + resource, parameter, context); + return this.client.getLroResult(response, + TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); + } + /** * Create a TopLevelArmResource. * @@ -527,6 +551,22 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String parameter, Context context) { + return new PagedIterable<>(() -> listSinglePage(parameter, context), + nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); + } + /** * List TopLevelArmResource resources by subscription ID. * @@ -599,6 +639,27 @@ private Mono actionAsync(String resourceGroupName, String topLevelArmResou .flatMap(ignored -> Mono.empty()); } + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + final String newParameter = null; + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java index 939c9182d96..eece1e1bf8a 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -26,6 +26,11 @@ public TopLevelArmResourcesImpl(TopLevelArmResourcesClient innerClient, this.serviceManager = serviceManager; } + public PagedIterable list(String parameter, Context context) { + PagedIterable inner = this.serviceClient().list(parameter, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); @@ -36,6 +41,12 @@ public PagedIterable list(String parameter, String newParam return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + return this.serviceClient() + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { return this.serviceClient() diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java index 48b1e22b1fe..0d732398d29 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -303,6 +303,18 @@ interface WithNewParameter { } } + /** + * A synchronous resource action. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response actionWithResponse(String parameter, Context context); + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java index 6bbc222bfbd..8f674319d57 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -12,6 +12,18 @@ * Resource collection API of TopLevelArmResources. */ public interface TopLevelArmResources { + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(String parameter, Context context); + /** * List TopLevelArmResource resources by subscription ID. * @@ -34,6 +46,21 @@ public interface TopLevelArmResources { */ PagedIterable list(String parameter, String newParameter, Context context); + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); + /** * A synchronous resource action. * From a61c34a57312cf009bcaf8400ea4fc787d07198a Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 18 Nov 2025 16:43:12 +0800 Subject: [PATCH 15/50] test --- .../armversioned/ArmVersionedTests.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java new file mode 100644 index 00000000000..662bb9bd95a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package tsptest.armversioned; + +import com.azure.core.util.Context; +import org.mockito.Mockito; +import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; + +public class ArmVersionedTests { + + // only to test compilation + public void testVersionedApi() { + ArmVersionedManager manager = Mockito.mock(ArmVersionedManager.class); + TopLevelArmResourceInner resource = Mockito.mock(TopLevelArmResourceInner.class); + + // API without optional parameter + // this API exists in all versions + manager.serviceClient().getTopLevelArmResources().createOrUpdate("resourceGroup", "resourceName", resource); + manager.topLevelArmResources().list(); + manager.topLevelArmResources().action("resourceGroup", "resourceName"); + + // API in 2024-12-01 + manager.serviceClient() + .getTopLevelArmResources() + .createOrUpdate("resourceGroup", "resourceName", resource, "parameter", "newParameter", Context.NONE); + manager.topLevelArmResources().list("parameter", "newParameter", Context.NONE); + manager.topLevelArmResources() + .actionWithResponse("resourceGroup", "resourceName", "parameter", "newParameter", Context.NONE); + + // API in 2023-12-01 + // this op will be generated, if tspconfig has "advanced-versioning" option + // REST API allow adding optional parameter to operation + manager.serviceClient() + .getTopLevelArmResources() + .createOrUpdate("resourceGroup", "resourceName", resource, "parameter", Context.NONE); + manager.topLevelArmResources().list("parameter", Context.NONE); + manager.topLevelArmResources().actionWithResponse("resourceGroup", "resourceName", "parameter", Context.NONE); + } +} From 0fa3f3314508aa93b71123117b134271f0d1da31 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 11:41:34 +0800 Subject: [PATCH 16/50] update addOptionalVariables --- .../core/template/ClientMethodTemplate.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index 071229d253c..8b4a84f1e1a 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -115,18 +115,28 @@ protected static void addValidations(JavaBlock function, ClientMethod clientMeth * @param clientMethod The client method. */ protected static void addOptionalVariables(JavaBlock function, ClientMethod clientMethod) { - if (!clientMethod.getOnlyRequiredParameters()) { - return; - } + final List proxyMethodParameters = clientMethod.getProxyMethod().getParameters(); + List methodParameters + = MethodUtil.getParameters(clientMethod, false); - for (ClientMethodParameter parameter : clientMethod.getMethodParameters()) { - if (parameter.isRequired()) { - // Parameter is required and will be part of the method signature. - continue; + for (ProxyMethodParameter parameter : proxyMethodParameters) { + boolean optionalOmitted = !parameter.isRequired() && parameter.getClientType() != ClassType.CONTEXT; + if (optionalOmitted) { + boolean parameterInClientMethodSignature = methodParameters.stream() + .filter(p -> p.getProxyMethodParameter() == parameter) + .findFirst() + .map(p -> p.getClientMethodParameter()) + .isPresent(); + // if the parameter is defined in client method signature, + // it does not need to be instantiated in local variable. + optionalOmitted = !parameterInClientMethodSignature; + } + + if (optionalOmitted) { + final String defaultValue = parameterDefaultValueExpression(parameter); + function.line("final %s %s = %s;", parameter.getClientType(), parameter.getName(), + defaultValue == null ? "null" : defaultValue); } - final String defaultValue = parameterDefaultValueExpression(parameter); - function.line("final %s %s = %s;", parameter.getClientType(), parameter.getName(), - defaultValue == null ? "null" : defaultValue); } } From b4fa958b90be6834fd62da63dc328ad541766515 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 11:48:50 +0800 Subject: [PATCH 17/50] Revert "update addOptionalVariables" This reverts commit 0fa3f3314508aa93b71123117b134271f0d1da31. --- .../core/template/ClientMethodTemplate.java | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index 8b4a84f1e1a..071229d253c 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -115,28 +115,18 @@ protected static void addValidations(JavaBlock function, ClientMethod clientMeth * @param clientMethod The client method. */ protected static void addOptionalVariables(JavaBlock function, ClientMethod clientMethod) { - final List proxyMethodParameters = clientMethod.getProxyMethod().getParameters(); - List methodParameters - = MethodUtil.getParameters(clientMethod, false); - - for (ProxyMethodParameter parameter : proxyMethodParameters) { - boolean optionalOmitted = !parameter.isRequired() && parameter.getClientType() != ClassType.CONTEXT; - if (optionalOmitted) { - boolean parameterInClientMethodSignature = methodParameters.stream() - .filter(p -> p.getProxyMethodParameter() == parameter) - .findFirst() - .map(p -> p.getClientMethodParameter()) - .isPresent(); - // if the parameter is defined in client method signature, - // it does not need to be instantiated in local variable. - optionalOmitted = !parameterInClientMethodSignature; - } + if (!clientMethod.getOnlyRequiredParameters()) { + return; + } - if (optionalOmitted) { - final String defaultValue = parameterDefaultValueExpression(parameter); - function.line("final %s %s = %s;", parameter.getClientType(), parameter.getName(), - defaultValue == null ? "null" : defaultValue); + for (ClientMethodParameter parameter : clientMethod.getMethodParameters()) { + if (parameter.isRequired()) { + // Parameter is required and will be part of the method signature. + continue; } + final String defaultValue = parameterDefaultValueExpression(parameter); + function.line("final %s %s = %s;", parameter.getClientType(), parameter.getName(), + defaultValue == null ? "null" : defaultValue); } } From d8f7ed45f9be74a2252e36ae7b9c1996f0847991 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 11:49:26 +0800 Subject: [PATCH 18/50] overload for LRO createOrUpdate in mgmt --- .../http/client/generator/core/mapper/ClientMethodMapper.java | 2 +- .../generator/mgmt/mapper/FluentClientMethodMapper.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index 341cab69e77..8a036e07211 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -355,7 +355,7 @@ private static JavaVisibility methodVisibilityInWrapperClient(Operation operatio } } - private void createOverloadForVersioning(List methods, ClientMethod baseMethod, + protected void createOverloadForVersioning(List methods, ClientMethod baseMethod, JavaVisibility methodWithContextVisibility, MethodPageDetails methodPageDetailsWithContext, boolean isProtocolMethod) { final ClientMethodType clientMethodType = baseMethod.getType(); diff --git a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/mapper/FluentClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/mapper/FluentClientMethodMapper.java index 2d136d7ffcc..cdf504ea502 100644 --- a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/mapper/FluentClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/mapper/FluentClientMethodMapper.java @@ -135,6 +135,10 @@ private void createLroGetFinalResultClientMethods(boolean isSync, ClientMethod b .build(); methods.add(lroGetFinalResultMethod); + // LRO '[Operation]' sync or async method overloads with versioning (for management). + createOverloadForVersioning(methods, lroGetFinalResultMethod, methodWithContextVisibility, null, + isProtocolMethod); + if (generateRequiredOnlyParametersOverload) { final ClientMethod lroGetFinalResultMethodWithRequiredOnlyParameters = lroGetFinalResultMethod.newBuilder() .onlyRequiredParameters(true) From ffb4c8891aec1619c19d53a752147b5e932c1495 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 13:08:53 +0800 Subject: [PATCH 19/50] overload for method for lro and pageable --- .../client/generator/core/mapper/ClientMethodMapper.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index 8a036e07211..371b3664d39 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -474,6 +474,8 @@ private void createSinglePageClientMethods(boolean isSync, ClientMethod baseMeth methods.add(singlePageMethod); } + createOverloadForVersioning(methods, singlePageMethod, methodWithContextVisibility, null, isProtocolMethod); + // Generate '[Operation]SinglePage' overload with all parameters and Context. addClientMethodWithContext(methods, singlePageMethod, methodWithContextVisibility, isProtocolMethod); } @@ -594,6 +596,9 @@ private void createLroWithResponseClientMethods(boolean isSync, ClientMethod bas .hasWithContextOverload(methodWithContextVisibility != NOT_GENERATE) .build(); methods.add(withResponseMethod); + + createOverloadForVersioning(methods, withResponseMethod, methodWithContextVisibility, null, isProtocolMethod); + addClientMethodWithContext(methods, withResponseMethod, methodWithContextVisibility, isProtocolMethod); } @@ -633,6 +638,9 @@ private void createFluentLroWithResponseSyncClientMethods(Operation operation, C .methodVisibility(NOT_VISIBLE) .build(); methods.add(withResponseSyncMethod); + + createOverloadForVersioning(methods, withResponseSyncMethod, NOT_VISIBLE, null, isProtocolMethod); + addClientMethodWithContext(methods, withResponseSyncMethod, NOT_VISIBLE, isProtocolMethod); } From a451335f72a86f55aa9b31f90914442b5215bbfc Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 13:19:25 +0800 Subject: [PATCH 20/50] regen --- .../fluent/TopLevelArmResourcesClient.java | 17 +++++ .../TopLevelArmResourceImpl.java | 24 ++----- .../TopLevelArmResourcesClientImpl.java | 66 +++++++++++++++++++ .../models/TopLevelArmResource.java | 33 +--------- 4 files changed, 90 insertions(+), 50 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java index c03819d2a36..ece0dd48031 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -72,6 +72,23 @@ SyncPoller, TopLevelArmResourceInner> begin String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource, String parameter, Context context); + /** * Create a TopLevelArmResource. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java index 5e802b42faf..bb142aec0c6 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -79,12 +79,8 @@ private tsptest.armversioned.ArmVersionedManager manager() { private String createParameter; - private String createNewParameter; - private String updateParameter; - private String updateNewParameter; - public TopLevelArmResourceImpl withExistingResourceGroup(String resourceGroupName) { this.resourceGroupName = resourceGroupName; return this; @@ -94,7 +90,7 @@ public TopLevelArmResource create() { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, - createNewParameter, Context.NONE); + Context.NONE); return this; } @@ -102,7 +98,7 @@ public TopLevelArmResource create(Context context) { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, - createNewParameter, context); + context); return this; } @@ -111,12 +107,10 @@ public TopLevelArmResource create(Context context) { this.serviceManager = serviceManager; this.topLevelArmResourcePropertiesName = name; this.createParameter = null; - this.createNewParameter = null; } public TopLevelArmResourceImpl update() { this.updateParameter = null; - this.updateNewParameter = null; return this; } @@ -124,7 +118,7 @@ public TopLevelArmResource apply() { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, - updateNewParameter, Context.NONE); + Context.NONE); return this; } @@ -132,7 +126,7 @@ public TopLevelArmResource apply(Context context) { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, - updateNewParameter, context); + context); return this; } @@ -189,16 +183,6 @@ public TopLevelArmResourceImpl withParameter(String parameter) { } } - public TopLevelArmResourceImpl withNewParameter(String newParameter) { - if (isInCreateMode()) { - this.createNewParameter = newParameter; - return this; - } else { - this.updateNewParameter = newParameter; - return this; - } - } - private boolean isInCreateMode() { return this.innerModel() == null || this.innerModel().id() == null; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java index 19159871fc6..130c5327568 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -202,6 +202,32 @@ private Response createOrUpdateWithResponse(String resourceGroupName newParameter, contentType, accept, resource, Context.NONE); } + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, + Context context) { + final String newParameter = null; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, contentType, accept, resource, context); + } + /** * Create a TopLevelArmResource. * @@ -416,6 +442,26 @@ private Mono createOrUpdateAsync(String resourceGroupN newParameter).last().flatMap(this.client::getLroFinalResultOrError); } + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource, String parameter, Context context) { + return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, context) + .getFinalResult(); + } + /** * Create a TopLevelArmResource. * @@ -530,6 +576,26 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String parameter, Context context) { + final String newParameter = null; + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), parameter, newParameter, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + /** * List TopLevelArmResource resources by subscription ID. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java index 0d732398d29..b85a60e8179 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -147,8 +147,8 @@ interface WithResourceGroup { * The stage of the TopLevelArmResource definition which contains all the minimum required properties for the * resource to be created, but also allows for any other optional properties to be specified. */ - interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties, - DefinitionStages.WithParameter, DefinitionStages.WithNewParameter { + interface WithCreate + extends DefinitionStages.WithTags, DefinitionStages.WithProperties, DefinitionStages.WithParameter { /** * Executes the create request. * @@ -203,19 +203,6 @@ interface WithParameter { */ WithCreate withParameter(String parameter); } - - /** - * The stage of the TopLevelArmResource definition allowing to specify newParameter. - */ - interface WithNewParameter { - /** - * Specifies the newParameter property: The newParameter parameter. - * - * @param newParameter The newParameter parameter. - * @return the next definition stage. - */ - WithCreate withNewParameter(String newParameter); - } } /** @@ -228,8 +215,7 @@ interface WithNewParameter { /** * The template for TopLevelArmResource update. */ - interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties, UpdateStages.WithParameter, - UpdateStages.WithNewParameter { + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties, UpdateStages.WithParameter { /** * Executes the update request. * @@ -288,19 +274,6 @@ interface WithParameter { */ Update withParameter(String parameter); } - - /** - * The stage of the TopLevelArmResource update allowing to specify newParameter. - */ - interface WithNewParameter { - /** - * Specifies the newParameter property: The newParameter parameter. - * - * @param newParameter The newParameter parameter. - * @return the next definition stage. - */ - Update withNewParameter(String newParameter); - } } /** From 64218aeaf2f5378a7d75317e0bbbc9b84df78c0e Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 13:33:58 +0800 Subject: [PATCH 21/50] mgmt, update logic for taking the client method of full parameters --- .../clientmodel/fluentmodel/ResourceOperation.java | 14 +++++++++++++- 1 file changed, 13 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/fluentmodel/ResourceOperation.java b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java index 73e70070b87..ecf558a50f8 100644 --- a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java +++ b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java @@ -131,7 +131,7 @@ private List getParametersByLocation(RequestParameterLocation p } private List getParametersByLocation(Set parameterLocations) { - ClientMethod clientMethod = getMethodReferencesOfFullParameters().iterator().next().getInnerClientMethod(); + ClientMethod clientMethod = getClientMethodOfFullParameters(); Map proxyMethodParameterByClientParameterName = clientMethod.getProxyMethod() .getParameters() .stream() @@ -145,6 +145,18 @@ private List getParametersByLocation(Set collectionMethods = getMethodReferencesOfFullParameters(); + // take the client method with longest parameters + // it should be the client method of full parameters + collectionMethods.sort((m1, m2) -> { + int count1 = m1.getInnerClientMethod().getParameters().size(); + int count2 = m2.getInnerClientMethod().getParameters().size(); + return Integer.compare(count2, count1); + }); + return collectionMethods.reversed().get(0).getInnerClientMethod(); + } + public ClientMethodParameter getBodyParameter() { List parameters = getParametersByLocation(RequestParameterLocation.BODY); return parameters.isEmpty() ? null : parameters.iterator().next().getClientMethodParameter(); From d99c9cd1f08ac95dbf8ba35bc21a33bb82375230 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 13:41:29 +0800 Subject: [PATCH 22/50] update npm deps --- .../package.json | 2 +- .../http-client-generator-test/package.json | 2 +- packages/http-client-java/package-lock.json | 441 +++++++++--------- packages/http-client-java/package.json | 18 +- 4 files changed, 231 insertions(+), 232 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json index 30b06a45a39..f92da45b1af 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json @@ -31,7 +31,7 @@ "@typespec/streams": "0.76.0", "@azure-tools/typespec-azure-core": "0.62.0", "@azure-tools/typespec-client-generator-core": "0.62.0", - "@azure-tools/typespec-azure-resource-manager": "0.62.0", + "@azure-tools/typespec-azure-resource-manager": "0.62.1", "@azure-tools/typespec-autorest": "0.62.0" }, "private": true diff --git a/packages/http-client-java/generator/http-client-generator-test/package.json b/packages/http-client-java/generator/http-client-generator-test/package.json index 2a307e20b09..d1ab99ad9cf 100644 --- a/packages/http-client-java/generator/http-client-generator-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-test/package.json @@ -31,7 +31,7 @@ "@typespec/streams": "0.76.0", "@azure-tools/typespec-azure-core": "0.62.0", "@azure-tools/typespec-client-generator-core": "0.62.0", - "@azure-tools/typespec-azure-resource-manager": "0.62.0", + "@azure-tools/typespec-azure-resource-manager": "0.62.1", "@azure-tools/typespec-autorest": "0.62.0" }, "private": true diff --git a/packages/http-client-java/package-lock.json b/packages/http-client-java/package-lock.json index 939be9a5356..d23e8d27452 100644 --- a/packages/http-client-java/package-lock.json +++ b/packages/http-client-java/package-lock.json @@ -16,13 +16,13 @@ "devDependencies": { "@azure-tools/typespec-autorest": "0.62.0", "@azure-tools/typespec-azure-core": "0.62.0", - "@azure-tools/typespec-azure-resource-manager": "0.62.0", + "@azure-tools/typespec-azure-resource-manager": "0.62.1", "@azure-tools/typespec-azure-rulesets": "0.62.0", "@azure-tools/typespec-client-generator-core": "0.62.0", - "@microsoft/api-extractor": "^7.55.0", - "@microsoft/api-extractor-model": "^7.32.0", + "@microsoft/api-extractor": "^7.55.1", + "@microsoft/api-extractor-model": "^7.32.1", "@types/js-yaml": "~4.0.9", - "@types/lodash": "~4.17.20", + "@types/lodash": "~4.17.21", "@types/node": "~24.10.1", "@typespec/compiler": "1.6.0", "@typespec/events": "0.76.0", @@ -34,12 +34,12 @@ "@typespec/streams": "0.76.0", "@typespec/versioning": "0.76.0", "@typespec/xml": "0.76.0", - "@vitest/coverage-v8": "^4.0.8", - "@vitest/ui": "^4.0.8", + "@vitest/coverage-v8": "^4.0.13", + "@vitest/ui": "^4.0.13", "c8": "~10.1.3", - "rimraf": "~6.1.0", + "rimraf": "~6.1.2", "typescript": "~5.9.3", - "vitest": "^4.0.8" + "vitest": "^4.0.13" }, "engines": { "node": ">=20.0.0" @@ -47,7 +47,7 @@ "peerDependencies": { "@azure-tools/typespec-autorest": ">=0.62.0 <1.0.0", "@azure-tools/typespec-azure-core": ">=0.62.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.62.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.62.1 <1.0.0", "@azure-tools/typespec-client-generator-core": ">=0.62.0 <1.0.0", "@typespec/compiler": "^1.6.0", "@typespec/events": ">=0.76.0 <1.0.0", @@ -151,9 +151,9 @@ } }, "node_modules/@azure-tools/typespec-azure-resource-manager": { - "version": "0.62.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.62.0.tgz", - "integrity": "sha512-e8lO9DhIkZJ3+1o2VItq1P4gEcy9EyA5G7AhTz8qICCfU23e5xUAUfscDHYH8JAfuO9vYLvCee/MKY01MQJ0vA==", + "version": "0.62.1", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.62.1.tgz", + "integrity": "sha512-sbCwg5Auvm2/fYUWbx3RlQyZGlMoAmhtRjrurgwWzZIBxBJ7sVqgUQktl3WGHAoeJ3qYa2gAIL4j8/xSPwt5kw==", "dev": true, "license": "MIT", "dependencies": { @@ -1525,19 +1525,19 @@ } }, "node_modules/@microsoft/api-extractor": { - "version": "7.55.0", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.55.0.tgz", - "integrity": "sha512-TYc5OtAK/9E3HGgd2bIfSjQDYIwPc0dysf9rPiwXZGsq916I6W2oww9bhm1OxPOeg6rMfOX3PoroGd7oCryYog==", + "version": "7.55.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.55.1.tgz", + "integrity": "sha512-l8Z+8qrLkZFM3HM95Dbpqs6G39fpCa7O5p8A7AkA6hSevxkgwsOlLrEuPv0ADOyj5dI1Af5WVDiwpKG/ya5G3w==", "dev": true, "license": "MIT", "dependencies": { - "@microsoft/api-extractor-model": "7.32.0", + "@microsoft/api-extractor-model": "7.32.1", "@microsoft/tsdoc": "~0.16.0", "@microsoft/tsdoc-config": "~0.18.0", - "@rushstack/node-core-library": "5.18.0", + "@rushstack/node-core-library": "5.19.0", "@rushstack/rig-package": "0.6.0", - "@rushstack/terminal": "0.19.3", - "@rushstack/ts-command-line": "5.1.3", + "@rushstack/terminal": "0.19.4", + "@rushstack/ts-command-line": "5.1.4", "diff": "~8.0.2", "lodash": "~4.17.15", "minimatch": "10.0.3", @@ -1551,15 +1551,15 @@ } }, "node_modules/@microsoft/api-extractor-model": { - "version": "7.32.0", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.32.0.tgz", - "integrity": "sha512-QIVJSreb8fGGJy1Qx0yzGVXxvHJN1WXgkFNHFheVv1iBJNqgvp+xeT3ienJmRwXmPPc5Es/cxBrXtKZJR3i7iw==", + "version": "7.32.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.32.1.tgz", + "integrity": "sha512-u4yJytMYiUAnhcNQcZDTh/tVtlrzKlyKrQnLOV+4Qr/5gV+cpufWzCYAB1Q23URFqD6z2RoL2UYncM9xJVGNKA==", "dev": true, "license": "MIT", "dependencies": { "@microsoft/tsdoc": "~0.16.0", "@microsoft/tsdoc-config": "~0.18.0", - "@rushstack/node-core-library": "5.18.0" + "@rushstack/node-core-library": "5.19.0" } }, "node_modules/@microsoft/api-extractor/node_modules/lru-cache": { @@ -1679,9 +1679,9 @@ "license": "MIT" }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.53.2.tgz", - "integrity": "sha512-yDPzwsgiFO26RJA4nZo8I+xqzh7sJTZIWQOxn+/XOdPE31lAvLIYCKqjV+lNH/vxE2L2iH3plKxDCRK6i+CwhA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.53.3.tgz", + "integrity": "sha512-mRSi+4cBjrRLoaal2PnqH82Wqyb+d3HsPUN/W+WslCXsZsyHa9ZeQQX/pQsZaVIWDkPcpV6jJ+3KLbTbgnwv8w==", "cpu": [ "arm" ], @@ -1693,9 +1693,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.53.2.tgz", - "integrity": "sha512-k8FontTxIE7b0/OGKeSN5B6j25EuppBcWM33Z19JoVT7UTXFSo3D9CdU39wGTeb29NO3XxpMNauh09B+Ibw+9g==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.53.3.tgz", + "integrity": "sha512-CbDGaMpdE9sh7sCmTrTUyllhrg65t6SwhjlMJsLr+J8YjFuPmCEjbBSx4Z/e4SmDyH3aB5hGaJUP2ltV/vcs4w==", "cpu": [ "arm64" ], @@ -1707,9 +1707,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.53.2.tgz", - "integrity": "sha512-A6s4gJpomNBtJ2yioj8bflM2oogDwzUiMl2yNJ2v9E7++sHrSrsQ29fOfn5DM/iCzpWcebNYEdXpaK4tr2RhfQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.53.3.tgz", + "integrity": "sha512-Nr7SlQeqIBpOV6BHHGZgYBuSdanCXuw09hon14MGOLGmXAFYjx1wNvquVPmpZnl0tLjg25dEdr4IQ6GgyToCUA==", "cpu": [ "arm64" ], @@ -1721,9 +1721,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.53.2.tgz", - "integrity": "sha512-e6XqVmXlHrBlG56obu9gDRPW3O3hLxpwHpLsBJvuI8qqnsrtSZ9ERoWUXtPOkY8c78WghyPHZdmPhHLWNdAGEw==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.53.3.tgz", + "integrity": "sha512-DZ8N4CSNfl965CmPktJ8oBnfYr3F8dTTNBQkRlffnUarJ2ohudQD17sZBa097J8xhQ26AwhHJ5mvUyQW8ddTsQ==", "cpu": [ "x64" ], @@ -1735,9 +1735,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.53.2.tgz", - "integrity": "sha512-v0E9lJW8VsrwPux5Qe5CwmH/CF/2mQs6xU1MF3nmUxmZUCHazCjLgYvToOk+YuuUqLQBio1qkkREhxhc656ViA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.53.3.tgz", + "integrity": "sha512-yMTrCrK92aGyi7GuDNtGn2sNW+Gdb4vErx4t3Gv/Tr+1zRb8ax4z8GWVRfr3Jw8zJWvpGHNpss3vVlbF58DZ4w==", "cpu": [ "arm64" ], @@ -1749,9 +1749,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.53.2.tgz", - "integrity": "sha512-ClAmAPx3ZCHtp6ysl4XEhWU69GUB1D+s7G9YjHGhIGCSrsg00nEGRRZHmINYxkdoJehde8VIsDC5t9C0gb6yqA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.53.3.tgz", + "integrity": "sha512-lMfF8X7QhdQzseM6XaX0vbno2m3hlyZFhwcndRMw8fbAGUGL3WFMBdK0hbUBIUYcEcMhVLr1SIamDeuLBnXS+Q==", "cpu": [ "x64" ], @@ -1763,9 +1763,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.53.2.tgz", - "integrity": "sha512-EPlb95nUsz6Dd9Qy13fI5kUPXNSljaG9FiJ4YUGU1O/Q77i5DYFW5KR8g1OzTcdZUqQQ1KdDqsTohdFVwCwjqg==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.53.3.tgz", + "integrity": "sha512-k9oD15soC/Ln6d2Wv/JOFPzZXIAIFLp6B+i14KhxAfnq76ajt0EhYc5YPeX6W1xJkAdItcVT+JhKl1QZh44/qw==", "cpu": [ "arm" ], @@ -1777,9 +1777,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.53.2.tgz", - "integrity": "sha512-BOmnVW+khAUX+YZvNfa0tGTEMVVEerOxN0pDk2E6N6DsEIa2Ctj48FOMfNDdrwinocKaC7YXUZ1pHlKpnkja/Q==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.53.3.tgz", + "integrity": "sha512-vTNlKq+N6CK/8UktsrFuc+/7NlEYVxgaEgRXVUVK258Z5ymho29skzW1sutgYjqNnquGwVUObAaxae8rZ6YMhg==", "cpu": [ "arm" ], @@ -1791,9 +1791,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.53.2.tgz", - "integrity": "sha512-Xt2byDZ+6OVNuREgBXr4+CZDJtrVso5woFtpKdGPhpTPHcNG7D8YXeQzpNbFRxzTVqJf7kvPMCub/pcGUWgBjA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.53.3.tgz", + "integrity": "sha512-RGrFLWgMhSxRs/EWJMIFM1O5Mzuz3Xy3/mnxJp/5cVhZ2XoCAxJnmNsEyeMJtpK+wu0FJFWz+QF4mjCA7AUQ3w==", "cpu": [ "arm64" ], @@ -1805,9 +1805,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.53.2.tgz", - "integrity": "sha512-+LdZSldy/I9N8+klim/Y1HsKbJ3BbInHav5qE9Iy77dtHC/pibw1SR/fXlWyAk0ThnpRKoODwnAuSjqxFRDHUQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.53.3.tgz", + "integrity": "sha512-kASyvfBEWYPEwe0Qv4nfu6pNkITLTb32p4yTgzFCocHnJLAHs+9LjUu9ONIhvfT/5lv4YS5muBHyuV84epBo/A==", "cpu": [ "arm64" ], @@ -1819,9 +1819,9 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.53.2.tgz", - "integrity": "sha512-8ms8sjmyc1jWJS6WdNSA23rEfdjWB30LH8Wqj0Cqvv7qSHnvw6kgMMXRdop6hkmGPlyYBdRPkjJnj3KCUHV/uQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.53.3.tgz", + "integrity": "sha512-JiuKcp2teLJwQ7vkJ95EwESWkNRFJD7TQgYmCnrPtlu50b4XvT5MOmurWNrCj3IFdyjBQ5p9vnrX4JM6I8OE7g==", "cpu": [ "loong64" ], @@ -1833,9 +1833,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.53.2.tgz", - "integrity": "sha512-3HRQLUQbpBDMmzoxPJYd3W6vrVHOo2cVW8RUo87Xz0JPJcBLBr5kZ1pGcQAhdZgX9VV7NbGNipah1omKKe23/g==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.53.3.tgz", + "integrity": "sha512-EoGSa8nd6d3T7zLuqdojxC20oBfNT8nexBbB/rkxgKj5T5vhpAQKKnD+h3UkoMuTyXkP5jTjK/ccNRmQrPNDuw==", "cpu": [ "ppc64" ], @@ -1847,9 +1847,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.53.2.tgz", - "integrity": "sha512-fMjKi+ojnmIvhk34gZP94vjogXNNUKMEYs+EDaB/5TG/wUkoeua7p7VCHnE6T2Tx+iaghAqQX8teQzcvrYpaQA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.53.3.tgz", + "integrity": "sha512-4s+Wped2IHXHPnAEbIB0YWBv7SDohqxobiiPA1FIWZpX+w9o2i4LezzH/NkFUl8LRci/8udci6cLq+jJQlh+0g==", "cpu": [ "riscv64" ], @@ -1861,9 +1861,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.53.2.tgz", - "integrity": "sha512-XuGFGU+VwUUV5kLvoAdi0Wz5Xbh2SrjIxCtZj6Wq8MDp4bflb/+ThZsVxokM7n0pcbkEr2h5/pzqzDYI7cCgLQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.53.3.tgz", + "integrity": "sha512-68k2g7+0vs2u9CxDt5ktXTngsxOQkSEV/xBbwlqYcUrAVh6P9EgMZvFsnHy4SEiUl46Xf0IObWVbMvPrr2gw8A==", "cpu": [ "riscv64" ], @@ -1875,9 +1875,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.53.2.tgz", - "integrity": "sha512-w6yjZF0P+NGzWR3AXWX9zc0DNEGdtvykB03uhonSHMRa+oWA6novflo2WaJr6JZakG2ucsyb+rvhrKac6NIy+w==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.53.3.tgz", + "integrity": "sha512-VYsFMpULAz87ZW6BVYw3I6sWesGpsP9OPcyKe8ofdg9LHxSbRMd7zrVrr5xi/3kMZtpWL/wC+UIJWJYVX5uTKg==", "cpu": [ "s390x" ], @@ -1889,9 +1889,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.53.2.tgz", - "integrity": "sha512-yo8d6tdfdeBArzC7T/PnHd7OypfI9cbuZzPnzLJIyKYFhAQ8SvlkKtKBMbXDxe1h03Rcr7u++nFS7tqXz87Gtw==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.53.3.tgz", + "integrity": "sha512-3EhFi1FU6YL8HTUJZ51imGJWEX//ajQPfqWLI3BQq4TlvHy4X0MOr5q3D2Zof/ka0d5FNdPwZXm3Yyib/UEd+w==", "cpu": [ "x64" ], @@ -1903,9 +1903,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.53.2.tgz", - "integrity": "sha512-ah59c1YkCxKExPP8O9PwOvs+XRLKwh/mV+3YdKqQ5AMQ0r4M4ZDuOrpWkUaqO7fzAHdINzV9tEVu8vNw48z0lA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.53.3.tgz", + "integrity": "sha512-eoROhjcc6HbZCJr+tvVT8X4fW3/5g/WkGvvmwz/88sDtSJzO7r/blvoBDgISDiCjDRZmHpwud7h+6Q9JxFwq1Q==", "cpu": [ "x64" ], @@ -1917,9 +1917,9 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.53.2.tgz", - "integrity": "sha512-4VEd19Wmhr+Zy7hbUsFZ6YXEiP48hE//KPLCSVNY5RMGX2/7HZ+QkN55a3atM1C/BZCGIgqN+xrVgtdak2S9+A==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.53.3.tgz", + "integrity": "sha512-OueLAWgrNSPGAdUdIjSWXw+u/02BRTcnfw9PN41D2vq/JSEPnJnVuBgw18VkN8wcd4fjUs+jFHVM4t9+kBSNLw==", "cpu": [ "arm64" ], @@ -1931,9 +1931,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.53.2.tgz", - "integrity": "sha512-IlbHFYc/pQCgew/d5fslcy1KEaYVCJ44G8pajugd8VoOEI8ODhtb/j8XMhLpwHCMB3yk2J07ctup10gpw2nyMA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.53.3.tgz", + "integrity": "sha512-GOFuKpsxR/whszbF/bzydebLiXIHSgsEUp6M0JI8dWvi+fFa1TD6YQa4aSZHtpmh2/uAlj/Dy+nmby3TJ3pkTw==", "cpu": [ "arm64" ], @@ -1945,9 +1945,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.53.2.tgz", - "integrity": "sha512-lNlPEGgdUfSzdCWU176ku/dQRnA7W+Gp8d+cWv73jYrb8uT7HTVVxq62DUYxjbaByuf1Yk0RIIAbDzp+CnOTFg==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.53.3.tgz", + "integrity": "sha512-iah+THLcBJdpfZ1TstDFbKNznlzoxa8fmnFYK4V67HvmuNYkVdAywJSoteUszvBQ9/HqN2+9AZghbajMsFT+oA==", "cpu": [ "ia32" ], @@ -1959,9 +1959,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.53.2.tgz", - "integrity": "sha512-S6YojNVrHybQis2lYov1sd+uj7K0Q05NxHcGktuMMdIQ2VixGwAfbJ23NnlvvVV1bdpR2m5MsNBViHJKcA4ADw==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.53.3.tgz", + "integrity": "sha512-J9QDiOIZlZLdcot5NXEepDkstocktoVjkaKUtqzgzpt2yWjGlbYiKyp05rWwk4nypbYUNoFAztEgixoLaSETkg==", "cpu": [ "x64" ], @@ -1973,9 +1973,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.53.2.tgz", - "integrity": "sha512-k+/Rkcyx//P6fetPoLMb8pBeqJBNGx81uuf7iljX9++yNBVRDQgD04L+SVXmXmh5ZP4/WOp4mWF0kmi06PW2tA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.53.3.tgz", + "integrity": "sha512-UhTd8u31dXadv0MopwGgNOBpUVROFKWVQgAg5N1ESyCz8AuBcMqm4AuTjrwgQKGDfoFuz02EuMRHQIw/frmYKQ==", "cpu": [ "x64" ], @@ -1987,9 +1987,9 @@ ] }, "node_modules/@rushstack/node-core-library": { - "version": "5.18.0", - "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-5.18.0.tgz", - "integrity": "sha512-XDebtBdw5S3SuZIt+Ra2NieT8kQ3D2Ow1HxhDQ/2soinswnOu9e7S69VSwTOLlQnx5mpWbONu+5JJjDxMAb6Fw==", + "version": "5.19.0", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-5.19.0.tgz", + "integrity": "sha512-BxAopbeWBvNJ6VGiUL+5lbJXywTdsnMeOS8j57Cn/xY10r6sV/gbsTlfYKjzVCUBZATX2eRzJHSMCchsMTGN6A==", "dev": true, "license": "MIT", "dependencies": { @@ -2084,13 +2084,13 @@ } }, "node_modules/@rushstack/terminal": { - "version": "0.19.3", - "resolved": "https://registry.npmjs.org/@rushstack/terminal/-/terminal-0.19.3.tgz", - "integrity": "sha512-0P8G18gK9STyO+CNBvkKPnWGMxESxecTYqOcikHOVIHXa9uAuTK+Fw8TJq2Gng1w7W6wTC9uPX6hGNvrMll2wA==", + "version": "0.19.4", + "resolved": "https://registry.npmjs.org/@rushstack/terminal/-/terminal-0.19.4.tgz", + "integrity": "sha512-f4XQk02CrKfrMgyOfhYd3qWI944dLC21S4I/LUhrlAP23GTMDNG6EK5effQtFkISwUKCgD9vMBrJZaPSUquxWQ==", "dev": true, "license": "MIT", "dependencies": { - "@rushstack/node-core-library": "5.18.0", + "@rushstack/node-core-library": "5.19.0", "@rushstack/problem-matcher": "0.1.1", "supports-color": "~8.1.1" }, @@ -2104,13 +2104,13 @@ } }, "node_modules/@rushstack/ts-command-line": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-5.1.3.tgz", - "integrity": "sha512-Kdv0k/BnnxIYFlMVC1IxrIS0oGQd4T4b7vKfx52Y2+wk2WZSDFIvedr7JrhenzSlm3ou5KwtoTGTGd5nbODRug==", + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-5.1.4.tgz", + "integrity": "sha512-H0I6VdJ6sOUbktDFpP2VW5N29w8v4hRoNZOQz02vtEi6ZTYL1Ju8u+TcFiFawUDrUsx/5MQTUhd79uwZZVwVlA==", "dev": true, "license": "MIT", "dependencies": { - "@rushstack/terminal": "0.19.3", + "@rushstack/terminal": "0.19.4", "@types/argparse": "1.0.38", "argparse": "~1.0.9", "string-argv": "~0.3.1" @@ -2191,9 +2191,9 @@ "dev": true }, "node_modules/@types/lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-H3MHACvFUEiujabxhaI/ImO6gUrd8oOurg7LQtS7mbwIXA/cUqWrvBsaeJ23aZEPk1TAYkurjfMbSELfoCXlGA==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-FOvQ0YPD5NOfPgMzJihoT+Za5pdkDJWcbpuj1DjaKZIr/gxodQjY/uWEFlTNqW2ugXHUiL8lRQgw63dzKHZdeQ==", "dev": true, "license": "MIT" }, @@ -2736,14 +2736,14 @@ } }, "node_modules/@vitest/coverage-v8": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.0.8.tgz", - "integrity": "sha512-wQgmtW6FtPNn4lWUXi8ZSYLpOIb92j3QCujxX3sQ81NTfQ/ORnE0HtK7Kqf2+7J9jeveMGyGyc4NWc5qy3rC4A==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.0.13.tgz", + "integrity": "sha512-w77N6bmtJ3CFnL/YHiYotwW/JI3oDlR3K38WEIqegRfdMSScaYxwYKB/0jSNpOTZzUjQkG8HHEz4sdWQMWpQ5g==", "dev": true, "license": "MIT", "dependencies": { "@bcoe/v8-coverage": "^1.0.2", - "@vitest/utils": "4.0.8", + "@vitest/utils": "4.0.13", "ast-v8-to-istanbul": "^0.3.8", "debug": "^4.4.3", "istanbul-lib-coverage": "^3.2.2", @@ -2758,8 +2758,8 @@ "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@vitest/browser": "4.0.8", - "vitest": "4.0.8" + "@vitest/browser": "4.0.13", + "vitest": "4.0.13" }, "peerDependenciesMeta": { "@vitest/browser": { @@ -2768,17 +2768,17 @@ } }, "node_modules/@vitest/expect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.8.tgz", - "integrity": "sha512-Rv0eabdP/xjAHQGr8cjBm+NnLHNoL268lMDK85w2aAGLFoVKLd8QGnVon5lLtkXQCoYaNL0wg04EGnyKkkKhPA==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.13.tgz", + "integrity": "sha512-zYtcnNIBm6yS7Gpr7nFTmq8ncowlMdOJkWLqYvhr/zweY6tFbDkDi8BPPOeHxEtK1rSI69H7Fd4+1sqvEGli6w==", "dev": true, "license": "MIT", "dependencies": { "@standard-schema/spec": "^1.0.0", "@types/chai": "^5.2.2", - "@vitest/spy": "4.0.8", - "@vitest/utils": "4.0.8", - "chai": "^6.2.0", + "@vitest/spy": "4.0.13", + "@vitest/utils": "4.0.13", + "chai": "^6.2.1", "tinyrainbow": "^3.0.3" }, "funding": { @@ -2786,13 +2786,13 @@ } }, "node_modules/@vitest/mocker": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.8.tgz", - "integrity": "sha512-9FRM3MZCedXH3+pIh+ME5Up2NBBHDq0wqwhOKkN4VnvCiKbVxddqH9mSGPZeawjd12pCOGnl+lo/ZGHt0/dQSg==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.13.tgz", + "integrity": "sha512-eNCwzrI5djoauklwP1fuslHBjrbR8rqIVbvNlAnkq1OTa6XT+lX68mrtPirNM9TnR69XUPt4puBCx2Wexseylg==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "4.0.8", + "@vitest/spy": "4.0.13", "estree-walker": "^3.0.3", "magic-string": "^0.30.21" }, @@ -2813,9 +2813,9 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.8.tgz", - "integrity": "sha512-qRrjdRkINi9DaZHAimV+8ia9Gq6LeGz2CgIEmMLz3sBDYV53EsnLZbJMR1q84z1HZCMsf7s0orDgZn7ScXsZKg==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.13.tgz", + "integrity": "sha512-ooqfze8URWbI2ozOeLDMh8YZxWDpGXoeY3VOgcDnsUxN0jPyPWSUvjPQWqDGCBks+opWlN1E4oP1UYl3C/2EQA==", "dev": true, "license": "MIT", "dependencies": { @@ -2826,13 +2826,13 @@ } }, "node_modules/@vitest/runner": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.8.tgz", - "integrity": "sha512-mdY8Sf1gsM8hKJUQfiPT3pn1n8RF4QBcJYFslgWh41JTfrK1cbqY8whpGCFzBl45LN028g0njLCYm0d7XxSaQQ==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.13.tgz", + "integrity": "sha512-9IKlAru58wcVaWy7hz6qWPb2QzJTKt+IOVKjAx5vb5rzEFPTL6H4/R9BMvjZ2ppkxKgTrFONEJFtzvnyEpiT+A==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "4.0.8", + "@vitest/utils": "4.0.13", "pathe": "^2.0.3" }, "funding": { @@ -2840,13 +2840,13 @@ } }, "node_modules/@vitest/snapshot": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.8.tgz", - "integrity": "sha512-Nar9OTU03KGiubrIOFhcfHg8FYaRaNT+bh5VUlNz8stFhCZPNrJvmZkhsr1jtaYvuefYFwK2Hwrq026u4uPWCw==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.13.tgz", + "integrity": "sha512-hb7Usvyika1huG6G6l191qu1urNPsq1iFc2hmdzQY3F5/rTgqQnwwplyf8zoYHkpt7H6rw5UfIw6i/3qf9oSxQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.0.8", + "@vitest/pretty-format": "4.0.13", "magic-string": "^0.30.21", "pathe": "^2.0.3" }, @@ -2855,9 +2855,9 @@ } }, "node_modules/@vitest/spy": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.8.tgz", - "integrity": "sha512-nvGVqUunyCgZH7kmo+Ord4WgZ7lN0sOULYXUOYuHr55dvg9YvMz3izfB189Pgp28w0vWFbEEfNc/c3VTrqrXeA==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.13.tgz", + "integrity": "sha512-hSu+m4se0lDV5yVIcNWqjuncrmBgwaXa2utFLIrBkQCQkt+pSwyZTPFQAZiiF/63j8jYa8uAeUZ3RSfcdWaYWw==", "dev": true, "license": "MIT", "funding": { @@ -2865,13 +2865,13 @@ } }, "node_modules/@vitest/ui": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-4.0.8.tgz", - "integrity": "sha512-F9jI5rSstNknPlTlPN2gcc4gpbaagowuRzw/OJzl368dvPun668Q182S8Q8P9PITgGCl5LAKXpzuue106eM4wA==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-4.0.13.tgz", + "integrity": "sha512-MFV6GhTflgBj194+vowTB2iLI5niMZhqiW7/NV7U4AfWbX/IAtsq4zA+gzCLyGzpsQUdJlX26hrQ1vuWShq2BQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "4.0.8", + "@vitest/utils": "4.0.13", "fflate": "^0.8.2", "flatted": "^3.3.3", "pathe": "^2.0.3", @@ -2883,17 +2883,17 @@ "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "vitest": "4.0.8" + "vitest": "4.0.13" } }, "node_modules/@vitest/utils": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.8.tgz", - "integrity": "sha512-pdk2phO5NDvEFfUTxcTP8RFYjVj/kfLSPIN5ebP2Mu9kcIMeAQTbknqcFEyBcC4z2pJlJI9aS5UQjcYfhmKAow==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.13.tgz", + "integrity": "sha512-ydozWyQ4LZuu8rLp47xFUWis5VOKMdHjXCWhs1LuJsTNKww+pTHQNK4e0assIB9K80TxFyskENL6vCu3j34EYA==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.0.8", + "@vitest/pretty-format": "4.0.13", "tinyrainbow": "^3.0.3" }, "funding": { @@ -4153,22 +4153,16 @@ } }, "node_modules/glob": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", - "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.0.tgz", + "integrity": "sha512-tvZgpqk6fz4BaNZ66ZsRaZnbHvP/jG3uKJvAZOwEVUL4RTA5nJeeLYfyN9/VA8NX/V3IBG+hkeuGpKjvELkVhA==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "dependencies": { - "foreground-child": "^3.3.1", - "jackspeak": "^4.1.1", - "minimatch": "^10.0.3", + "minimatch": "^10.1.1", "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", "path-scurry": "^2.0.0" }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, "engines": { "node": "20 || >=22" }, @@ -4189,6 +4183,22 @@ "node": ">= 6" } }, + "node_modules/glob/node_modules/minimatch": { + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz", + "integrity": "sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/brace-expansion": "^5.0.0" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/globby": { "version": "15.0.0", "resolved": "https://registry.npmjs.org/globby/-/globby-15.0.0.tgz", @@ -4877,22 +4887,6 @@ "node": ">=8" } }, - "node_modules/jackspeak": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz", - "integrity": "sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/jju": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", @@ -5614,9 +5608,9 @@ "license": "MIT" }, "node_modules/path-scurry": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", - "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.1.tgz", + "integrity": "sha512-oWyT4gICAu+kaA7QWk/jvCHWarMKNs6pXOGWKDTr7cw4IGcUbW+PeTfbaQiLGheFRpjo6O9J0PmyMfQPjH71oA==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -5958,13 +5952,13 @@ } }, "node_modules/rimraf": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.0.tgz", - "integrity": "sha512-DxdlA1bdNzkZK7JiNWH+BAx1x4tEJWoTofIopFo6qWUU94jYrFZ0ubY05TqH3nWPJ1nKa1JWVFDINZ3fnrle/A==", + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.2.tgz", + "integrity": "sha512-cFCkPslJv7BAXJsYlK1dZsbP8/ZNLkCAQ0bi1hf5EKX2QHegmDFEFA6QhuYJlk7UDdc+02JjO80YSOrWPpw06g==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "glob": "^11.0.3", + "glob": "^13.0.0", "package-json-from-dist": "^1.0.1" }, "bin": { @@ -5978,9 +5972,9 @@ } }, "node_modules/rollup": { - "version": "4.53.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.53.2.tgz", - "integrity": "sha512-MHngMYwGJVi6Fmnk6ISmnk7JAHRNF0UkuucA0CUW3N3a4KnONPEZz+vUanQP/ZC/iY1Qkf3bwPWzyY84wEks1g==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.53.3.tgz", + "integrity": "sha512-w8GmOxZfBmKknvdXU1sdM9NHcoQejwF/4mNgj2JuEEdRaHwwF12K7e9eXn1nLZ07ad+du76mkVsyeb2rKGllsA==", "dev": true, "license": "MIT", "dependencies": { @@ -5994,28 +5988,28 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.53.2", - "@rollup/rollup-android-arm64": "4.53.2", - "@rollup/rollup-darwin-arm64": "4.53.2", - "@rollup/rollup-darwin-x64": "4.53.2", - "@rollup/rollup-freebsd-arm64": "4.53.2", - "@rollup/rollup-freebsd-x64": "4.53.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.53.2", - "@rollup/rollup-linux-arm-musleabihf": "4.53.2", - "@rollup/rollup-linux-arm64-gnu": "4.53.2", - "@rollup/rollup-linux-arm64-musl": "4.53.2", - "@rollup/rollup-linux-loong64-gnu": "4.53.2", - "@rollup/rollup-linux-ppc64-gnu": "4.53.2", - "@rollup/rollup-linux-riscv64-gnu": "4.53.2", - "@rollup/rollup-linux-riscv64-musl": "4.53.2", - "@rollup/rollup-linux-s390x-gnu": "4.53.2", - "@rollup/rollup-linux-x64-gnu": "4.53.2", - "@rollup/rollup-linux-x64-musl": "4.53.2", - "@rollup/rollup-openharmony-arm64": "4.53.2", - "@rollup/rollup-win32-arm64-msvc": "4.53.2", - "@rollup/rollup-win32-ia32-msvc": "4.53.2", - "@rollup/rollup-win32-x64-gnu": "4.53.2", - "@rollup/rollup-win32-x64-msvc": "4.53.2", + "@rollup/rollup-android-arm-eabi": "4.53.3", + "@rollup/rollup-android-arm64": "4.53.3", + "@rollup/rollup-darwin-arm64": "4.53.3", + "@rollup/rollup-darwin-x64": "4.53.3", + "@rollup/rollup-freebsd-arm64": "4.53.3", + "@rollup/rollup-freebsd-x64": "4.53.3", + "@rollup/rollup-linux-arm-gnueabihf": "4.53.3", + "@rollup/rollup-linux-arm-musleabihf": "4.53.3", + "@rollup/rollup-linux-arm64-gnu": "4.53.3", + "@rollup/rollup-linux-arm64-musl": "4.53.3", + "@rollup/rollup-linux-loong64-gnu": "4.53.3", + "@rollup/rollup-linux-ppc64-gnu": "4.53.3", + "@rollup/rollup-linux-riscv64-gnu": "4.53.3", + "@rollup/rollup-linux-riscv64-musl": "4.53.3", + "@rollup/rollup-linux-s390x-gnu": "4.53.3", + "@rollup/rollup-linux-x64-gnu": "4.53.3", + "@rollup/rollup-linux-x64-musl": "4.53.3", + "@rollup/rollup-openharmony-arm64": "4.53.3", + "@rollup/rollup-win32-arm64-msvc": "4.53.3", + "@rollup/rollup-win32-ia32-msvc": "4.53.3", + "@rollup/rollup-win32-x64-gnu": "4.53.3", + "@rollup/rollup-win32-x64-msvc": "4.53.3", "fsevents": "~2.3.2" } }, @@ -6634,10 +6628,11 @@ } }, "node_modules/test-exclude/node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", "dev": true, + "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^3.1.2", @@ -6958,9 +6953,9 @@ } }, "node_modules/vite": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.2.2.tgz", - "integrity": "sha512-BxAKBWmIbrDgrokdGZH1IgkIk/5mMHDreLDmCJ0qpyJaAteP8NvMhkwr/ZCQNqNH97bw/dANTE9PDzqwJghfMQ==", + "version": "7.2.4", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.2.4.tgz", + "integrity": "sha512-NL8jTlbo0Tn4dUEXEsUg8KeyG/Lkmc4Fnzb8JXN/Ykm9G4HNImjtABMJgkQoVjOBN/j2WAwDTRytdqJbZsah7w==", "dev": true, "license": "MIT", "dependencies": { @@ -7064,19 +7059,19 @@ } }, "node_modules/vitest": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.8.tgz", - "integrity": "sha512-urzu3NCEV0Qa0Y2PwvBtRgmNtxhj5t5ULw7cuKhIHh3OrkKTLlut0lnBOv9qe5OvbkMH2g38G7KPDCTpIytBVg==", + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.13.tgz", + "integrity": "sha512-QSD4I0fN6uZQfftryIXuqvqgBxTvJ3ZNkF6RWECd82YGAYAfhcppBLFXzXJHQAAhVFyYEuFTrq6h0hQqjB7jIQ==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/expect": "4.0.8", - "@vitest/mocker": "4.0.8", - "@vitest/pretty-format": "4.0.8", - "@vitest/runner": "4.0.8", - "@vitest/snapshot": "4.0.8", - "@vitest/spy": "4.0.8", - "@vitest/utils": "4.0.8", + "@vitest/expect": "4.0.13", + "@vitest/mocker": "4.0.13", + "@vitest/pretty-format": "4.0.13", + "@vitest/runner": "4.0.13", + "@vitest/snapshot": "4.0.13", + "@vitest/spy": "4.0.13", + "@vitest/utils": "4.0.13", "debug": "^4.4.3", "es-module-lexer": "^1.7.0", "expect-type": "^1.2.2", @@ -7102,12 +7097,13 @@ }, "peerDependencies": { "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", "@types/debug": "^4.1.12", "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "4.0.8", - "@vitest/browser-preview": "4.0.8", - "@vitest/browser-webdriverio": "4.0.8", - "@vitest/ui": "4.0.8", + "@vitest/browser-playwright": "4.0.13", + "@vitest/browser-preview": "4.0.13", + "@vitest/browser-webdriverio": "4.0.13", + "@vitest/ui": "4.0.13", "happy-dom": "*", "jsdom": "*" }, @@ -7115,6 +7111,9 @@ "@edge-runtime/vm": { "optional": true }, + "@opentelemetry/api": { + "optional": true + }, "@types/debug": { "optional": true }, diff --git a/packages/http-client-java/package.json b/packages/http-client-java/package.json index b2036796555..d0c44f5397d 100644 --- a/packages/http-client-java/package.json +++ b/packages/http-client-java/package.json @@ -51,7 +51,7 @@ "peerDependencies": { "@azure-tools/typespec-autorest": ">=0.62.0 <1.0.0", "@azure-tools/typespec-azure-core": ">=0.62.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.62.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.62.1 <1.0.0", "@azure-tools/typespec-client-generator-core": ">=0.62.0 <1.0.0", "@typespec/compiler": "^1.6.0", "@typespec/events": ">=0.76.0 <1.0.0", @@ -71,13 +71,13 @@ "devDependencies": { "@azure-tools/typespec-autorest": "0.62.0", "@azure-tools/typespec-azure-core": "0.62.0", - "@azure-tools/typespec-azure-resource-manager": "0.62.0", + "@azure-tools/typespec-azure-resource-manager": "0.62.1", "@azure-tools/typespec-azure-rulesets": "0.62.0", "@azure-tools/typespec-client-generator-core": "0.62.0", - "@microsoft/api-extractor": "^7.55.0", - "@microsoft/api-extractor-model": "^7.32.0", + "@microsoft/api-extractor": "^7.55.1", + "@microsoft/api-extractor-model": "^7.32.1", "@types/js-yaml": "~4.0.9", - "@types/lodash": "~4.17.20", + "@types/lodash": "~4.17.21", "@types/node": "~24.10.1", "@typespec/compiler": "1.6.0", "@typespec/events": "0.76.0", @@ -89,11 +89,11 @@ "@typespec/streams": "0.76.0", "@typespec/versioning": "0.76.0", "@typespec/xml": "0.76.0", - "@vitest/coverage-v8": "^4.0.8", - "@vitest/ui": "^4.0.8", + "@vitest/coverage-v8": "^4.0.13", + "@vitest/ui": "^4.0.13", "c8": "~10.1.3", - "rimraf": "~6.1.0", + "rimraf": "~6.1.2", "typescript": "~5.9.3", - "vitest": "^4.0.8" + "vitest": "^4.0.13" } } From 2b3b2227a2ad35147e006b11c400337bdc746769 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 15:03:50 +0800 Subject: [PATCH 23/50] bug fix --- .../mgmt/model/clientmodel/fluentmodel/ResourceOperation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java index ecf558a50f8..70c8190ae4a 100644 --- a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java +++ b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java @@ -152,9 +152,9 @@ private ClientMethod getClientMethodOfFullParameters() { collectionMethods.sort((m1, m2) -> { int count1 = m1.getInnerClientMethod().getParameters().size(); int count2 = m2.getInnerClientMethod().getParameters().size(); - return Integer.compare(count2, count1); + return -Integer.compare(count1, count2); }); - return collectionMethods.reversed().get(0).getInnerClientMethod(); + return collectionMethods.get(0).getInnerClientMethod(); } public ClientMethodParameter getBodyParameter() { From 9653e3546f0e03448b8746717f38dcda19a1892c Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 15:13:41 +0800 Subject: [PATCH 24/50] regen --- .../TopLevelArmResourceImpl.java | 16 +++++++++ .../models/TopLevelArmResource.java | 33 +++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java index bb142aec0c6..b1b8de027c2 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -79,8 +79,12 @@ private tsptest.armversioned.ArmVersionedManager manager() { private String createParameter; + private String createNewParameter; + private String updateParameter; + private String updateNewParameter; + public TopLevelArmResourceImpl withExistingResourceGroup(String resourceGroupName) { this.resourceGroupName = resourceGroupName; return this; @@ -107,10 +111,12 @@ public TopLevelArmResource create(Context context) { this.serviceManager = serviceManager; this.topLevelArmResourcePropertiesName = name; this.createParameter = null; + this.createNewParameter = null; } public TopLevelArmResourceImpl update() { this.updateParameter = null; + this.updateNewParameter = null; return this; } @@ -183,6 +189,16 @@ public TopLevelArmResourceImpl withParameter(String parameter) { } } + public TopLevelArmResourceImpl withNewParameter(String newParameter) { + if (isInCreateMode()) { + this.createNewParameter = newParameter; + return this; + } else { + this.updateNewParameter = newParameter; + return this; + } + } + private boolean isInCreateMode() { return this.innerModel() == null || this.innerModel().id() == null; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java index b85a60e8179..0d732398d29 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -147,8 +147,8 @@ interface WithResourceGroup { * The stage of the TopLevelArmResource definition which contains all the minimum required properties for the * resource to be created, but also allows for any other optional properties to be specified. */ - interface WithCreate - extends DefinitionStages.WithTags, DefinitionStages.WithProperties, DefinitionStages.WithParameter { + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties, + DefinitionStages.WithParameter, DefinitionStages.WithNewParameter { /** * Executes the create request. * @@ -203,6 +203,19 @@ interface WithParameter { */ WithCreate withParameter(String parameter); } + + /** + * The stage of the TopLevelArmResource definition allowing to specify newParameter. + */ + interface WithNewParameter { + /** + * Specifies the newParameter property: The newParameter parameter. + * + * @param newParameter The newParameter parameter. + * @return the next definition stage. + */ + WithCreate withNewParameter(String newParameter); + } } /** @@ -215,7 +228,8 @@ interface WithParameter { /** * The template for TopLevelArmResource update. */ - interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties, UpdateStages.WithParameter { + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties, UpdateStages.WithParameter, + UpdateStages.WithNewParameter { /** * Executes the update request. * @@ -274,6 +288,19 @@ interface WithParameter { */ Update withParameter(String parameter); } + + /** + * The stage of the TopLevelArmResource update allowing to specify newParameter. + */ + interface WithNewParameter { + /** + * Specifies the newParameter property: The newParameter parameter. + * + * @param newParameter The newParameter parameter. + * @return the next definition stage. + */ + Update withNewParameter(String newParameter); + } } /** From 7648f098d05019fc70cfaeb439cb4ccf68202a8e Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 15:18:57 +0800 Subject: [PATCH 25/50] update test --- .../armversioned/ArmVersionedTests.java | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java index 662bb9bd95a..18adfae6d7c 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java @@ -3,38 +3,70 @@ package tsptest.armversioned; +import com.azure.core.management.Region; import com.azure.core.util.Context; import org.mockito.Mockito; import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; +import tsptest.armversioned.models.TopLevelArmResource; public class ArmVersionedTests { // only to test compilation public void testVersionedApi() { ArmVersionedManager manager = Mockito.mock(ArmVersionedManager.class); - TopLevelArmResourceInner resource = Mockito.mock(TopLevelArmResourceInner.class); + TopLevelArmResourceInner resourceInner = Mockito.mock(TopLevelArmResourceInner.class); // API without optional parameter // this API exists in all versions - manager.serviceClient().getTopLevelArmResources().createOrUpdate("resourceGroup", "resourceName", resource); manager.topLevelArmResources().list(); + manager.topLevelArmResources().action("resourceGroup", "resourceName"); - // API in 2024-12-01 manager.serviceClient() .getTopLevelArmResources() - .createOrUpdate("resourceGroup", "resourceName", resource, "parameter", "newParameter", Context.NONE); + .createOrUpdate("resourceGroup", "resourceName", resourceInner); + TopLevelArmResource resource = manager.topLevelArmResources() + .define("resourceName") + .withRegion(Region.US_WEST3) + .withExistingResourceGroup("resourceGroup") + .create(); + + resource.update().apply(); + + // API in 2024-12-01 manager.topLevelArmResources().list("parameter", "newParameter", Context.NONE); manager.topLevelArmResources() .actionWithResponse("resourceGroup", "resourceName", "parameter", "newParameter", Context.NONE); + manager.serviceClient() + .getTopLevelArmResources() + .createOrUpdate("resourceGroup", "resourceName", resourceInner, "parameter", "newParameter", Context.NONE); + manager.topLevelArmResources() + .define("resourceName") + .withRegion(Region.US_WEST3) + .withExistingResourceGroup("resourceGroup") + .withParameter("parameter") + .create(); + + resource.update().withParameter("parameter").apply(); + // API in 2023-12-01 // this op will be generated, if tspconfig has "advanced-versioning" option // REST API allow adding optional parameter to operation - manager.serviceClient() - .getTopLevelArmResources() - .createOrUpdate("resourceGroup", "resourceName", resource, "parameter", Context.NONE); manager.topLevelArmResources().list("parameter", Context.NONE); manager.topLevelArmResources().actionWithResponse("resourceGroup", "resourceName", "parameter", Context.NONE); + + manager.serviceClient() + .getTopLevelArmResources() + .createOrUpdate("resourceGroup", "resourceName", resourceInner, "parameter", Context.NONE); + manager.topLevelArmResources() + .define("resourceName") + .withRegion(Region.US_WEST3) + .withExistingResourceGroup("resourceGroup") + .withParameter("parameter") + .withNewParameter("newParameter") + .create(); + + resource.update().withParameter("parameter").withNewParameter("newParameter").apply(); } } From 499120522a156e0290c7a1f868ed7ba60dc2e6b9 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 15:27:24 +0800 Subject: [PATCH 26/50] make a diff --- .../http-client-generator-test/Generate.ps1 | 3 - .../fluent/TopLevelArmResourcesClient.java | 65 --------- .../TopLevelArmResourceImpl.java | 13 +- .../TopLevelArmResourcesClientImpl.java | 127 ------------------ .../TopLevelArmResourcesImpl.java | 11 -- .../models/TopLevelArmResource.java | 12 -- .../models/TopLevelArmResources.java | 27 ---- 7 files changed, 4 insertions(+), 254 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 index 2ca6a7e0283..d344a462f98 100644 --- a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 +++ b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 @@ -107,9 +107,6 @@ $generateScript = { $tspOptions += " --option ""@typespec/http-client-java.generate-tests=false""" # add customization code $tspOptions += " --option ""@typespec/http-client-java.customization-class=../../customization/src/main/java/KeyVaultCustomization.java""" - } elseif ($tspFile -match "tsp[\\/]arm-versioned.tsp") { - # enable advanced versioning for resiliency test - $tspOptions += " --option ""@typespec/http-client-java.advanced-versioning=true""" } elseif ($tspFile -match "tsp[\\/]subclient.tsp") { $tspOptions += " --option ""@typespec/http-client-java.enable-subclient=true""" # test for include-api-view-properties diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java index ece0dd48031..b9ae081b543 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -17,25 +17,6 @@ * An instance of this class provides access to all the operations defined in TopLevelArmResourcesClient. */ public interface TopLevelArmResourcesClient { - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this - * type using a specific property type. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( - String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, - String parameter, Context context); - /** * Create a TopLevelArmResource. * @@ -72,23 +53,6 @@ SyncPoller, TopLevelArmResourceInner> begin String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return concrete tracked resource types can be created by aliasing this type using a specific property type. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource, String parameter, Context context); - /** * Create a TopLevelArmResource. * @@ -122,19 +86,6 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); - /** - * List TopLevelArmResource resources by subscription ID. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - PagedIterable list(String parameter, Context context); - /** * List TopLevelArmResource resources by subscription ID. * @@ -159,22 +110,6 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve @ServiceMethod(returns = ReturnType.COLLECTION) PagedIterable list(String parameter, String newParameter, Context context); - /** - * A synchronous resource action. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); - /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java index b1b8de027c2..0d4654dd035 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -94,7 +94,7 @@ public TopLevelArmResource create() { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, - Context.NONE); + createNewParameter, Context.NONE); return this; } @@ -102,7 +102,7 @@ public TopLevelArmResource create(Context context) { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, - context); + createNewParameter, context); return this; } @@ -124,7 +124,7 @@ public TopLevelArmResource apply() { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, - Context.NONE); + updateNewParameter, Context.NONE); return this; } @@ -132,7 +132,7 @@ public TopLevelArmResource apply(Context context) { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, - context); + updateNewParameter, context); return this; } @@ -145,11 +145,6 @@ public TopLevelArmResource apply(Context context) { = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "topLevelArmResources"); } - public Response actionWithResponse(String parameter, Context context) { - return serviceManager.topLevelArmResources() - .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); - } - public Response actionWithResponse(String parameter, String newParameter, Context context) { return serviceManager.topLevelArmResources() .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java index 130c5327568..ec992783194 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -202,32 +202,6 @@ private Response createOrUpdateWithResponse(String resourceGroupName newParameter, contentType, accept, resource, Context.NONE); } - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return concrete tracked resource types can be created by aliasing this type using a specific property type along - * with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private Response createOrUpdateWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, - Context context) { - final String newParameter = null; - final String contentType = "application/json"; - final String accept = "application/json"; - return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, contentType, accept, resource, context); - } - /** * Create a TopLevelArmResource. * @@ -327,30 +301,6 @@ public SyncPoller, TopLevelArmResourceInner TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, Context.NONE); } - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this - * type using a specific property type. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( - String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, - String parameter, Context context) { - Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, - resource, parameter, context); - return this.client.getLroResult(response, - TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); - } - /** * Create a TopLevelArmResource. * @@ -442,26 +392,6 @@ private Mono createOrUpdateAsync(String resourceGroupN newParameter).last().flatMap(this.client::getLroFinalResultOrError); } - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return concrete tracked resource types can be created by aliasing this type using a specific property type. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource, String parameter, Context context) { - return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, context) - .getFinalResult(); - } - /** * Create a TopLevelArmResource. * @@ -576,26 +506,6 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } - /** - * List TopLevelArmResource resources by subscription ID. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listSinglePage(String parameter, Context context) { - final String newParameter = null; - final String accept = "application/json"; - Response res = service.listSync(this.client.getEndpoint(), - this.client.getApiVersion(), this.client.getSubscriptionId(), parameter, newParameter, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), - res.getValue().nextLink(), null); - } - /** * List TopLevelArmResource resources by subscription ID. * @@ -617,22 +527,6 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } - /** - * List TopLevelArmResource resources by subscription ID. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable list(String parameter, Context context) { - return new PagedIterable<>(() -> listSinglePage(parameter, context), - nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); - } - /** * List TopLevelArmResource resources by subscription ID. * @@ -705,27 +599,6 @@ private Mono actionAsync(String resourceGroupName, String topLevelArmResou .flatMap(ignored -> Mono.empty()); } - /** - * A synchronous resource action. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { - final String newParameter = null; - return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, context); - } - /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java index eece1e1bf8a..939c9182d96 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -26,11 +26,6 @@ public TopLevelArmResourcesImpl(TopLevelArmResourcesClient innerClient, this.serviceManager = serviceManager; } - public PagedIterable list(String parameter, Context context) { - PagedIterable inner = this.serviceClient().list(parameter, context); - return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); - } - public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); @@ -41,12 +36,6 @@ public PagedIterable list(String parameter, String newParam return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } - public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { - return this.serviceClient() - .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); - } - public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { return this.serviceClient() diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java index 0d732398d29..48b1e22b1fe 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -303,18 +303,6 @@ interface WithNewParameter { } } - /** - * A synchronous resource action. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - Response actionWithResponse(String parameter, Context context); - /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java index 8f674319d57..6bbc222bfbd 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -12,18 +12,6 @@ * Resource collection API of TopLevelArmResources. */ public interface TopLevelArmResources { - /** - * List TopLevelArmResource resources by subscription ID. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. - */ - PagedIterable list(String parameter, Context context); - /** * List TopLevelArmResource resources by subscription ID. * @@ -46,21 +34,6 @@ public interface TopLevelArmResources { */ PagedIterable list(String parameter, String newParameter, Context context); - /** - * A synchronous resource action. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); - /** * A synchronous resource action. * From 2fe0045b75f1b231dd532956edee615df5582bc6 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 15:27:33 +0800 Subject: [PATCH 27/50] Revert "make a diff" This reverts commit 499120522a156e0290c7a1f868ed7ba60dc2e6b9. --- .../http-client-generator-test/Generate.ps1 | 3 + .../fluent/TopLevelArmResourcesClient.java | 65 +++++++++ .../TopLevelArmResourceImpl.java | 13 +- .../TopLevelArmResourcesClientImpl.java | 127 ++++++++++++++++++ .../TopLevelArmResourcesImpl.java | 11 ++ .../models/TopLevelArmResource.java | 12 ++ .../models/TopLevelArmResources.java | 27 ++++ 7 files changed, 254 insertions(+), 4 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 index d344a462f98..2ca6a7e0283 100644 --- a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 +++ b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 @@ -107,6 +107,9 @@ $generateScript = { $tspOptions += " --option ""@typespec/http-client-java.generate-tests=false""" # add customization code $tspOptions += " --option ""@typespec/http-client-java.customization-class=../../customization/src/main/java/KeyVaultCustomization.java""" + } elseif ($tspFile -match "tsp[\\/]arm-versioned.tsp") { + # enable advanced versioning for resiliency test + $tspOptions += " --option ""@typespec/http-client-java.advanced-versioning=true""" } elseif ($tspFile -match "tsp[\\/]subclient.tsp") { $tspOptions += " --option ""@typespec/http-client-java.enable-subclient=true""" # test for include-api-view-properties diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java index b9ae081b543..ece0dd48031 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -17,6 +17,25 @@ * An instance of this class provides access to all the operations defined in TopLevelArmResourcesClient. */ public interface TopLevelArmResourcesClient { + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, Context context); + /** * Create a TopLevelArmResource. * @@ -53,6 +72,23 @@ SyncPoller, TopLevelArmResourceInner> begin String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource, String parameter, Context context); + /** * Create a TopLevelArmResource. * @@ -86,6 +122,19 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String parameter, Context context); + /** * List TopLevelArmResource resources by subscription ID. * @@ -110,6 +159,22 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve @ServiceMethod(returns = ReturnType.COLLECTION) PagedIterable list(String parameter, String newParameter, Context context); + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java index 0d4654dd035..b1b8de027c2 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -94,7 +94,7 @@ public TopLevelArmResource create() { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, - createNewParameter, Context.NONE); + Context.NONE); return this; } @@ -102,7 +102,7 @@ public TopLevelArmResource create(Context context) { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, - createNewParameter, context); + context); return this; } @@ -124,7 +124,7 @@ public TopLevelArmResource apply() { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, - updateNewParameter, Context.NONE); + Context.NONE); return this; } @@ -132,7 +132,7 @@ public TopLevelArmResource apply(Context context) { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, - updateNewParameter, context); + context); return this; } @@ -145,6 +145,11 @@ public TopLevelArmResource apply(Context context) { = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "topLevelArmResources"); } + public Response actionWithResponse(String parameter, Context context) { + return serviceManager.topLevelArmResources() + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + public Response actionWithResponse(String parameter, String newParameter, Context context) { return serviceManager.topLevelArmResources() .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java index ec992783194..130c5327568 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -202,6 +202,32 @@ private Response createOrUpdateWithResponse(String resourceGroupName newParameter, contentType, accept, resource, Context.NONE); } + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, + Context context) { + final String newParameter = null; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, contentType, accept, resource, context); + } + /** * Create a TopLevelArmResource. * @@ -301,6 +327,30 @@ public SyncPoller, TopLevelArmResourceInner TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, Context.NONE); } + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, Context context) { + Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, + resource, parameter, context); + return this.client.getLroResult(response, + TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); + } + /** * Create a TopLevelArmResource. * @@ -392,6 +442,26 @@ private Mono createOrUpdateAsync(String resourceGroupN newParameter).last().flatMap(this.client::getLroFinalResultOrError); } + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource, String parameter, Context context) { + return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, context) + .getFinalResult(); + } + /** * Create a TopLevelArmResource. * @@ -506,6 +576,26 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String parameter, Context context) { + final String newParameter = null; + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), parameter, newParameter, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + /** * List TopLevelArmResource resources by subscription ID. * @@ -527,6 +617,22 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String parameter, Context context) { + return new PagedIterable<>(() -> listSinglePage(parameter, context), + nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); + } + /** * List TopLevelArmResource resources by subscription ID. * @@ -599,6 +705,27 @@ private Mono actionAsync(String resourceGroupName, String topLevelArmResou .flatMap(ignored -> Mono.empty()); } + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + final String newParameter = null; + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java index 939c9182d96..eece1e1bf8a 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -26,6 +26,11 @@ public TopLevelArmResourcesImpl(TopLevelArmResourcesClient innerClient, this.serviceManager = serviceManager; } + public PagedIterable list(String parameter, Context context) { + PagedIterable inner = this.serviceClient().list(parameter, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); @@ -36,6 +41,12 @@ public PagedIterable list(String parameter, String newParam return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + return this.serviceClient() + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { return this.serviceClient() diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java index 48b1e22b1fe..0d732398d29 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -303,6 +303,18 @@ interface WithNewParameter { } } + /** + * A synchronous resource action. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response actionWithResponse(String parameter, Context context); + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java index 6bbc222bfbd..8f674319d57 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -12,6 +12,18 @@ * Resource collection API of TopLevelArmResources. */ public interface TopLevelArmResources { + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(String parameter, Context context); + /** * List TopLevelArmResource resources by subscription ID. * @@ -34,6 +46,21 @@ public interface TopLevelArmResources { */ PagedIterable list(String parameter, String newParameter, Context context); + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); + /** * A synchronous resource action. * From 0686df8a52d378630a520a6615b1b540aee510b2 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 15:57:01 +0800 Subject: [PATCH 28/50] comment --- .../generator/core/mapper/ClientMethodMapper.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index 371b3664d39..f0917251f33 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -362,17 +362,20 @@ protected void createOverloadForVersioning(List methods, ClientMet final List parameters = baseMethod.getParameters(); if (!isProtocolMethod) { if (parameters.stream().anyMatch(p -> p.getVersioning() != null && p.getVersioning().getAdded() != null)) { + // versioning of @added exists final List> signatures = findOverloadedSignatures(parameters); for (List overloadedParameters : signatures) { if (JavaSettings.getInstance().isDataPlaneClient() && (clientMethodType != ClientMethodType.SimpleSyncRestResponse && clientMethodType != ClientMethodType.SimpleAsyncRestResponse)) { + // For DPG final ClientMethod overloadedMethod = baseMethod.newBuilder().parameters(overloadedParameters).build(); methods.add(overloadedMethod); } else if (!JavaSettings.getInstance().isDataPlaneClient() && (clientMethodType != ClientMethodType.SimpleAsync && clientMethodType != ClientMethodType.SimpleSync)) { + // For non-DPG, overload on simple op / pageable op / LRO (with Context) ClientMethod.Builder overloadedMethodBuilder = baseMethod.newBuilder().parameters(overloadedParameters); if (methodPageDetailsWithContext != null) { @@ -474,6 +477,7 @@ private void createSinglePageClientMethods(boolean isSync, ClientMethod baseMeth methods.add(singlePageMethod); } + // Pageable op '[Operation]SinglePage' overloads for versioning createOverloadForVersioning(methods, singlePageMethod, methodWithContextVisibility, null, isProtocolMethod); // Generate '[Operation]SinglePage' overload with all parameters and Context. @@ -528,7 +532,7 @@ private void createPageStreamingClientMethods(boolean isSync, ClientMethod baseM if (settings.getSyncMethods() != SyncMethodsGeneration.NONE) { // generate the overload, if "sync-methods != NONE" methods.add(pagingMethod); - // overload for versioning + // Pageable op '[Operation]' overloads for versioning createOverloadForVersioning(methods, pagingMethod, methodWithContextVisibility, methodPageDetailsWithContext, isProtocolMethod); } @@ -597,6 +601,7 @@ private void createLroWithResponseClientMethods(boolean isSync, ClientMethod bas .build(); methods.add(withResponseMethod); + // LRO '[Operation]WithResponse' overloads for versioning createOverloadForVersioning(methods, withResponseMethod, methodWithContextVisibility, null, isProtocolMethod); addClientMethodWithContext(methods, withResponseMethod, methodWithContextVisibility, isProtocolMethod); @@ -639,6 +644,7 @@ private void createFluentLroWithResponseSyncClientMethods(Operation operation, C .build(); methods.add(withResponseSyncMethod); + // LRO '[Operation]' overloads for versioning createOverloadForVersioning(methods, withResponseSyncMethod, NOT_VISIBLE, null, isProtocolMethod); addClientMethodWithContext(methods, withResponseSyncMethod, NOT_VISIBLE, isProtocolMethod); @@ -792,7 +798,7 @@ private void createSimpleWithResponseClientMethods(boolean isSync, ClientMethod .methodVisibility(methodVisibility) .build(); - // overload for versioning + // Simple op '[Operation]WithResponse' overloads for versioning createOverloadForVersioning(methods, withResponseMethod, methodWithContextVisibility, null, isProtocolMethod); // Always generate an overload of WithResponse with non-required parameters without Context. It is only for sync @@ -838,7 +844,7 @@ private void createSimpleValueClientMethods(boolean isSync, ClientMethod baseMet .build(); methods.add(simpleMethod); - // overload for versioning + // Simple op '[Operation]' overloads for versioning createOverloadForVersioning(methods, simpleMethod, methodWithContextVisibility, null, isProtocolMethod); if (generateRequiredOnlyParametersOverload) { From 1f57aedab5db7bf2374581e1c8df00bd1a81efaa Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 15:57:39 +0800 Subject: [PATCH 29/50] delete type that not used --- .../generator/core/model/clientmodel/ClientMethodType.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethodType.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethodType.java index 37f9cd5dabc..59e8eaa270c 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethodType.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethodType.java @@ -23,8 +23,6 @@ public enum ClientMethodType { * Mono<PagedResponseBase<H,T>>. */ PagingAsyncSinglePage(2, true, false, false), - SimulatedPagingSync(3, false, false, true), // unused - SimulatedPagingAsync(4, false, false, false), // unused /** * represents long-running method that returns T where T is the final result of the LRO. */ From 218b6ba23387c0570ce171f296c2194fa8a2601e Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 25 Nov 2025 16:10:23 +0800 Subject: [PATCH 30/50] we can remove the condition --- .../generator/core/mapper/ClientMethodMapper.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index f0917251f33..dde32c6f53d 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -365,17 +365,13 @@ protected void createOverloadForVersioning(List methods, ClientMet // versioning of @added exists final List> signatures = findOverloadedSignatures(parameters); for (List overloadedParameters : signatures) { - if (JavaSettings.getInstance().isDataPlaneClient() - && (clientMethodType != ClientMethodType.SimpleSyncRestResponse - && clientMethodType != ClientMethodType.SimpleAsyncRestResponse)) { - // For DPG + if (JavaSettings.getInstance().isDataPlaneClient()) { + // DPG final ClientMethod overloadedMethod = baseMethod.newBuilder().parameters(overloadedParameters).build(); methods.add(overloadedMethod); - } else if (!JavaSettings.getInstance().isDataPlaneClient() - && (clientMethodType != ClientMethodType.SimpleAsync - && clientMethodType != ClientMethodType.SimpleSync)) { - // For non-DPG, overload on simple op / pageable op / LRO (with Context) + } else { + // non-DPG ClientMethod.Builder overloadedMethodBuilder = baseMethod.newBuilder().parameters(overloadedParameters); if (methodPageDetailsWithContext != null) { From ccf67b6a21a18c1461258515558972ce97a89f99 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 10:43:54 +0800 Subject: [PATCH 31/50] Update packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../client/generator/core/template/ClientMethodTemplate.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index 071229d253c..9e1344da637 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -169,10 +169,7 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client boolean optionalOmitted = !parameter.isRequired() && parameter.getClientType() != ClassType.CONTEXT; if (optionalOmitted) { boolean parameterInClientMethodSignature = methodParameters.stream() - .filter(p -> p.getProxyMethodParameter() == parameter) - .findFirst() - .map(p -> p.getClientMethodParameter()) - .isPresent(); + .anyMatch(p -> p.getProxyMethodParameter() == parameter); // if the parameter is defined in client method signature, // it does not need to be instantiated in local variable. optionalOmitted = !parameterInClientMethodSignature; From 7c93f904c59c8533104dfc5080d5f790a8060c70 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 10:49:11 +0800 Subject: [PATCH 32/50] format --- .../client/generator/core/template/ClientMethodTemplate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index 9e1344da637..2da67af3e72 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -168,8 +168,8 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client // parameters are omitted and will need to instantiated in the method. boolean optionalOmitted = !parameter.isRequired() && parameter.getClientType() != ClassType.CONTEXT; if (optionalOmitted) { - boolean parameterInClientMethodSignature = methodParameters.stream() - .anyMatch(p -> p.getProxyMethodParameter() == parameter); + boolean parameterInClientMethodSignature + = methodParameters.stream().anyMatch(p -> p.getProxyMethodParameter() == parameter); // if the parameter is defined in client method signature, // it does not need to be instantiated in local variable. optionalOmitted = !parameterInClientMethodSignature; From e7309497762f220b7b01f5ee66031e167e2c2deb Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 16:25:39 +0800 Subject: [PATCH 33/50] add more API to test case --- .../generator/http-client-generator-test/tsp/arm-versioned.tsp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp index c97b3d0f8f4..1dc537045bc 100644 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp @@ -47,6 +47,9 @@ model Response {} interface TopLevelArmResources { createOrUpdate is ArmResourceCreateOrUpdateAsync; listBySubscription is ArmListBySubscription; + listByResourceGroup is ArmResourceListByParent; + get is ArmResourceRead; + delete is ArmResourceDeleteWithoutOkAsync; action is ArmResourceActionSync< TopLevelArmResource, Request = void, From f4f44617175e991c6cbc196951e36ab95d96fcb2 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 16:39:03 +0800 Subject: [PATCH 34/50] bug fix for not taking the client method of full parameters --- .../fluentmodel/ResourceOperation.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java index 70c8190ae4a..1c3983adde3 100644 --- a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java +++ b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/ResourceOperation.java @@ -131,7 +131,7 @@ private List getParametersByLocation(RequestParameterLocation p } private List getParametersByLocation(Set parameterLocations) { - ClientMethod clientMethod = getClientMethodOfFullParameters(); + ClientMethod clientMethod = getMethodReferencesOfFullParameters().iterator().next().getInnerClientMethod(); Map proxyMethodParameterByClientParameterName = clientMethod.getProxyMethod() .getParameters() .stream() @@ -145,18 +145,6 @@ private List getParametersByLocation(Set collectionMethods = getMethodReferencesOfFullParameters(); - // take the client method with longest parameters - // it should be the client method of full parameters - collectionMethods.sort((m1, m2) -> { - int count1 = m1.getInnerClientMethod().getParameters().size(); - int count2 = m2.getInnerClientMethod().getParameters().size(); - return -Integer.compare(count1, count2); - }); - return collectionMethods.get(0).getInnerClientMethod(); - } - public ClientMethodParameter getBodyParameter() { List parameters = getParametersByLocation(RequestParameterLocation.BODY); return parameters.isEmpty() ? null : parameters.iterator().next().getClientMethodParameter(); @@ -178,11 +166,21 @@ public Collection getLocalVariables() { return this.getResourceLocalVariables().getLocalVariablesMap().values(); } + /** + * Gets the method references, filter out those with only required parameters. + * + * @return the method references returns is sorted by the number of parameters in descending order. + */ protected List getMethodReferencesOfFullParameters() { // method references of full parameters (include optional parameters) return this.getMethodReferences() .stream() .filter(m -> !m.getInnerClientMethod().getOnlyRequiredParameters()) + .sorted((m1, m2) -> { + int count1 = m1.getInnerClientMethod().getParameters().size(); + int count2 = m2.getInnerClientMethod().getParameters().size(); + return -Integer.compare(count1, count2); + }) .collect(Collectors.toList()); } From dd89acb1ae8a65dd9c57245832304d477f40016b Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 16:47:28 +0800 Subject: [PATCH 35/50] regen --- .../fluent/TopLevelArmResourcesClient.java | 177 ++++ .../TopLevelArmResourceImpl.java | 30 +- .../TopLevelArmResourcesClientImpl.java | 835 ++++++++++++++++-- .../TopLevelArmResourcesImpl.java | 140 +++ .../models/TopLevelArmResource.java | 15 + .../models/TopLevelArmResources.java | 170 ++++ ...ersioned-generated_apiview_properties.json | 5 + ...nager-armversioned-generated_metadata.json | 2 +- 8 files changed, 1312 insertions(+), 62 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java index ece0dd48031..0bb8f757661 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -159,6 +159,183 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve @ServiceMethod(returns = ReturnType.COLLECTION) PagedIterable list(String parameter, String newParameter, Context context); + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + Context context); + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + String newParameter, Context context); + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, Context context); + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context); + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner getByResourceGroup(String resourceGroupName, String topLevelArmResourcePropertiesName); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourcePropertiesName); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, Context context); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String topLevelArmResourcePropertiesName); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, + String newParameter, Context context); + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java index b1b8de027c2..6d9d1e0eba8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -94,7 +94,7 @@ public TopLevelArmResource create() { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, - Context.NONE); + createNewParameter, Context.NONE); return this; } @@ -102,7 +102,7 @@ public TopLevelArmResource create(Context context) { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), createParameter, - context); + createNewParameter, context); return this; } @@ -124,7 +124,7 @@ public TopLevelArmResource apply() { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, - Context.NONE); + updateNewParameter, Context.NONE); return this; } @@ -132,7 +132,7 @@ public TopLevelArmResource apply(Context context) { this.innerObject = serviceManager.serviceClient() .getTopLevelArmResources() .createOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, this.innerModel(), updateParameter, - context); + updateNewParameter, context); return this; } @@ -145,6 +145,28 @@ public TopLevelArmResource apply(Context context) { = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "topLevelArmResources"); } + public TopLevelArmResource refresh() { + String localParameter = null; + String localNewParameter = null; + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResources() + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, localParameter, + localNewParameter, Context.NONE) + .getValue(); + return this; + } + + public TopLevelArmResource refresh(Context context) { + String localParameter = null; + String localNewParameter = null; + this.innerObject = serviceManager.serviceClient() + .getTopLevelArmResources() + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, localParameter, + localNewParameter, context) + .getValue(); + return this; + } + public Response actionWithResponse(String parameter, Context context) { return serviceManager.topLevelArmResources() .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java index 130c5327568..66753a1700b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -5,6 +5,7 @@ package tsptest.armversioned.implementation; import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; import com.azure.core.annotation.ExpectedResponses; import com.azure.core.annotation.Get; import com.azure.core.annotation.HeaderParam; @@ -111,6 +112,68 @@ Response listSync(@HostParam("endpoint") String e @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, @HeaderParam("Accept") String accept, Context context); + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @QueryParam("parameter") String parameter, + @QueryParam("newParameter") String newParameter, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @QueryParam("parameter") String parameter, + @QueryParam("newParameter") String newParameter, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, + @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, + Context context); + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}/action") @ExpectedResponses({ 200 }) @@ -148,6 +211,22 @@ Mono> listBySubscriptionNext( Response listBySubscriptionNextSync( @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByResourceGroupNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); } /** @@ -666,157 +745,799 @@ public PagedIterable list(String parameter, String new } /** - * A synchronous resource action. + * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. * @param newParameter The newParameter parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> actionWithResponseAsync(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, String newParameter) { + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName, + String parameter, String newParameter) { + final String accept = "application/json"; return FluxUtil - .withContext(context -> service.action(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, context)) + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, parameter, newParameter, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** - * A synchronous resource action. + * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedFlux}. */ - @ServiceMethod(returns = ReturnType.SINGLE) - private Mono actionAsync(String resourceGroupName, String topLevelArmResourcePropertiesName) { + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, String parameter, + String newParameter) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, parameter, newParameter), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { final String parameter = null; final String newParameter = null; - return actionWithResponseAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter) - .flatMap(ignored -> Mono.empty()); + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, parameter, newParameter), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); } /** - * A synchronous resource action. + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByResourceGroupSinglePage(String resourceGroupName, + String parameter, String newParameter) { + final String accept = "application/json"; + Response res + = service.listByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, parameter, newParameter, accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + private PagedResponse listByResourceGroupSinglePage(String resourceGroupName, String parameter, Context context) { final String newParameter = null; - return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, context); + final String accept = "application/json"; + Response res + = service.listByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, parameter, newParameter, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); } /** - * A synchronous resource action. + * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + private PagedResponse listByResourceGroupSinglePage(String resourceGroupName, String parameter, String newParameter, Context context) { - return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, context); + final String accept = "application/json"; + Response res + = service.listByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, parameter, newParameter, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); } /** - * A synchronous resource action. + * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void action(String resourceGroupName, String topLevelArmResourcePropertiesName) { + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + Context context) { + return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName, parameter, context), + nextLink -> listByResourceGroupNextSinglePage(nextLink, context)); + } + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { final String parameter = null; final String newParameter = null; - actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, Context.NONE); + return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName, parameter, newParameter), + nextLink -> listByResourceGroupNextSinglePage(nextLink)); } /** - * Get the next page of items. + * List TopLevelArmResource resources by resource group. * - * @param nextLink The URL to get the next list of items. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse} on successful - * completion of {@link Mono}. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + String newParameter, Context context) { + return new PagedIterable<>( + () -> listByResourceGroupSinglePage(resourceGroupName, parameter, newParameter, context), + nextLink -> listByResourceGroupNextSinglePage(nextLink, context)); + } + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter) { final String accept = "application/json"; return FluxUtil - .withContext( - context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) - .>map(res -> new PagedResponseBase<>(res.getRequest(), - res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } /** - * Get the next page of items. + * Get a TopLevelArmResource. * - * @param nextLink The URL to get the next list of items. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + * @return a TopLevelArmResource on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listBySubscriptionNextSinglePage(String nextLink) { + private Mono getByResourceGroupAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + return getByResourceGroupWithResponseAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter).flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, Context context) { + final String newParameter = null; final String accept = "application/json"; - Response res - = service.listBySubscriptionNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), - res.getValue().nextLink(), null); + return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, accept, context); } /** - * Get the next page of items. + * Get a TopLevelArmResource. * - * @param nextLink The URL to get the next list of items. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + * @return a TopLevelArmResource along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listBySubscriptionNextSinglePage(String nextLink, Context context) { + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { final String accept = "application/json"; - Response res - = service.listBySubscriptionNextSync(nextLink, this.client.getEndpoint(), accept, context); + return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, accept, context); + } + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner getByResourceGroup(String resourceGroupName, + String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + return getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, Context.NONE).getValue(); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter) { + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter) { + return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, Context.NONE); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + final String newParameter = null; + return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context) { + return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter) { + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + Mono>> mono + = deleteWithResponseAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter) { + Response response + = deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter); + return this.client.getLroResult(response, Void.class, Void.class, Context.NONE); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, Context context) { + Response response + = deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + return this.client.getLroResult(response, Void.class, Void.class, context); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, + String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + Response response + = deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter); + return this.client.getLroResult(response, Void.class, Void.class, Context.NONE); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { + Response response = deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, + parameter, newParameter, context); + return this.client.getLroResult(response, Void.class, Void.class, context); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, + String newParameter) { + return beginDeleteAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + return beginDeleteAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, + Context context) { + beginDelete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context).getFinalResult(); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + beginDelete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter).getFinalResult(); + } + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, + String newParameter, Context context) { + beginDelete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context) + .getFinalResult(); + } + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> actionWithResponseAsync(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter) { + return FluxUtil + .withContext(context -> service.action(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono actionAsync(String resourceGroupName, String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + return actionWithResponseAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter) + .flatMap(ignored -> Mono.empty()); + } + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + final String newParameter = null; + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context) { + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void action(String resourceGroupName, String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, Context.NONE); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listBySubscriptionNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listBySubscriptionNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listBySubscriptionNextSinglePage(String nextLink, Context context) { + final String accept = "application/json"; + Response res + = service.listBySubscriptionNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink) { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByResourceGroupNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listByResourceGroupNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByResourceGroupNextSinglePage(String nextLink, + Context context) { + final String accept = "application/json"; + Response res + = service.listByResourceGroupNextSync(nextLink, this.client.getEndpoint(), accept, context); return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null); } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java index eece1e1bf8a..eaa43467b14 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -6,6 +6,7 @@ import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; import tsptest.armversioned.fluent.TopLevelArmResourcesClient; @@ -41,6 +42,75 @@ public PagedIterable list(String parameter, String newParam return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } + public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + Context context) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName, parameter, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + String newParameter, Context context) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName, parameter, newParameter, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, Context context) { + Response inner = this.serviceClient() + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new TopLevelArmResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { + Response inner = this.serviceClient() + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new TopLevelArmResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public TopLevelArmResource getByResourceGroup(String resourceGroupName, String topLevelArmResourcePropertiesName) { + TopLevelArmResourceInner inner + = this.serviceClient().getByResourceGroup(resourceGroupName, topLevelArmResourcePropertiesName); + if (inner != null) { + return new TopLevelArmResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, + Context context) { + this.serviceClient().delete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + + public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName) { + this.serviceClient().delete(resourceGroupName, topLevelArmResourcePropertiesName); + } + + public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, + String newParameter, Context context) { + this.serviceClient() + .delete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); + } + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, Context context) { return this.serviceClient() @@ -57,6 +127,76 @@ public void action(String resourceGroupName, String topLevelArmResourcePropertie this.serviceClient().action(resourceGroupName, topLevelArmResourcePropertiesName); } + public TopLevelArmResource getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String topLevelArmResourcePropertiesName + = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourcePropertiesName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String localParameter = null; + String localNewParameter = null; + return this + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, localParameter, + localNewParameter, Context.NONE) + .getValue(); + } + + public Response getByIdWithResponse(String id, String parameter, String newParameter, + Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String topLevelArmResourcePropertiesName + = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourcePropertiesName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String topLevelArmResourcePropertiesName + = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourcePropertiesName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + String localParameter = null; + String localNewParameter = null; + this.delete(resourceGroupName, topLevelArmResourcePropertiesName, localParameter, localNewParameter, + Context.NONE); + } + + public void deleteByIdWithResponse(String id, String parameter, String newParameter, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String topLevelArmResourcePropertiesName + = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourcePropertiesName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + this.delete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); + } + private TopLevelArmResourcesClient serviceClient() { return this.innerClient; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java index 0d732398d29..0305ff904a4 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -303,6 +303,21 @@ interface WithNewParameter { } } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + TopLevelArmResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + TopLevelArmResource refresh(Context context); + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java index 8f674319d57..aa8b376fca8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -46,6 +46,127 @@ public interface TopLevelArmResources { */ PagedIterable list(String parameter, String newParameter, Context context); + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, String parameter, Context context); + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + String newParameter, Context context); + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, Context context); + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context); + + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource. + */ + TopLevelArmResource getByResourceGroup(String resourceGroupName, String topLevelArmResourcePropertiesName); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, Context context); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String topLevelArmResourcePropertiesName); + + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, + String newParameter, Context context); + /** * A synchronous resource action. * @@ -88,6 +209,55 @@ Response actionWithResponse(String resourceGroupName, String topLevelArmRe */ void action(String resourceGroupName, String topLevelArmResourcePropertiesName); + /** + * Get a TopLevelArmResource. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + TopLevelArmResource getById(String id); + + /** + * Get a TopLevelArmResource. + * + * @param id the resource ID. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + Response getByIdWithResponse(String id, String parameter, String newParameter, + Context context); + + /** + * Delete a TopLevelArmResource. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a TopLevelArmResource. + * + * @param id the resource ID. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByIdWithResponse(String id, String parameter, String newParameter, Context context); + /** * Begins definition for a new TopLevelArmResource resource. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json index 496a507b97a..283a579746a 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json @@ -6,8 +6,13 @@ "tsptest.armversioned.fluent.TopLevelArmResourcesClient.action": "TspTest.ArmVersioned.TopLevelArmResources.action", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.actionWithResponse": "TspTest.ArmVersioned.TopLevelArmResources.action", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginCreateOrUpdate": "TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginDelete": "TspTest.ArmVersioned.TopLevelArmResources.delete", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.createOrUpdate": "TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.delete": "TspTest.ArmVersioned.TopLevelArmResources.delete", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroup": "TspTest.ArmVersioned.TopLevelArmResources.get", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroupWithResponse": "TspTest.ArmVersioned.TopLevelArmResources.get", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.list": "TspTest.ArmVersioned.TopLevelArmResources.listBySubscription", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.listByResourceGroup": "TspTest.ArmVersioned.TopLevelArmResources.listByResourceGroup", "tsptest.armversioned.fluent.models.TopLevelArmResourceInner": "TspTest.ArmVersioned.TopLevelArmResource", "tsptest.armversioned.implementation.ArmVersionedClientBuilder": "TspTest.ArmVersioned", "tsptest.armversioned.implementation.models.TopLevelArmResourceListResult": "Azure.ResourceManager.ResourceListResult", diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json index 3bad5e67907..0746900a92c 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json @@ -1 +1 @@ -{"flavor":"Azure","apiVersion":"2024-12-01","crossLanguageDefinitions":{"tsptest.armversioned.fluent.ArmVersionedClient":"TspTest.ArmVersioned","tsptest.armversioned.fluent.TopLevelArmResourcesClient":"TspTest.ArmVersioned.TopLevelArmResources","tsptest.armversioned.fluent.TopLevelArmResourcesClient.action":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.actionWithResponse":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginCreateOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.createOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.list":"TspTest.ArmVersioned.TopLevelArmResources.listBySubscription","tsptest.armversioned.fluent.models.TopLevelArmResourceInner":"TspTest.ArmVersioned.TopLevelArmResource","tsptest.armversioned.implementation.ArmVersionedClientBuilder":"TspTest.ArmVersioned","tsptest.armversioned.implementation.models.TopLevelArmResourceListResult":"Azure.ResourceManager.ResourceListResult","tsptest.armversioned.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","tsptest.armversioned.models.TopLevelArmResourceProperties":"TspTest.ArmVersioned.TopLevelArmResourceProperties"},"generatedFiles":["src/main/java/module-info.java","src/main/java/tsptest/armversioned/ArmVersionedManager.java","src/main/java/tsptest/armversioned/fluent/ArmVersionedClient.java","src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java","src/main/java/tsptest/armversioned/fluent/models/TopLevelArmResourceInner.java","src/main/java/tsptest/armversioned/fluent/models/package-info.java","src/main/java/tsptest/armversioned/fluent/package-info.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientBuilder.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java","src/main/java/tsptest/armversioned/implementation/ResourceManagerUtils.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java","src/main/java/tsptest/armversioned/implementation/models/TopLevelArmResourceListResult.java","src/main/java/tsptest/armversioned/implementation/package-info.java","src/main/java/tsptest/armversioned/models/ResourceProvisioningState.java","src/main/java/tsptest/armversioned/models/TopLevelArmResource.java","src/main/java/tsptest/armversioned/models/TopLevelArmResourceProperties.java","src/main/java/tsptest/armversioned/models/TopLevelArmResources.java","src/main/java/tsptest/armversioned/models/package-info.java","src/main/java/tsptest/armversioned/package-info.java"]} \ No newline at end of file +{"flavor":"Azure","apiVersion":"2024-12-01","crossLanguageDefinitions":{"tsptest.armversioned.fluent.ArmVersionedClient":"TspTest.ArmVersioned","tsptest.armversioned.fluent.TopLevelArmResourcesClient":"TspTest.ArmVersioned.TopLevelArmResources","tsptest.armversioned.fluent.TopLevelArmResourcesClient.action":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.actionWithResponse":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginCreateOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginDelete":"TspTest.ArmVersioned.TopLevelArmResources.delete","tsptest.armversioned.fluent.TopLevelArmResourcesClient.createOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.delete":"TspTest.ArmVersioned.TopLevelArmResources.delete","tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroup":"TspTest.ArmVersioned.TopLevelArmResources.get","tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroupWithResponse":"TspTest.ArmVersioned.TopLevelArmResources.get","tsptest.armversioned.fluent.TopLevelArmResourcesClient.list":"TspTest.ArmVersioned.TopLevelArmResources.listBySubscription","tsptest.armversioned.fluent.TopLevelArmResourcesClient.listByResourceGroup":"TspTest.ArmVersioned.TopLevelArmResources.listByResourceGroup","tsptest.armversioned.fluent.models.TopLevelArmResourceInner":"TspTest.ArmVersioned.TopLevelArmResource","tsptest.armversioned.implementation.ArmVersionedClientBuilder":"TspTest.ArmVersioned","tsptest.armversioned.implementation.models.TopLevelArmResourceListResult":"Azure.ResourceManager.ResourceListResult","tsptest.armversioned.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","tsptest.armversioned.models.TopLevelArmResourceProperties":"TspTest.ArmVersioned.TopLevelArmResourceProperties"},"generatedFiles":["src/main/java/module-info.java","src/main/java/tsptest/armversioned/ArmVersionedManager.java","src/main/java/tsptest/armversioned/fluent/ArmVersionedClient.java","src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java","src/main/java/tsptest/armversioned/fluent/models/TopLevelArmResourceInner.java","src/main/java/tsptest/armversioned/fluent/models/package-info.java","src/main/java/tsptest/armversioned/fluent/package-info.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientBuilder.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java","src/main/java/tsptest/armversioned/implementation/ResourceManagerUtils.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java","src/main/java/tsptest/armversioned/implementation/models/TopLevelArmResourceListResult.java","src/main/java/tsptest/armversioned/implementation/package-info.java","src/main/java/tsptest/armversioned/models/ResourceProvisioningState.java","src/main/java/tsptest/armversioned/models/TopLevelArmResource.java","src/main/java/tsptest/armversioned/models/TopLevelArmResourceProperties.java","src/main/java/tsptest/armversioned/models/TopLevelArmResources.java","src/main/java/tsptest/armversioned/models/package-info.java","src/main/java/tsptest/armversioned/package-info.java"]} \ No newline at end of file From 66dcfbac5485d14f6812c9570467cb394d5bb6a1 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 16:50:56 +0800 Subject: [PATCH 36/50] update test --- .../generator/http-client-generator-test/tsp/arm-versioned.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp index 1dc537045bc..413fa7e7505 100644 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/arm-versioned.tsp @@ -49,7 +49,7 @@ interface TopLevelArmResources { listBySubscription is ArmListBySubscription; listByResourceGroup is ArmResourceListByParent; get is ArmResourceRead; - delete is ArmResourceDeleteWithoutOkAsync; + delete is ArmResourceDeleteSync; action is ArmResourceActionSync< TopLevelArmResource, Request = void, From 55551cf2d9254e3bff8ad74445b7c39e9e85cb29 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 17:01:52 +0800 Subject: [PATCH 37/50] regen --- .../fluent/TopLevelArmResourcesClient.java | 55 +---- .../TopLevelArmResourcesClientImpl.java | 232 ++---------------- .../TopLevelArmResourcesImpl.java | 26 +- .../models/TopLevelArmResources.java | 20 +- ...ersioned-generated_apiview_properties.json | 2 +- ...nager-armversioned-generated_metadata.json | 2 +- 6 files changed, 51 insertions(+), 286 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java index 0bb8f757661..edc8c00e645 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -258,25 +258,12 @@ Response getByResourceGroupWithResponse(String resourc * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of long-running operation. + * @return the {@link Response}. */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourcePropertiesName, + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, Context context); - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of long-running operation. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourcePropertiesName); - /** * Delete a TopLevelArmResource. * @@ -288,25 +275,11 @@ SyncPoller, Void> beginDelete(String resourceGroupName, String * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of long-running operation. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - SyncPoller, Void> beginDelete(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter, Context context); - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, Context context); + Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context); /** * Delete a TopLevelArmResource. @@ -320,22 +293,6 @@ SyncPoller, Void> beginDelete(String resourceGroupName, String @ServiceMethod(returns = ReturnType.SINGLE) void delete(String resourceGroupName, String topLevelArmResourcePropertiesName); - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, - String newParameter, Context context); - /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java index 66753a1700b..491beba030b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -154,9 +154,9 @@ Response getByResourceGroupSync(@HostParam("endpoint") @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}") - @ExpectedResponses({ 202, 204 }) + @ExpectedResponses({ 200, 204 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono>> delete(@HostParam("endpoint") String endpoint, + Mono> delete(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, @@ -165,10 +165,10 @@ Mono>> delete(@HostParam("endpoint") String endpoint, @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmVersioned/topLevelArmResources/{topLevelArmResourcePropertiesName}") - @ExpectedResponses({ 202, 204 }) + @ExpectedResponses({ 200, 204 }) @UnexpectedResponseExceptionType(ManagementException.class) - Response deleteSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + Response deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourcePropertiesName") String topLevelArmResourcePropertiesName, @QueryParam("parameter") String parameter, @QueryParam("newParameter") String newParameter, @@ -1044,7 +1044,7 @@ public TopLevelArmResourceInner getByResourceGroup(String resourceGroupName, * @return the {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Mono>> deleteWithResponseAsync(String resourceGroupName, + private Mono> deleteWithResponseAsync(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter) { return FluxUtil .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), @@ -1058,19 +1058,17 @@ private Mono>> deleteWithResponseAsync(String resource * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response}. + * @return A {@link Mono} that completes when a successful response is received. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter) { - return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, Context.NONE); + private Mono deleteAsync(String resourceGroupName, String topLevelArmResourcePropertiesName) { + final String parameter = null; + final String newParameter = null; + return deleteWithResponseAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter) + .flatMap(ignored -> Mono.empty()); } /** @@ -1083,10 +1081,10 @@ private Response deleteWithResponse(String resourceGroupName, String * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response}. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, Context context) { final String newParameter = null; return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), @@ -1105,193 +1103,16 @@ private Response deleteWithResponse(String resourceGroupName, String * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body along with {@link Response}. + * @return the {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); } - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link PollerFlux} for polling of long-running operation. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, String newParameter) { - Mono>> mono - = deleteWithResponseAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter); - return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, - this.client.getContext()); - } - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link PollerFlux} for polling of long-running operation. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, - String topLevelArmResourcePropertiesName) { - final String parameter = null; - final String newParameter = null; - Mono>> mono - = deleteWithResponseAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter); - return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, - this.client.getContext()); - } - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of long-running operation. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller, Void> beginDelete(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, String newParameter) { - Response response - = deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter); - return this.client.getLroResult(response, Void.class, Void.class, Context.NONE); - } - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of long-running operation. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller, Void> beginDelete(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, Context context) { - Response response - = deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); - return this.client.getLroResult(response, Void.class, Void.class, context); - } - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of long-running operation. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller, Void> beginDelete(String resourceGroupName, - String topLevelArmResourcePropertiesName) { - final String parameter = null; - final String newParameter = null; - Response response - = deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter); - return this.client.getLroResult(response, Void.class, Void.class, Context.NONE); - } - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of long-running operation. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller, Void> beginDelete(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { - Response response = deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, - parameter, newParameter, context); - return this.client.getLroResult(response, Void.class, Void.class, context); - } - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private Mono deleteAsync(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, - String newParameter) { - return beginDeleteAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter).last() - .flatMap(this.client::getLroFinalResultOrError); - } - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private Mono deleteAsync(String resourceGroupName, String topLevelArmResourcePropertiesName) { - final String parameter = null; - final String newParameter = null; - return beginDeleteAsync(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter).last() - .flatMap(this.client::getLroFinalResultOrError); - } - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, - Context context) { - beginDelete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context).getFinalResult(); - } - /** * Delete a TopLevelArmResource. * @@ -1305,26 +1126,7 @@ public void delete(String resourceGroupName, String topLevelArmResourcePropertie public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName) { final String parameter = null; final String newParameter = null; - beginDelete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter).getFinalResult(); - } - - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, - String newParameter, Context context) { - beginDelete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context) - .getFinalResult(); + deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, Context.NONE); } /** diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java index eaa43467b14..a5bbca9cff1 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -96,19 +96,20 @@ public TopLevelArmResource getByResourceGroup(String resourceGroupName, String t } } - public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, - Context context) { - this.serviceClient().delete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + return this.serviceClient() + .deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); } - public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName) { - this.serviceClient().delete(resourceGroupName, topLevelArmResourcePropertiesName); + public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context) { + return this.serviceClient() + .deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); } - public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, - String newParameter, Context context) { - this.serviceClient() - .delete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); + public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName) { + this.serviceClient().delete(resourceGroupName, topLevelArmResourcePropertiesName); } public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, @@ -178,11 +179,11 @@ public void deleteById(String id) { } String localParameter = null; String localNewParameter = null; - this.delete(resourceGroupName, topLevelArmResourcePropertiesName, localParameter, localNewParameter, + this.deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, localParameter, localNewParameter, Context.NONE); } - public void deleteByIdWithResponse(String id, String parameter, String newParameter, Context context) { + public Response deleteByIdWithResponse(String id, String parameter, String newParameter, Context context) { String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); if (resourceGroupName == null) { throw LOGGER.logExceptionAsError(new IllegalArgumentException( @@ -194,7 +195,8 @@ public void deleteByIdWithResponse(String id, String parameter, String newParame throw LOGGER.logExceptionAsError(new IllegalArgumentException( String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); } - this.delete(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); + return this.deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, + context); } private TopLevelArmResourcesClient serviceClient() { diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java index aa8b376fca8..49404086ca2 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -138,34 +138,37 @@ Response getByResourceGroupWithResponse(String resourceGrou * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ - void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, Context context); + Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); /** * Delete a TopLevelArmResource. * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ - void delete(String resourceGroupName, String topLevelArmResourcePropertiesName); + Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, String newParameter, Context context); /** * Delete a TopLevelArmResource. * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. */ - void delete(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, - String newParameter, Context context); + void delete(String resourceGroupName, String topLevelArmResourcePropertiesName); /** * A synchronous resource action. @@ -255,8 +258,9 @@ Response getByIdWithResponse(String id, String parameter, S * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. */ - void deleteByIdWithResponse(String id, String parameter, String newParameter, Context context); + Response deleteByIdWithResponse(String id, String parameter, String newParameter, Context context); /** * Begins definition for a new TopLevelArmResource resource. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json index 283a579746a..6f845da1398 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_apiview_properties.json @@ -6,9 +6,9 @@ "tsptest.armversioned.fluent.TopLevelArmResourcesClient.action": "TspTest.ArmVersioned.TopLevelArmResources.action", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.actionWithResponse": "TspTest.ArmVersioned.TopLevelArmResources.action", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginCreateOrUpdate": "TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate", - "tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginDelete": "TspTest.ArmVersioned.TopLevelArmResources.delete", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.createOrUpdate": "TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.delete": "TspTest.ArmVersioned.TopLevelArmResources.delete", + "tsptest.armversioned.fluent.TopLevelArmResourcesClient.deleteWithResponse": "TspTest.ArmVersioned.TopLevelArmResources.delete", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroup": "TspTest.ArmVersioned.TopLevelArmResources.get", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroupWithResponse": "TspTest.ArmVersioned.TopLevelArmResources.get", "tsptest.armversioned.fluent.TopLevelArmResourcesClient.list": "TspTest.ArmVersioned.TopLevelArmResources.listBySubscription", diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json index 0746900a92c..5eb8d805513 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/azure-resourcemanager-armversioned-generated_metadata.json @@ -1 +1 @@ -{"flavor":"Azure","apiVersion":"2024-12-01","crossLanguageDefinitions":{"tsptest.armversioned.fluent.ArmVersionedClient":"TspTest.ArmVersioned","tsptest.armversioned.fluent.TopLevelArmResourcesClient":"TspTest.ArmVersioned.TopLevelArmResources","tsptest.armversioned.fluent.TopLevelArmResourcesClient.action":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.actionWithResponse":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginCreateOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginDelete":"TspTest.ArmVersioned.TopLevelArmResources.delete","tsptest.armversioned.fluent.TopLevelArmResourcesClient.createOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.delete":"TspTest.ArmVersioned.TopLevelArmResources.delete","tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroup":"TspTest.ArmVersioned.TopLevelArmResources.get","tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroupWithResponse":"TspTest.ArmVersioned.TopLevelArmResources.get","tsptest.armversioned.fluent.TopLevelArmResourcesClient.list":"TspTest.ArmVersioned.TopLevelArmResources.listBySubscription","tsptest.armversioned.fluent.TopLevelArmResourcesClient.listByResourceGroup":"TspTest.ArmVersioned.TopLevelArmResources.listByResourceGroup","tsptest.armversioned.fluent.models.TopLevelArmResourceInner":"TspTest.ArmVersioned.TopLevelArmResource","tsptest.armversioned.implementation.ArmVersionedClientBuilder":"TspTest.ArmVersioned","tsptest.armversioned.implementation.models.TopLevelArmResourceListResult":"Azure.ResourceManager.ResourceListResult","tsptest.armversioned.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","tsptest.armversioned.models.TopLevelArmResourceProperties":"TspTest.ArmVersioned.TopLevelArmResourceProperties"},"generatedFiles":["src/main/java/module-info.java","src/main/java/tsptest/armversioned/ArmVersionedManager.java","src/main/java/tsptest/armversioned/fluent/ArmVersionedClient.java","src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java","src/main/java/tsptest/armversioned/fluent/models/TopLevelArmResourceInner.java","src/main/java/tsptest/armversioned/fluent/models/package-info.java","src/main/java/tsptest/armversioned/fluent/package-info.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientBuilder.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java","src/main/java/tsptest/armversioned/implementation/ResourceManagerUtils.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java","src/main/java/tsptest/armversioned/implementation/models/TopLevelArmResourceListResult.java","src/main/java/tsptest/armversioned/implementation/package-info.java","src/main/java/tsptest/armversioned/models/ResourceProvisioningState.java","src/main/java/tsptest/armversioned/models/TopLevelArmResource.java","src/main/java/tsptest/armversioned/models/TopLevelArmResourceProperties.java","src/main/java/tsptest/armversioned/models/TopLevelArmResources.java","src/main/java/tsptest/armversioned/models/package-info.java","src/main/java/tsptest/armversioned/package-info.java"]} \ No newline at end of file +{"flavor":"Azure","apiVersion":"2024-12-01","crossLanguageDefinitions":{"tsptest.armversioned.fluent.ArmVersionedClient":"TspTest.ArmVersioned","tsptest.armversioned.fluent.TopLevelArmResourcesClient":"TspTest.ArmVersioned.TopLevelArmResources","tsptest.armversioned.fluent.TopLevelArmResourcesClient.action":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.actionWithResponse":"TspTest.ArmVersioned.TopLevelArmResources.action","tsptest.armversioned.fluent.TopLevelArmResourcesClient.beginCreateOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.createOrUpdate":"TspTest.ArmVersioned.TopLevelArmResources.createOrUpdate","tsptest.armversioned.fluent.TopLevelArmResourcesClient.delete":"TspTest.ArmVersioned.TopLevelArmResources.delete","tsptest.armversioned.fluent.TopLevelArmResourcesClient.deleteWithResponse":"TspTest.ArmVersioned.TopLevelArmResources.delete","tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroup":"TspTest.ArmVersioned.TopLevelArmResources.get","tsptest.armversioned.fluent.TopLevelArmResourcesClient.getByResourceGroupWithResponse":"TspTest.ArmVersioned.TopLevelArmResources.get","tsptest.armversioned.fluent.TopLevelArmResourcesClient.list":"TspTest.ArmVersioned.TopLevelArmResources.listBySubscription","tsptest.armversioned.fluent.TopLevelArmResourcesClient.listByResourceGroup":"TspTest.ArmVersioned.TopLevelArmResources.listByResourceGroup","tsptest.armversioned.fluent.models.TopLevelArmResourceInner":"TspTest.ArmVersioned.TopLevelArmResource","tsptest.armversioned.implementation.ArmVersionedClientBuilder":"TspTest.ArmVersioned","tsptest.armversioned.implementation.models.TopLevelArmResourceListResult":"Azure.ResourceManager.ResourceListResult","tsptest.armversioned.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","tsptest.armversioned.models.TopLevelArmResourceProperties":"TspTest.ArmVersioned.TopLevelArmResourceProperties"},"generatedFiles":["src/main/java/module-info.java","src/main/java/tsptest/armversioned/ArmVersionedManager.java","src/main/java/tsptest/armversioned/fluent/ArmVersionedClient.java","src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java","src/main/java/tsptest/armversioned/fluent/models/TopLevelArmResourceInner.java","src/main/java/tsptest/armversioned/fluent/models/package-info.java","src/main/java/tsptest/armversioned/fluent/package-info.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientBuilder.java","src/main/java/tsptest/armversioned/implementation/ArmVersionedClientImpl.java","src/main/java/tsptest/armversioned/implementation/ResourceManagerUtils.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java","src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java","src/main/java/tsptest/armversioned/implementation/models/TopLevelArmResourceListResult.java","src/main/java/tsptest/armversioned/implementation/package-info.java","src/main/java/tsptest/armversioned/models/ResourceProvisioningState.java","src/main/java/tsptest/armversioned/models/TopLevelArmResource.java","src/main/java/tsptest/armversioned/models/TopLevelArmResourceProperties.java","src/main/java/tsptest/armversioned/models/TopLevelArmResources.java","src/main/java/tsptest/armversioned/models/package-info.java","src/main/java/tsptest/armversioned/package-info.java"]} \ No newline at end of file From f42068643ab06d52c49b844b258500f85cfde3c6 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 17:06:05 +0800 Subject: [PATCH 38/50] update test --- .../armversioned/ArmVersionedTests.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java index 18adfae6d7c..013664f28da 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java @@ -20,6 +20,8 @@ public void testVersionedApi() { // this API exists in all versions manager.topLevelArmResources().list(); + manager.topLevelArmResources().listByResourceGroup("resourceGroup"); + manager.topLevelArmResources().action("resourceGroup", "resourceName"); manager.serviceClient() @@ -33,8 +35,16 @@ public void testVersionedApi() { resource.update().apply(); + manager.topLevelArmResources().deleteById("id"); + + resource.refresh(); + + // API in 2024-12-01 manager.topLevelArmResources().list("parameter", "newParameter", Context.NONE); + + manager.topLevelArmResources().listByResourceGroup("resourceGroup", "parameter", "newParameter", Context.NONE); + manager.topLevelArmResources() .actionWithResponse("resourceGroup", "resourceName", "parameter", "newParameter", Context.NONE); @@ -46,14 +56,20 @@ public void testVersionedApi() { .withRegion(Region.US_WEST3) .withExistingResourceGroup("resourceGroup") .withParameter("parameter") + .withNewParameter("newParameter") .create(); - resource.update().withParameter("parameter").apply(); + resource.update().withParameter("parameter").withNewParameter("newParameter").apply(); + + manager.topLevelArmResources().deleteByIdWithResponse("id", "parameter", "newParameter", Context.NONE); // API in 2023-12-01 // this op will be generated, if tspconfig has "advanced-versioning" option // REST API allow adding optional parameter to operation manager.topLevelArmResources().list("parameter", Context.NONE); + + manager.topLevelArmResources().listByResourceGroup("resourceGroup", "parameter", Context.NONE); + manager.topLevelArmResources().actionWithResponse("resourceGroup", "resourceName", "parameter", Context.NONE); manager.serviceClient() @@ -64,9 +80,10 @@ public void testVersionedApi() { .withRegion(Region.US_WEST3) .withExistingResourceGroup("resourceGroup") .withParameter("parameter") - .withNewParameter("newParameter") .create(); - resource.update().withParameter("parameter").withNewParameter("newParameter").apply(); + resource.update().withParameter("parameter").apply(); + + manager.topLevelArmResources().deleteByIdWithResponse("id", "parameter", Context.NONE); } } From 07fb92f02d0b4e2b5e5b934a12686291483a81a7 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 17:30:06 +0800 Subject: [PATCH 39/50] fix and test --- .../fluentmodel/delete/ResourceDelete.java | 32 ++++++++++++------- .../armversioned/ArmVersionedTests.java | 5 ++- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/delete/ResourceDelete.java b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/delete/ResourceDelete.java index 67c3023d279..7011c892b7c 100644 --- a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/delete/ResourceDelete.java +++ b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/delete/ResourceDelete.java @@ -4,8 +4,8 @@ package com.microsoft.typespec.http.client.generator.mgmt.model.clientmodel.fluentmodel.delete; import com.microsoft.typespec.http.client.generator.core.extension.plugin.PluginLogger; -import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClientMethodParameter; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.examplemodel.MethodParameter; +import com.microsoft.typespec.http.client.generator.core.model.javamodel.JavaVisibility; import com.microsoft.typespec.http.client.generator.core.template.prototype.MethodTemplate; import com.microsoft.typespec.http.client.generator.mgmt.FluentGen; import com.microsoft.typespec.http.client.generator.mgmt.model.arm.UrlPathSegments; @@ -15,11 +15,12 @@ import com.microsoft.typespec.http.client.generator.mgmt.model.clientmodel.fluentmodel.ResourceOperation; import com.microsoft.typespec.http.client.generator.mgmt.model.clientmodel.fluentmodel.method.CollectionMethodOperationByIdTemplate; import com.microsoft.typespec.http.client.generator.mgmt.model.clientmodel.fluentmodel.method.FluentMethod; +import com.microsoft.typespec.http.client.generator.mgmt.util.FluentUtils; import com.microsoft.typespec.http.client.generator.mgmt.util.Utils; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Optional; +import java.util.stream.Collectors; import org.slf4j.Logger; public class ResourceDelete extends ResourceOperation { @@ -45,25 +46,34 @@ public String getLocalVariablePrefix() { public List getDeleteByIdCollectionMethods() { List methods = new ArrayList<>(); - List parameters = new ArrayList<>(); - Optional methodOpt = this.findMethod(true, parameters); - if (methodOpt.isPresent()) { - FluentCollectionMethod collectionMethod = methodOpt.get(); + List collectionMethods = this.findMethodsWithContext(); + if (!collectionMethods.isEmpty()) { + FluentCollectionMethod oneCollectionMethod = collectionMethods.iterator().next(); - String name = getDeleteByIdMethodName(collectionMethod.getMethodName()); + String name = getDeleteByIdMethodName(oneCollectionMethod.getMethodName()); if (!hasConflictingMethod(name)) { List pathParameters = this.getPathParameters(); - methods.add(new CollectionMethodOperationByIdTemplate(resourceModel, name, pathParameters, - urlPathSegments, false, getResourceLocalVariables(), collectionMethod).getMethodTemplate()); + urlPathSegments, false, getResourceLocalVariables(), oneCollectionMethod).getMethodTemplate()); - methods.add(new CollectionMethodOperationByIdTemplate(resourceModel, name, pathParameters, - urlPathSegments, true, getResourceLocalVariables(), collectionMethod).getMethodTemplate()); + for (FluentCollectionMethod collectionMethod : collectionMethods) { + methods.add(new CollectionMethodOperationByIdTemplate(resourceModel, name, pathParameters, + urlPathSegments, true, getResourceLocalVariables(), collectionMethod).getMethodTemplate()); + } } } return methods; } + protected List findMethodsWithContext() { + return this.getMethodReferencesOfFullParameters() + .stream() + .filter(m -> m.getInnerClientMethod().getParameters().stream().anyMatch(FluentUtils::isContextParameter)) + // fluent method implementation calls client interface API, thus we need the method to be public + .filter(method -> JavaVisibility.Public == method.getInnerClientMethod().getMethodVisibility()) + .collect(Collectors.toList()); + } + private static String getDeleteByIdMethodName(String methodName) { String getByIdMethodName = methodName; int indexOfBy = methodName.indexOf("By"); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java index 013664f28da..14310a475cd 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java @@ -35,10 +35,10 @@ public void testVersionedApi() { resource.update().apply(); + manager.topLevelArmResources().delete("resourceGroup", "resourceName"); manager.topLevelArmResources().deleteById("id"); resource.refresh(); - // API in 2024-12-01 manager.topLevelArmResources().list("parameter", "newParameter", Context.NONE); @@ -61,6 +61,8 @@ public void testVersionedApi() { resource.update().withParameter("parameter").withNewParameter("newParameter").apply(); + manager.topLevelArmResources() + .deleteWithResponse("resourceGroup", "resourceName", "parameter", "newParameter", Context.NONE); manager.topLevelArmResources().deleteByIdWithResponse("id", "parameter", "newParameter", Context.NONE); // API in 2023-12-01 @@ -84,6 +86,7 @@ public void testVersionedApi() { resource.update().withParameter("parameter").apply(); + manager.topLevelArmResources().deleteWithResponse("resourceGroup", "resourceName", "parameter", Context.NONE); manager.topLevelArmResources().deleteByIdWithResponse("id", "parameter", Context.NONE); } } From 8e13f794807f21bfd004b69a253f20dac3d713c0 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 17:39:51 +0800 Subject: [PATCH 40/50] comment --- .../model/clientmodel/fluentmodel/delete/ResourceDelete.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/delete/ResourceDelete.java b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/delete/ResourceDelete.java index 7011c892b7c..4e1e2f59d58 100644 --- a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/delete/ResourceDelete.java +++ b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/model/clientmodel/fluentmodel/delete/ResourceDelete.java @@ -52,11 +52,14 @@ public List getDeleteByIdCollectionMethods() { String name = getDeleteByIdMethodName(oneCollectionMethod.getMethodName()); if (!hasConflictingMethod(name)) { + // deleteById without Context List pathParameters = this.getPathParameters(); methods.add(new CollectionMethodOperationByIdTemplate(resourceModel, name, pathParameters, urlPathSegments, false, getResourceLocalVariables(), oneCollectionMethod).getMethodTemplate()); for (FluentCollectionMethod collectionMethod : collectionMethods) { + // deleteByIdWithResponse with Context + // There can be multiple such methods, due to overload from versioning (optional parameter @added) methods.add(new CollectionMethodOperationByIdTemplate(resourceModel, name, pathParameters, urlPathSegments, true, getResourceLocalVariables(), collectionMethod).getMethodTemplate()); } From 3f11d0d014b36c8e9bdeeac944e3cbe01f75f149 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 17:43:36 +0800 Subject: [PATCH 41/50] regen --- .../implementation/TopLevelArmResourcesImpl.java | 15 +++++++++++++++ .../armversioned/models/TopLevelArmResources.java | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java index a5bbca9cff1..86e06d5aa5f 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -199,6 +199,21 @@ public Response deleteByIdWithResponse(String id, String parameter, String context); } + public Response deleteByIdWithResponse(String id, String parameter, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String topLevelArmResourcePropertiesName + = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourcePropertiesName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + return this.deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + private TopLevelArmResourcesClient serviceClient() { return this.innerClient; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java index 49404086ca2..2f9cd86e62f 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -262,6 +262,19 @@ Response getByIdWithResponse(String id, String parameter, S */ Response deleteByIdWithResponse(String id, String parameter, String newParameter, Context context); + /** + * Delete a TopLevelArmResource. + * + * @param id the resource ID. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByIdWithResponse(String id, String parameter, Context context); + /** * Begins definition for a new TopLevelArmResource resource. * From 6a8d20453f374166cb2f8d76bf6c9c0c795a16cb Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 17:52:56 +0800 Subject: [PATCH 42/50] demonstrate for case without advanced-versioning --- .../http-client-generator-test/Generate.ps1 | 3 - .../fluent/TopLevelArmResourcesClient.java | 112 ---------- .../TopLevelArmResourceImpl.java | 5 - .../TopLevelArmResourcesClientImpl.java | 211 ------------------ .../TopLevelArmResourcesImpl.java | 51 ----- .../models/TopLevelArmResource.java | 12 - .../models/TopLevelArmResources.java | 83 ------- 7 files changed, 477 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 index 2ca6a7e0283..d344a462f98 100644 --- a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 +++ b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 @@ -107,9 +107,6 @@ $generateScript = { $tspOptions += " --option ""@typespec/http-client-java.generate-tests=false""" # add customization code $tspOptions += " --option ""@typespec/http-client-java.customization-class=../../customization/src/main/java/KeyVaultCustomization.java""" - } elseif ($tspFile -match "tsp[\\/]arm-versioned.tsp") { - # enable advanced versioning for resiliency test - $tspOptions += " --option ""@typespec/http-client-java.advanced-versioning=true""" } elseif ($tspFile -match "tsp[\\/]subclient.tsp") { $tspOptions += " --option ""@typespec/http-client-java.enable-subclient=true""" # test for include-api-view-properties diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java index edc8c00e645..00cdfe3d1b4 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -17,25 +17,6 @@ * An instance of this class provides access to all the operations defined in TopLevelArmResourcesClient. */ public interface TopLevelArmResourcesClient { - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this - * type using a specific property type. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( - String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, - String parameter, Context context); - /** * Create a TopLevelArmResource. * @@ -72,23 +53,6 @@ SyncPoller, TopLevelArmResourceInner> begin String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return concrete tracked resource types can be created by aliasing this type using a specific property type. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource, String parameter, Context context); - /** * Create a TopLevelArmResource. * @@ -122,19 +86,6 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); - /** - * List TopLevelArmResource resources by subscription ID. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - PagedIterable list(String parameter, Context context); - /** * List TopLevelArmResource resources by subscription ID. * @@ -159,21 +110,6 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve @ServiceMethod(returns = ReturnType.COLLECTION) PagedIterable list(String parameter, String newParameter, Context context); - /** - * List TopLevelArmResource resources by resource group. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - PagedIterable listByResourceGroup(String resourceGroupName, String parameter, - Context context); - /** * List TopLevelArmResource resources by resource group. * @@ -202,22 +138,6 @@ PagedIterable listByResourceGroup(String resourceGroup PagedIterable listByResourceGroup(String resourceGroupName, String parameter, String newParameter, Context context); - /** - * Get a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a TopLevelArmResource along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, Context context); - /** * Get a TopLevelArmResource. * @@ -248,22 +168,6 @@ Response getByResourceGroupWithResponse(String resourc @ServiceMethod(returns = ReturnType.SINGLE) TopLevelArmResourceInner getByResourceGroup(String resourceGroupName, String topLevelArmResourcePropertiesName); - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); - /** * Delete a TopLevelArmResource. * @@ -293,22 +197,6 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe @ServiceMethod(returns = ReturnType.SINGLE) void delete(String resourceGroupName, String topLevelArmResourcePropertiesName); - /** - * A synchronous resource action. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); - /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java index 6d9d1e0eba8..d45c262fae9 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -167,11 +167,6 @@ public TopLevelArmResource refresh(Context context) { return this; } - public Response actionWithResponse(String parameter, Context context) { - return serviceManager.topLevelArmResources() - .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); - } - public Response actionWithResponse(String parameter, String newParameter, Context context) { return serviceManager.topLevelArmResources() .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java index 491beba030b..cca552aa9b3 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -281,32 +281,6 @@ private Response createOrUpdateWithResponse(String resourceGroupName newParameter, contentType, accept, resource, Context.NONE); } - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return concrete tracked resource types can be created by aliasing this type using a specific property type along - * with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private Response createOrUpdateWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, - Context context) { - final String newParameter = null; - final String contentType = "application/json"; - final String accept = "application/json"; - return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, contentType, accept, resource, context); - } - /** * Create a TopLevelArmResource. * @@ -406,30 +380,6 @@ public SyncPoller, TopLevelArmResourceInner TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, Context.NONE); } - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this - * type using a specific property type. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( - String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, - String parameter, Context context) { - Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, - resource, parameter, context); - return this.client.getLroResult(response, - TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); - } - /** * Create a TopLevelArmResource. * @@ -521,26 +471,6 @@ private Mono createOrUpdateAsync(String resourceGroupN newParameter).last().flatMap(this.client::getLroFinalResultOrError); } - /** - * Create a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return concrete tracked resource types can be created by aliasing this type using a specific property type. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource, String parameter, Context context) { - return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, context) - .getFinalResult(); - } - /** * Create a TopLevelArmResource. * @@ -655,26 +585,6 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } - /** - * List TopLevelArmResource resources by subscription ID. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listSinglePage(String parameter, Context context) { - final String newParameter = null; - final String accept = "application/json"; - Response res = service.listSync(this.client.getEndpoint(), - this.client.getApiVersion(), this.client.getSubscriptionId(), parameter, newParameter, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), - res.getValue().nextLink(), null); - } - /** * List TopLevelArmResource resources by subscription ID. * @@ -696,22 +606,6 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } - /** - * List TopLevelArmResource resources by subscription ID. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable list(String parameter, Context context) { - return new PagedIterable<>(() -> listSinglePage(parameter, context), - nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); - } - /** * List TopLevelArmResource resources by subscription ID. * @@ -825,29 +719,6 @@ private PagedResponse listByResourceGroupSinglePage(St res.getValue().nextLink(), null); } - /** - * List TopLevelArmResource resources by resource group. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listByResourceGroupSinglePage(String resourceGroupName, - String parameter, Context context) { - final String newParameter = null; - final String accept = "application/json"; - Response res - = service.listByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, parameter, newParameter, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), - res.getValue().nextLink(), null); - } - /** * List TopLevelArmResource resources by resource group. * @@ -871,24 +742,6 @@ private PagedResponse listByResourceGroupSinglePage(St res.getValue().nextLink(), null); } - /** - * List TopLevelArmResource resources by resource group. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, - Context context) { - return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName, parameter, context), - nextLink -> listByResourceGroupNextSinglePage(nextLink, context)); - } - /** * List TopLevelArmResource resources by resource group. * @@ -968,28 +821,6 @@ private Mono getByResourceGroupAsync(String resourceGr newParameter).flatMap(res -> Mono.justOrEmpty(res.getValue())); } - /** - * Get a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a TopLevelArmResource along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, Context context) { - final String newParameter = null; - final String accept = "application/json"; - return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, accept, context); - } - /** * Get a TopLevelArmResource. * @@ -1071,27 +902,6 @@ private Mono deleteAsync(String resourceGroupName, String topLevelArmResou .flatMap(ignored -> Mono.empty()); } - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { - final String newParameter = null; - return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, context); - } - /** * Delete a TopLevelArmResource. * @@ -1169,27 +979,6 @@ private Mono actionAsync(String resourceGroupName, String topLevelArmResou .flatMap(ignored -> Mono.empty()); } - /** - * A synchronous resource action. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { - final String newParameter = null; - return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, context); - } - /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java index 86e06d5aa5f..68fbb10229a 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -27,11 +27,6 @@ public TopLevelArmResourcesImpl(TopLevelArmResourcesClient innerClient, this.serviceManager = serviceManager; } - public PagedIterable list(String parameter, Context context) { - PagedIterable inner = this.serviceClient().list(parameter, context); - return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); - } - public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); @@ -42,13 +37,6 @@ public PagedIterable list(String parameter, String newParam return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } - public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, - Context context) { - PagedIterable inner - = this.serviceClient().listByResourceGroup(resourceGroupName, parameter, context); - return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); - } - public PagedIterable listByResourceGroup(String resourceGroupName) { PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); @@ -61,18 +49,6 @@ public PagedIterable listByResourceGroup(String resourceGro return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } - public Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, Context context) { - Response inner = this.serviceClient() - .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); - if (inner != null) { - return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), - new TopLevelArmResourceImpl(inner.getValue(), this.manager())); - } else { - return null; - } - } - public Response getByResourceGroupWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { Response inner = this.serviceClient() @@ -96,12 +72,6 @@ public TopLevelArmResource getByResourceGroup(String resourceGroupName, String t } } - public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { - return this.serviceClient() - .deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); - } - public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { return this.serviceClient() @@ -112,12 +82,6 @@ public void delete(String resourceGroupName, String topLevelArmResourcePropertie this.serviceClient().delete(resourceGroupName, topLevelArmResourcePropertiesName); } - public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { - return this.serviceClient() - .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); - } - public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { return this.serviceClient() @@ -199,21 +163,6 @@ public Response deleteByIdWithResponse(String id, String parameter, String context); } - public Response deleteByIdWithResponse(String id, String parameter, Context context) { - String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); - if (resourceGroupName == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); - } - String topLevelArmResourcePropertiesName - = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); - if (topLevelArmResourcePropertiesName == null) { - throw LOGGER.logExceptionAsError(new IllegalArgumentException( - String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); - } - return this.deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); - } - private TopLevelArmResourcesClient serviceClient() { return this.innerClient; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java index 0305ff904a4..af77b173ca3 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -318,18 +318,6 @@ interface WithNewParameter { */ TopLevelArmResource refresh(Context context); - /** - * A synchronous resource action. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - Response actionWithResponse(String parameter, Context context); - /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java index 2f9cd86e62f..2f85588f42d 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -12,18 +12,6 @@ * Resource collection API of TopLevelArmResources. */ public interface TopLevelArmResources { - /** - * List TopLevelArmResource resources by subscription ID. - * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. - */ - PagedIterable list(String parameter, Context context); - /** * List TopLevelArmResource resources by subscription ID. * @@ -46,19 +34,6 @@ public interface TopLevelArmResources { */ PagedIterable list(String parameter, String newParameter, Context context); - /** - * List TopLevelArmResource resources by resource group. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. - */ - PagedIterable listByResourceGroup(String resourceGroupName, String parameter, Context context); - /** * List TopLevelArmResource resources by resource group. * @@ -85,21 +60,6 @@ public interface TopLevelArmResources { PagedIterable listByResourceGroup(String resourceGroupName, String parameter, String newParameter, Context context); - /** - * Get a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a TopLevelArmResource along with {@link Response}. - */ - Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, Context context); - /** * Get a TopLevelArmResource. * @@ -128,21 +88,6 @@ Response getByResourceGroupWithResponse(String resourceGrou */ TopLevelArmResource getByResourceGroup(String resourceGroupName, String topLevelArmResourcePropertiesName); - /** - * Delete a TopLevelArmResource. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); - /** * Delete a TopLevelArmResource. * @@ -170,21 +115,6 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe */ void delete(String resourceGroupName, String topLevelArmResourcePropertiesName); - /** - * A synchronous resource action. - * - * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); - /** * A synchronous resource action. * @@ -262,19 +192,6 @@ Response getByIdWithResponse(String id, String parameter, S */ Response deleteByIdWithResponse(String id, String parameter, String newParameter, Context context); - /** - * Delete a TopLevelArmResource. - * - * @param id the resource ID. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - Response deleteByIdWithResponse(String id, String parameter, Context context); - /** * Begins definition for a new TopLevelArmResource resource. * From 2fba784ce3eeb5c6a838567a25a715daec3969f7 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 26 Nov 2025 17:53:04 +0800 Subject: [PATCH 43/50] Revert "demonstrate for case without advanced-versioning" This reverts commit 6a8d20453f374166cb2f8d76bf6c9c0c795a16cb. --- .../http-client-generator-test/Generate.ps1 | 3 + .../fluent/TopLevelArmResourcesClient.java | 112 ++++++++++ .../TopLevelArmResourceImpl.java | 5 + .../TopLevelArmResourcesClientImpl.java | 211 ++++++++++++++++++ .../TopLevelArmResourcesImpl.java | 51 +++++ .../models/TopLevelArmResource.java | 12 + .../models/TopLevelArmResources.java | 83 +++++++ 7 files changed, 477 insertions(+) diff --git a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 index d344a462f98..2ca6a7e0283 100644 --- a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 +++ b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 @@ -107,6 +107,9 @@ $generateScript = { $tspOptions += " --option ""@typespec/http-client-java.generate-tests=false""" # add customization code $tspOptions += " --option ""@typespec/http-client-java.customization-class=../../customization/src/main/java/KeyVaultCustomization.java""" + } elseif ($tspFile -match "tsp[\\/]arm-versioned.tsp") { + # enable advanced versioning for resiliency test + $tspOptions += " --option ""@typespec/http-client-java.advanced-versioning=true""" } elseif ($tspFile -match "tsp[\\/]subclient.tsp") { $tspOptions += " --option ""@typespec/http-client-java.enable-subclient=true""" # test for include-api-view-properties diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java index 00cdfe3d1b4..edc8c00e645 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -17,6 +17,25 @@ * An instance of this class provides access to all the operations defined in TopLevelArmResourcesClient. */ public interface TopLevelArmResourcesClient { + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, Context context); + /** * Create a TopLevelArmResource. * @@ -53,6 +72,23 @@ SyncPoller, TopLevelArmResourceInner> begin String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource, String parameter, Context context); + /** * Create a TopLevelArmResource. * @@ -86,6 +122,19 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(String parameter, Context context); + /** * List TopLevelArmResource resources by subscription ID. * @@ -110,6 +159,21 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve @ServiceMethod(returns = ReturnType.COLLECTION) PagedIterable list(String parameter, String newParameter, Context context); + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + Context context); + /** * List TopLevelArmResource resources by resource group. * @@ -138,6 +202,22 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve PagedIterable listByResourceGroup(String resourceGroupName, String parameter, String newParameter, Context context); + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, Context context); + /** * Get a TopLevelArmResource. * @@ -168,6 +248,22 @@ Response getByResourceGroupWithResponse(String resourc @ServiceMethod(returns = ReturnType.SINGLE) TopLevelArmResourceInner getByResourceGroup(String resourceGroupName, String topLevelArmResourcePropertiesName); + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); + /** * Delete a TopLevelArmResource. * @@ -197,6 +293,22 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe @ServiceMethod(returns = ReturnType.SINGLE) void delete(String resourceGroupName, String topLevelArmResourcePropertiesName); + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java index d45c262fae9..6d9d1e0eba8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -167,6 +167,11 @@ public TopLevelArmResource refresh(Context context) { return this; } + public Response actionWithResponse(String parameter, Context context) { + return serviceManager.topLevelArmResources() + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + public Response actionWithResponse(String parameter, String newParameter, Context context) { return serviceManager.topLevelArmResources() .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java index cca552aa9b3..491beba030b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -281,6 +281,32 @@ private Response createOrUpdateWithResponse(String resourceGroupName newParameter, contentType, accept, resource, Context.NONE); } + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, + Context context) { + final String newParameter = null; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, contentType, accept, resource, context); + } + /** * Create a TopLevelArmResource. * @@ -380,6 +406,30 @@ public SyncPoller, TopLevelArmResourceInner TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, Context.NONE); } + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of concrete tracked resource types can be created by aliasing this + * type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, Context context) { + Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, + resource, parameter, context); + return this.client.getLroResult(response, + TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); + } + /** * Create a TopLevelArmResource. * @@ -471,6 +521,26 @@ private Mono createOrUpdateAsync(String resourceGroupN newParameter).last().flatMap(this.client::getLroFinalResultOrError); } + /** + * Create a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete tracked resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, + TopLevelArmResourceInner resource, String parameter, Context context) { + return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, context) + .getFinalResult(); + } + /** * Create a TopLevelArmResource. * @@ -585,6 +655,26 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(String parameter, Context context) { + final String newParameter = null; + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), parameter, newParameter, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + /** * List TopLevelArmResource resources by subscription ID. * @@ -606,6 +696,22 @@ private PagedResponse listSinglePage(String parameter, res.getValue().nextLink(), null); } + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(String parameter, Context context) { + return new PagedIterable<>(() -> listSinglePage(parameter, context), + nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); + } + /** * List TopLevelArmResource resources by subscription ID. * @@ -719,6 +825,29 @@ private PagedResponse listByResourceGroupSinglePage(St res.getValue().nextLink(), null); } + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByResourceGroupSinglePage(String resourceGroupName, + String parameter, Context context) { + final String newParameter = null; + final String accept = "application/json"; + Response res + = service.listByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, parameter, newParameter, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + /** * List TopLevelArmResource resources by resource group. * @@ -742,6 +871,24 @@ private PagedResponse listByResourceGroupSinglePage(St res.getValue().nextLink(), null); } + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + Context context) { + return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName, parameter, context), + nextLink -> listByResourceGroupNextSinglePage(nextLink, context)); + } + /** * List TopLevelArmResource resources by resource group. * @@ -821,6 +968,28 @@ private Mono getByResourceGroupAsync(String resourceGr newParameter).flatMap(res -> Mono.justOrEmpty(res.getValue())); } + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, Context context) { + final String newParameter = null; + final String accept = "application/json"; + return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, accept, context); + } + /** * Get a TopLevelArmResource. * @@ -902,6 +1071,27 @@ private Mono deleteAsync(String resourceGroupName, String topLevelArmResou .flatMap(ignored -> Mono.empty()); } + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + final String newParameter = null; + return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + /** * Delete a TopLevelArmResource. * @@ -979,6 +1169,27 @@ private Mono actionAsync(String resourceGroupName, String topLevelArmResou .flatMap(ignored -> Mono.empty()); } + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + final String newParameter = null; + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); + } + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java index 68fbb10229a..86e06d5aa5f 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -27,6 +27,11 @@ public TopLevelArmResourcesImpl(TopLevelArmResourcesClient innerClient, this.serviceManager = serviceManager; } + public PagedIterable list(String parameter, Context context) { + PagedIterable inner = this.serviceClient().list(parameter, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); @@ -37,6 +42,13 @@ public PagedIterable list(String parameter, String newParam return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } + public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + Context context) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName, parameter, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + public PagedIterable listByResourceGroup(String resourceGroupName) { PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); @@ -49,6 +61,18 @@ public PagedIterable listByResourceGroup(String resourceGro return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } + public Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, Context context) { + Response inner = this.serviceClient() + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new TopLevelArmResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + public Response getByResourceGroupWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { Response inner = this.serviceClient() @@ -72,6 +96,12 @@ public TopLevelArmResource getByResourceGroup(String resourceGroupName, String t } } + public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + return this.serviceClient() + .deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { return this.serviceClient() @@ -82,6 +112,12 @@ public void delete(String resourceGroupName, String topLevelArmResourcePropertie this.serviceClient().delete(resourceGroupName, topLevelArmResourcePropertiesName); } + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context) { + return this.serviceClient() + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { return this.serviceClient() @@ -163,6 +199,21 @@ public Response deleteByIdWithResponse(String id, String parameter, String context); } + public Response deleteByIdWithResponse(String id, String parameter, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String topLevelArmResourcePropertiesName + = ResourceManagerUtils.getValueFromIdByName(id, "topLevelArmResources"); + if (topLevelArmResourcePropertiesName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'topLevelArmResources'.", id))); + } + return this.deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + } + private TopLevelArmResourcesClient serviceClient() { return this.innerClient; } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java index af77b173ca3..0305ff904a4 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -318,6 +318,18 @@ interface WithNewParameter { */ TopLevelArmResource refresh(Context context); + /** + * A synchronous resource action. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response actionWithResponse(String parameter, Context context); + /** * A synchronous resource action. * diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java index 2f85588f42d..2f9cd86e62f 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -12,6 +12,18 @@ * Resource collection API of TopLevelArmResources. */ public interface TopLevelArmResources { + /** + * List TopLevelArmResource resources by subscription ID. + * + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(String parameter, Context context); + /** * List TopLevelArmResource resources by subscription ID. * @@ -34,6 +46,19 @@ public interface TopLevelArmResources { */ PagedIterable list(String parameter, String newParameter, Context context); + /** + * List TopLevelArmResource resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, String parameter, Context context); + /** * List TopLevelArmResource resources by resource group. * @@ -60,6 +85,21 @@ public interface TopLevelArmResources { PagedIterable listByResourceGroup(String resourceGroupName, String parameter, String newParameter, Context context); + /** + * Get a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a TopLevelArmResource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, + String topLevelArmResourcePropertiesName, String parameter, Context context); + /** * Get a TopLevelArmResource. * @@ -88,6 +128,21 @@ Response getByResourceGroupWithResponse(String resourceGrou */ TopLevelArmResource getByResourceGroup(String resourceGroupName, String topLevelArmResourcePropertiesName); + /** + * Delete a TopLevelArmResource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); + /** * Delete a TopLevelArmResource. * @@ -115,6 +170,21 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe */ void delete(String resourceGroupName, String topLevelArmResourcePropertiesName); + /** + * A synchronous resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, + String parameter, Context context); + /** * A synchronous resource action. * @@ -192,6 +262,19 @@ Response getByIdWithResponse(String id, String parameter, S */ Response deleteByIdWithResponse(String id, String parameter, String newParameter, Context context); + /** + * Delete a TopLevelArmResource. + * + * @param id the resource ID. + * @param parameter The parameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByIdWithResponse(String id, String parameter, Context context); + /** * Begins definition for a new TopLevelArmResource resource. * From 90c11197f49e13195a42c714946b3cb4944517f8 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Thu, 27 Nov 2025 15:15:36 +0800 Subject: [PATCH 44/50] rename to make the var easier to understand --- .../generator/core/template/ClientMethodTemplate.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index 2da67af3e72..46b6ae16cc2 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -166,18 +166,19 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client // If the parameter isn't required and the client method only uses required parameters, optional // parameters are omitted and will need to instantiated in the method. - boolean optionalOmitted = !parameter.isRequired() && parameter.getClientType() != ClassType.CONTEXT; - if (optionalOmitted) { + boolean optionalParameterToInitialize + = !parameter.isRequired() && parameter.getClientType() != ClassType.CONTEXT; + if (optionalParameterToInitialize) { boolean parameterInClientMethodSignature = methodParameters.stream().anyMatch(p -> p.getProxyMethodParameter() == parameter); // if the parameter is defined in client method signature, // it does not need to be instantiated in local variable. - optionalOmitted = !parameterInClientMethodSignature; + optionalParameterToInitialize = !parameterInClientMethodSignature; } // Optional variables and constants are always null if their wire type and client type differ and applying // conversions between the types is ignored. - boolean alwaysNull = parameterWireType != parameterClientType && optionalOmitted; + boolean alwaysNull = parameterWireType != parameterClientType && optionalParameterToInitialize; // Constants should be included if the parameter is a constant, and it's either required or optional // constants aren't generated as enums. @@ -187,7 +188,7 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client // Client methods only add local variable instantiations when the parameter isn't passed by the caller, // isn't always null, is an optional parameter that was omitted or is a constant that is either required // or AutoRest isn't generating with optional constant as enums. - if (!alwaysNull && (optionalOmitted || includeConstant)) { + if (!alwaysNull && (optionalParameterToInitialize || includeConstant)) { final String defaultValue = parameterDefaultValueExpression(parameter); function.line("final %s %s = %s;", parameterClientType, parameter.getParameterReference(), defaultValue == null ? "null" : defaultValue); From ef26163686a8ddb5e1292807d7989187c0f0ab61 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Thu, 27 Nov 2025 15:42:08 +0800 Subject: [PATCH 45/50] add overloadedClientMethod var to ClientMethod --- .../core/mapper/ClientMethodMapper.java | 92 +++++++++++-------- .../core/model/clientmodel/ClientMethod.java | 23 ++++- 2 files changed, 75 insertions(+), 40 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index dde32c6f53d..bd8f8dfc932 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -356,9 +356,8 @@ private static JavaVisibility methodVisibilityInWrapperClient(Operation operatio } protected void createOverloadForVersioning(List methods, ClientMethod baseMethod, - JavaVisibility methodWithContextVisibility, MethodPageDetails methodPageDetailsWithContext, - boolean isProtocolMethod) { - final ClientMethodType clientMethodType = baseMethod.getType(); + ClientMethod overloadedMethod, JavaVisibility methodWithContextVisibility, + MethodPageDetails methodPageDetailsWithContext, boolean isProtocolMethod) { final List parameters = baseMethod.getParameters(); if (!isProtocolMethod) { if (parameters.stream().anyMatch(p -> p.getVersioning() != null && p.getVersioning().getAdded() != null)) { @@ -367,19 +366,22 @@ protected void createOverloadForVersioning(List methods, ClientMet for (List overloadedParameters : signatures) { if (JavaSettings.getInstance().isDataPlaneClient()) { // DPG - final ClientMethod overloadedMethod - = baseMethod.newBuilder().parameters(overloadedParameters).build(); - methods.add(overloadedMethod); + final ClientMethod overloadMethod = baseMethod.newBuilder() + .overloadedClientMethod(overloadedMethod) + .parameters(overloadedParameters) + .build(); + methods.add(overloadMethod); } else { // non-DPG - ClientMethod.Builder overloadedMethodBuilder - = baseMethod.newBuilder().parameters(overloadedParameters); + ClientMethod.Builder overloadedMethodBuilder = baseMethod.newBuilder() + .overloadedClientMethod(overloadedMethod) + .parameters(overloadedParameters); if (methodPageDetailsWithContext != null) { overloadedMethodBuilder = overloadedMethodBuilder.methodPageDetails(methodPageDetailsWithContext); } - final ClientMethod overloadedMethod = overloadedMethodBuilder.build(); - addClientMethodWithContext(methods, overloadedMethod, methodWithContextVisibility, + final ClientMethod overloadMethod = overloadedMethodBuilder.build(); + addClientMethodWithContext(methods, overloadMethod, methodWithContextVisibility, isProtocolMethod); } } @@ -473,11 +475,13 @@ private void createSinglePageClientMethods(boolean isSync, ClientMethod baseMeth methods.add(singlePageMethod); } - // Pageable op '[Operation]SinglePage' overloads for versioning - createOverloadForVersioning(methods, singlePageMethod, methodWithContextVisibility, null, isProtocolMethod); - // Generate '[Operation]SinglePage' overload with all parameters and Context. - addClientMethodWithContext(methods, singlePageMethod, methodWithContextVisibility, isProtocolMethod); + ClientMethod clientMethodWithContext + = addClientMethodWithContext(methods, singlePageMethod, methodWithContextVisibility, isProtocolMethod); + + // Pageable op '[Operation]SinglePage' overloads for versioning + createOverloadForVersioning(methods, singlePageMethod, clientMethodWithContext, methodWithContextVisibility, + null, isProtocolMethod); } private void createPageStreamingClientMethods(boolean isSync, ClientMethod baseMethod, @@ -528,9 +532,6 @@ private void createPageStreamingClientMethods(boolean isSync, ClientMethod baseM if (settings.getSyncMethods() != SyncMethodsGeneration.NONE) { // generate the overload, if "sync-methods != NONE" methods.add(pagingMethod); - // Pageable op '[Operation]' overloads for versioning - createOverloadForVersioning(methods, pagingMethod, methodWithContextVisibility, - methodPageDetailsWithContext, isProtocolMethod); } if (generateRequiredOnlyParametersOverload) { @@ -547,7 +548,12 @@ private void createPageStreamingClientMethods(boolean isSync, ClientMethod baseM } else { pagingMethodWithContext = pagingMethod; } - addClientMethodWithContext(methods, pagingMethodWithContext, methodWithContextVisibility, isProtocolMethod); + ClientMethod clientMethodWithContext = addClientMethodWithContext(methods, pagingMethodWithContext, + methodWithContextVisibility, isProtocolMethod); + + // Pageable op '[Operation]' overloads for versioning + createOverloadForVersioning(methods, pagingMethod, clientMethodWithContext, methodWithContextVisibility, + methodPageDetailsWithContext, isProtocolMethod); } private void createLroWithResponseClientMethods(boolean isSync, ClientMethod baseMethod, List methods, @@ -597,10 +603,12 @@ private void createLroWithResponseClientMethods(boolean isSync, ClientMethod bas .build(); methods.add(withResponseMethod); - // LRO '[Operation]WithResponse' overloads for versioning - createOverloadForVersioning(methods, withResponseMethod, methodWithContextVisibility, null, isProtocolMethod); + ClientMethod clientMethodWithContext + = addClientMethodWithContext(methods, withResponseMethod, methodWithContextVisibility, isProtocolMethod); - addClientMethodWithContext(methods, withResponseMethod, methodWithContextVisibility, isProtocolMethod); + // LRO '[Operation]WithResponse' overloads for versioning + createOverloadForVersioning(methods, withResponseMethod, clientMethodWithContext, methodWithContextVisibility, + null, isProtocolMethod); } private void createFluentLroWithResponseSyncClientMethods(Operation operation, ClientMethod baseMethod, @@ -640,10 +648,12 @@ private void createFluentLroWithResponseSyncClientMethods(Operation operation, C .build(); methods.add(withResponseSyncMethod); - // LRO '[Operation]' overloads for versioning - createOverloadForVersioning(methods, withResponseSyncMethod, NOT_VISIBLE, null, isProtocolMethod); + ClientMethod clientMethodWithContext + = addClientMethodWithContext(methods, withResponseSyncMethod, NOT_VISIBLE, isProtocolMethod); - addClientMethodWithContext(methods, withResponseSyncMethod, NOT_VISIBLE, isProtocolMethod); + // LRO '[Operation]' overloads for versioning + createOverloadForVersioning(methods, withResponseSyncMethod, clientMethodWithContext, NOT_VISIBLE, null, + isProtocolMethod); } private void createProtocolLroBeginClientMethods(ClientMethod baseMethod, PollingMetadata pollingMetadata, @@ -733,9 +743,6 @@ private void createLroBeginClientMethods(boolean isSync, ClientMethod lroBaseMet .build(); methods.add(beginLroMethod); - // LRO 'begin[Operation]' sync or async method overloads with versioning. - createOverloadForVersioning(methods, beginLroMethod, methodWithContextVisibility, null, isProtocolMethod); - if (generateRequiredOnlyParametersOverload) { // LRO 'begin[Operation]' sync or async method overload with only required parameters. final ClientMethod beginLroMethodWithRequiredParameters = beginLroMethod.newBuilder() @@ -746,7 +753,12 @@ private void createLroBeginClientMethods(boolean isSync, ClientMethod lroBaseMet } // LRO 'begin[Operation]' sync or async method overload with only required with context parameters. - addClientMethodWithContext(methods, beginLroMethod, methodWithContextVisibility, isProtocolMethod); + ClientMethod clientMethodWithContext + = addClientMethodWithContext(methods, beginLroMethod, methodWithContextVisibility, isProtocolMethod); + + // LRO 'begin[Operation]' sync or async method overloads with versioning. + createOverloadForVersioning(methods, beginLroMethod, clientMethodWithContext, methodWithContextVisibility, null, + isProtocolMethod); } private void createSimpleClientMethods(boolean isSync, ClientMethod baseMethod, List methods, @@ -794,13 +806,15 @@ private void createSimpleWithResponseClientMethods(boolean isSync, ClientMethod .methodVisibility(methodVisibility) .build(); - // Simple op '[Operation]WithResponse' overloads for versioning - createOverloadForVersioning(methods, withResponseMethod, methodWithContextVisibility, null, isProtocolMethod); - // Always generate an overload of WithResponse with non-required parameters without Context. It is only for sync // proxy method, and is usually filtered out in methodVisibility function. methods.add(withResponseMethod); - addClientMethodWithContext(methods, withResponseMethod, methodWithContextVisibility, isProtocolMethod); + ClientMethod clientMethodWithContext + = addClientMethodWithContext(methods, withResponseMethod, methodWithContextVisibility, isProtocolMethod); + + // Simple op '[Operation]WithResponse' overloads for versioning + createOverloadForVersioning(methods, withResponseMethod, clientMethodWithContext, methodWithContextVisibility, + null, isProtocolMethod); } private void createSimpleValueClientMethods(boolean isSync, ClientMethod baseMethod, List methods, @@ -840,9 +854,6 @@ private void createSimpleValueClientMethods(boolean isSync, ClientMethod baseMet .build(); methods.add(simpleMethod); - // Simple op '[Operation]' overloads for versioning - createOverloadForVersioning(methods, simpleMethod, methodWithContextVisibility, null, isProtocolMethod); - if (generateRequiredOnlyParametersOverload) { final ClientMethod simpleMethodWithRequiredParameters = simpleMethod.newBuilder() .methodVisibility(methodWithRequiredParametersVisibility) @@ -850,7 +861,12 @@ private void createSimpleValueClientMethods(boolean isSync, ClientMethod baseMet .build(); methods.add(simpleMethodWithRequiredParameters); } - addClientMethodWithContext(methods, simpleMethod, methodWithContextVisibility, isProtocolMethod); + ClientMethod clientMethodWithContext + = addClientMethodWithContext(methods, simpleMethod, methodWithContextVisibility, isProtocolMethod); + + // Simple op '[Operation]' overloads for versioning + createOverloadForVersioning(methods, simpleMethod, clientMethodWithContext, methodWithContextVisibility, null, + isProtocolMethod); } /** @@ -970,8 +986,9 @@ protected ClientMethodParameter getContextParameter(boolean isProtocolMethod) { * @param baseMethod The method to use to obtain the builder for context enabled {@link ClientMethod}. * @param visibility The visibility for the context enabled client method. * @param isProtocolMethod Is protocol method. + * @return the client method with Context parameter. */ - protected void addClientMethodWithContext(List methods, ClientMethod baseMethod, + protected ClientMethod addClientMethodWithContext(List methods, ClientMethod baseMethod, JavaVisibility visibility, boolean isProtocolMethod) { final ClientMethodParameter contextParameter = getContextParameter(isProtocolMethod); final List parameters = new ArrayList<>(baseMethod.getParameters()); @@ -987,6 +1004,7 @@ protected void addClientMethodWithContext(List methods, ClientMeth .hasWithContextOverload(false) // WithContext overload doesn't have a withContext overload .build(); methods.add(withContextMethod); + return withContextMethod; } private static MethodNamer resolveMethodNamer(ProxyMethod proxyMethod, ConvenienceApi convenienceApi, diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethod.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethod.java index 64c21351671..1b28b451e4d 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethod.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethod.java @@ -115,6 +115,8 @@ public class ClientMethod { private final String argumentList; private final OperationInstrumentationInfo instrumentationInfo; + private final ClientMethod overloadedClientMethod; + public ClientMethod.Builder newBuilder() { return new ClientMethod.Builder().description(description) .returnValue(returnValue) @@ -137,7 +139,8 @@ public ClientMethod.Builder newBuilder() { .methodDocumentation(externalDocumentation) .operationInstrumentationInfo(instrumentationInfo) .setCrossLanguageDefinitionId(crossLanguageDefinitionId) - .hasWithContextOverload(hasWithContextOverload); + .hasWithContextOverload(hasWithContextOverload) + .overloadedClientMethod(overloadedClientMethod); } /** @@ -171,7 +174,7 @@ protected ClientMethod(String description, ReturnValue returnValue, String name, JavaVisibility methodVisibilityInWrapperClient, ImplementationDetails implementationDetails, MethodPollingDetails methodPollingDetails, ExternalDocumentation externalDocumentation, String crossLanguageDefinitionId, boolean hasWithContextOverload, - OperationInstrumentationInfo instrumentationInfo) { + OperationInstrumentationInfo instrumentationInfo, ClientMethod overloadedClientMethod) { this.description = description; this.returnValue = returnValue; this.name = name; @@ -216,6 +219,7 @@ protected ClientMethod(String description, ReturnValue returnValue, String name, this.argumentList = getMethodParameters().stream().map(ClientMethodParameter::getName).collect(Collectors.joining(", ")); this.instrumentationInfo = instrumentationInfo; + this.overloadedClientMethod = overloadedClientMethod; } @Override @@ -633,6 +637,7 @@ public static class Builder { protected boolean hasWithContextOverload; protected boolean hidePageableParams; protected OperationInstrumentationInfo instrumentationInfo; + protected ClientMethod overloadedClientMethod; public Builder setCrossLanguageDefinitionId(String crossLanguageDefinitionId) { this.crossLanguageDefinitionId = crossLanguageDefinitionId; @@ -882,6 +887,17 @@ public Builder operationInstrumentationInfo(OperationInstrumentationInfo instrum return this; } + /** + * Sets the overloaded client method associated with this ClientMethod. + * + * @param overloadedClientMethod the overloaded client method + * @return the Builder itself + */ + public Builder overloadedClientMethod(ClientMethod overloadedClientMethod) { + this.overloadedClientMethod = overloadedClientMethod; + return this; + } + /** * @return an immutable ClientMethod instance with the configurations on this builder. */ @@ -891,7 +907,8 @@ public ClientMethod build() { clientReference, CollectionUtil.toImmutableList(requiredNullableParameterExpressions), isGroupedParameterRequired, groupedParameterTypeName, methodPageDetails, parameterTransformations, methodVisibility, methodVisibilityInWrapperClient, implementationDetails, methodPollingDetails, - externalDocumentation, crossLanguageDefinitionId, hasWithContextOverload, instrumentationInfo); + externalDocumentation, crossLanguageDefinitionId, hasWithContextOverload, instrumentationInfo, + overloadedClientMethod); } } } From a041c47e6ace3a258282f9b0fddc5f6a48bcb554 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Thu, 27 Nov 2025 15:51:34 +0800 Subject: [PATCH 46/50] refine the logic --- .../core/model/clientmodel/ClientMethod.java | 9 ++++++++ .../core/template/ClientMethodTemplate.java | 21 +++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethod.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethod.java index 1b28b451e4d..292a655b7c7 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethod.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethod.java @@ -447,6 +447,15 @@ public OperationInstrumentationInfo getOperationInstrumentationInfo() { return instrumentationInfo; } + /** + * Get the overloaded client method associated with this ClientMethod. + * + * @return the overloaded client method. + */ + public ClientMethod getOverloadedClientMethod() { + return overloadedClientMethod; + } + /** * Add this ClientMethod's imports to the provided set of imports. * diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index 46b6ae16cc2..7018b681f34 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -39,6 +39,8 @@ import io.clientcore.core.annotations.ReturnType; import io.clientcore.core.http.models.HttpHeaderName; import io.clientcore.core.utils.CoreUtils; + +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -142,6 +144,10 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client final List proxyMethodParameters = clientMethod.getProxyMethod().getParameters(); List methodParameters = MethodUtil.getParameters(clientMethod, false); + List overloadedMethodParameters + = clientMethod.getOverloadedClientMethod() == null + ? Collections.emptyList() + : MethodUtil.getParameters(clientMethod.getOverloadedClientMethod(), false); for (ProxyMethodParameter parameter : proxyMethodParameters) { if (parameter.isFromClient()) { // parameter is scoped to the client, hence no local variable instantiation for it. @@ -164,16 +170,19 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client parameterWireType = ClassType.STRING; } - // If the parameter isn't required and the client method only uses required parameters, optional - // parameters are omitted and will need to instantiated in the method. - boolean optionalParameterToInitialize - = !parameter.isRequired() && parameter.getClientType() != ClassType.CONTEXT; - if (optionalParameterToInitialize) { + // If the parameter isn't required and the client method only uses required parameters, + // optional parameters will need to be locally instantiated in the method. + boolean optionalParameterToInitialize = !parameter.isRequired() && clientMethod.getOnlyRequiredParameters(); + if (!parameter.isRequired() && clientMethod.getOverloadedClientMethod() != null) { + // for overload client method for versioning boolean parameterInClientMethodSignature = methodParameters.stream().anyMatch(p -> p.getProxyMethodParameter() == parameter); + boolean parameterInOverloadedClientMethodSignature + = overloadedMethodParameters.stream().anyMatch(p -> p.getProxyMethodParameter() == parameter); // if the parameter is defined in client method signature, // it does not need to be instantiated in local variable. - optionalParameterToInitialize = !parameterInClientMethodSignature; + optionalParameterToInitialize + = !parameterInClientMethodSignature && parameterInOverloadedClientMethodSignature; } // Optional variables and constants are always null if their wire type and client type differ and applying From 02dd0135baf43aaa0d008594a199bb92b470cb81 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Thu, 27 Nov 2025 15:55:33 +0800 Subject: [PATCH 47/50] fix --- .../clientcore/ClientCoreClientMethodMapper.java | 3 ++- .../generator/core/template/ClientMethodTemplate.java | 1 - .../mgmt/mapper/FluentClientMethodMapper.java | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/clientcore/ClientCoreClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/clientcore/ClientCoreClientMethodMapper.java index 6a29b714c95..7ba333d8fd2 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/clientcore/ClientCoreClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/clientcore/ClientCoreClientMethodMapper.java @@ -34,7 +34,7 @@ protected ClientMethodParameter getContextParameter(boolean isProtocolMethod) { } @Override - protected void addClientMethodWithContext(List methods, ClientMethod baseMethod, + protected ClientMethod addClientMethodWithContext(List methods, ClientMethod baseMethod, JavaVisibility visibility, boolean isProtocolMethod) { final ClientMethodParameter contextParameter = getContextParameter(isProtocolMethod); final List parameters = new ArrayList<>(baseMethod.getParameters()); @@ -48,5 +48,6 @@ protected void addClientMethodWithContext(List methods, ClientMeth .hasWithContextOverload(false) .build(); methods.add(withContextMethod); + return withContextMethod; } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index 7018b681f34..a0b2b96de59 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -39,7 +39,6 @@ import io.clientcore.core.annotations.ReturnType; import io.clientcore.core.http.models.HttpHeaderName; import io.clientcore.core.utils.CoreUtils; - import java.util.Collections; import java.util.HashMap; import java.util.List; diff --git a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/mapper/FluentClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/mapper/FluentClientMethodMapper.java index cdf504ea502..54a1d9ba028 100644 --- a/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/mapper/FluentClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-mgmt/src/main/java/com/microsoft/typespec/http/client/generator/mgmt/mapper/FluentClientMethodMapper.java @@ -135,10 +135,6 @@ private void createLroGetFinalResultClientMethods(boolean isSync, ClientMethod b .build(); methods.add(lroGetFinalResultMethod); - // LRO '[Operation]' sync or async method overloads with versioning (for management). - createOverloadForVersioning(methods, lroGetFinalResultMethod, methodWithContextVisibility, null, - isProtocolMethod); - if (generateRequiredOnlyParametersOverload) { final ClientMethod lroGetFinalResultMethodWithRequiredOnlyParameters = lroGetFinalResultMethod.newBuilder() .onlyRequiredParameters(true) @@ -147,6 +143,11 @@ private void createLroGetFinalResultClientMethods(boolean isSync, ClientMethod b methods.add(lroGetFinalResultMethodWithRequiredOnlyParameters); } - addClientMethodWithContext(methods, lroGetFinalResultMethod, methodWithContextVisibility, isProtocolMethod); + ClientMethod clientMethodWithContext = addClientMethodWithContext(methods, lroGetFinalResultMethod, + methodWithContextVisibility, isProtocolMethod); + + // LRO '[Operation]' sync or async method overloads with versioning (for management). + createOverloadForVersioning(methods, lroGetFinalResultMethod, clientMethodWithContext, + methodWithContextVisibility, null, isProtocolMethod); } } From 18abe5be2f3d073bcf9233e6cbbb780c9e158c49 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Thu, 27 Nov 2025 17:06:29 +0800 Subject: [PATCH 48/50] regen --- .../ResiliencyServiceDrivenAsyncClient.java | 14 +- .../ResiliencyServiceDrivenClient.java | 14 +- .../fluent/TopLevelArmResourcesClient.java | 72 ++++---- .../TopLevelArmResourceImpl.java | 8 +- .../TopLevelArmResourcesClientImpl.java | 162 +++++++++--------- .../TopLevelArmResourcesImpl.java | 44 ++--- .../models/TopLevelArmResource.java | 6 +- .../models/TopLevelArmResources.java | 46 ++--- 8 files changed, 183 insertions(+), 183 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/resiliency/servicedriven/ResiliencyServiceDrivenAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/resiliency/servicedriven/ResiliencyServiceDrivenAsyncClient.java index ef087b93546..c2890ccd4ca 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/resiliency/servicedriven/ResiliencyServiceDrivenAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/resiliency/servicedriven/ResiliencyServiceDrivenAsyncClient.java @@ -275,8 +275,6 @@ public Mono fromOneOptional(String parameter, String newParameter) { * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional * parameters. * - * @param parameter I am an optional parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. @@ -286,12 +284,9 @@ public Mono fromOneOptional(String parameter, String newParameter) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono fromOneOptional(String parameter) { + public Mono fromOneOptional() { // Generated convenience method for fromOneOptionalWithResponse RequestOptions requestOptions = new RequestOptions(); - if (parameter != null) { - requestOptions.addQueryParam("parameter", parameter, false); - } return fromOneOptionalWithResponse(requestOptions).flatMap(FluxUtil::toMono); } @@ -299,6 +294,8 @@ public Mono fromOneOptional(String parameter) { * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional * parameters. * + * @param parameter I am an optional parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. @@ -308,9 +305,12 @@ public Mono fromOneOptional(String parameter) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono fromOneOptional() { + public Mono fromOneOptional(String parameter) { // Generated convenience method for fromOneOptionalWithResponse RequestOptions requestOptions = new RequestOptions(); + if (parameter != null) { + requestOptions.addQueryParam("parameter", parameter, false); + } return fromOneOptionalWithResponse(requestOptions).flatMap(FluxUtil::toMono); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/resiliency/servicedriven/ResiliencyServiceDrivenClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/resiliency/servicedriven/ResiliencyServiceDrivenClient.java index 01f4fb89e4d..44c7799e4be 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/resiliency/servicedriven/ResiliencyServiceDrivenClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/resiliency/servicedriven/ResiliencyServiceDrivenClient.java @@ -268,8 +268,6 @@ public void fromOneOptional(String parameter, String newParameter) { * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional * parameters. * - * @param parameter I am an optional parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. @@ -278,12 +276,9 @@ public void fromOneOptional(String parameter, String newParameter) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public void fromOneOptional(String parameter) { + public void fromOneOptional() { // Generated convenience method for fromOneOptionalWithResponse RequestOptions requestOptions = new RequestOptions(); - if (parameter != null) { - requestOptions.addQueryParam("parameter", parameter, false); - } fromOneOptionalWithResponse(requestOptions).getValue(); } @@ -291,6 +286,8 @@ public void fromOneOptional(String parameter) { * Tests that we can grow up an operation from accepting one optional parameter to accepting two optional * parameters. * + * @param parameter I am an optional parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. @@ -299,9 +296,12 @@ public void fromOneOptional(String parameter) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public void fromOneOptional() { + public void fromOneOptional(String parameter) { // Generated convenience method for fromOneOptionalWithResponse RequestOptions requestOptions = new RequestOptions(); + if (parameter != null) { + requestOptions.addQueryParam("parameter", parameter, false); + } fromOneOptionalWithResponse(requestOptions).getValue(); } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java index edc8c00e645..47f358f13b6 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/fluent/TopLevelArmResourcesClient.java @@ -23,8 +23,6 @@ public interface TopLevelArmResourcesClient { * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -33,8 +31,7 @@ public interface TopLevelArmResourcesClient { */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( - String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, - String parameter, Context context); + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource); /** * Create a TopLevelArmResource. @@ -42,6 +39,9 @@ SyncPoller, TopLevelArmResourceInner> begin * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -50,7 +50,8 @@ SyncPoller, TopLevelArmResourceInner> begin */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( - String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource); + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, String newParameter, Context context); /** * Create a TopLevelArmResource. @@ -59,7 +60,6 @@ SyncPoller, TopLevelArmResourceInner> begin * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -70,7 +70,7 @@ SyncPoller, TopLevelArmResourceInner> begin @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, - String parameter, String newParameter, Context context); + String parameter, Context context); /** * Create a TopLevelArmResource. @@ -78,8 +78,6 @@ SyncPoller, TopLevelArmResourceInner> begin * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -87,7 +85,7 @@ SyncPoller, TopLevelArmResourceInner> begin */ @ServiceMethod(returns = ReturnType.SINGLE) TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource, String parameter, Context context); + TopLevelArmResourceInner resource); /** * Create a TopLevelArmResource. @@ -95,6 +93,9 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -102,7 +103,7 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve */ @ServiceMethod(returns = ReturnType.SINGLE) TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource); + TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); /** * Create a TopLevelArmResource. @@ -111,7 +112,6 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -120,36 +120,36 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve */ @ServiceMethod(returns = ReturnType.SINGLE) TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource, String parameter, String newParameter, Context context); + TopLevelArmResourceInner resource, String parameter, Context context); /** * List TopLevelArmResource resources by subscription ID. * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - PagedIterable list(String parameter, Context context); + PagedIterable list(); /** * List TopLevelArmResource resources by subscription ID. * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - PagedIterable list(); + PagedIterable list(String parameter, String newParameter, Context context); /** * List TopLevelArmResource resources by subscription ID. * * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -157,41 +157,41 @@ TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLeve * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - PagedIterable list(String parameter, String newParameter, Context context); + PagedIterable list(String parameter, Context context); /** * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - PagedIterable listByResourceGroup(String resourceGroupName, String parameter, - Context context); + PagedIterable listByResourceGroup(String resourceGroupName); /** * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - PagedIterable listByResourceGroup(String resourceGroupName); + PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + String newParameter, Context context); /** * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -200,7 +200,7 @@ PagedIterable listByResourceGroup(String resourceGroup */ @ServiceMethod(returns = ReturnType.COLLECTION) PagedIterable listByResourceGroup(String resourceGroupName, String parameter, - String newParameter, Context context); + Context context); /** * Get a TopLevelArmResource. @@ -208,6 +208,7 @@ PagedIterable listByResourceGroup(String resourceGroup * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -216,7 +217,7 @@ PagedIterable listByResourceGroup(String resourceGroup */ @ServiceMethod(returns = ReturnType.SINGLE) Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, Context context); + String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context); /** * Get a TopLevelArmResource. @@ -224,7 +225,6 @@ Response getByResourceGroupWithResponse(String resourc * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -233,7 +233,7 @@ Response getByResourceGroupWithResponse(String resourc */ @ServiceMethod(returns = ReturnType.SINGLE) Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context); + String topLevelArmResourcePropertiesName, String parameter, Context context); /** * Get a TopLevelArmResource. @@ -254,6 +254,7 @@ Response getByResourceGroupWithResponse(String resourc * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -262,7 +263,7 @@ Response getByResourceGroupWithResponse(String resourc */ @ServiceMethod(returns = ReturnType.SINGLE) Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); + String parameter, String newParameter, Context context); /** * Delete a TopLevelArmResource. @@ -270,7 +271,6 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -279,7 +279,7 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe */ @ServiceMethod(returns = ReturnType.SINGLE) Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter, Context context); + String parameter, Context context); /** * Delete a TopLevelArmResource. @@ -299,6 +299,7 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -307,7 +308,7 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe */ @ServiceMethod(returns = ReturnType.SINGLE) Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); + String parameter, String newParameter, Context context); /** * A synchronous resource action. @@ -315,7 +316,6 @@ Response actionWithResponse(String resourceGroupName, String topLevelArmRe * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -324,7 +324,7 @@ Response actionWithResponse(String resourceGroupName, String topLevelArmRe */ @ServiceMethod(returns = ReturnType.SINGLE) Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter, Context context); + String parameter, Context context); /** * A synchronous resource action. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java index 6d9d1e0eba8..56789e16392 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourceImpl.java @@ -167,14 +167,14 @@ public TopLevelArmResource refresh(Context context) { return this; } - public Response actionWithResponse(String parameter, Context context) { + public Response actionWithResponse(String parameter, String newParameter, Context context) { return serviceManager.topLevelArmResources() - .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); } - public Response actionWithResponse(String parameter, String newParameter, Context context) { + public Response actionWithResponse(String parameter, Context context) { return serviceManager.topLevelArmResources() - .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); } public void action() { diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java index 491beba030b..28cc7a6e6e8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesClientImpl.java @@ -288,6 +288,7 @@ private Response createOrUpdateWithResponse(String resourceGroupName * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -298,8 +299,7 @@ private Response createOrUpdateWithResponse(String resourceGroupName @ServiceMethod(returns = ReturnType.SINGLE) private Response createOrUpdateWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, - Context context) { - final String newParameter = null; + String newParameter, Context context) { final String contentType = "application/json"; final String accept = "application/json"; return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), @@ -314,7 +314,6 @@ private Response createOrUpdateWithResponse(String resourceGroupName * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -325,7 +324,8 @@ private Response createOrUpdateWithResponse(String resourceGroupName @ServiceMethod(returns = ReturnType.SINGLE) private Response createOrUpdateWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, String parameter, - String newParameter, Context context) { + Context context) { + final String newParameter = null; final String contentType = "application/json"; final String accept = "application/json"; return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), @@ -412,8 +412,6 @@ public SyncPoller, TopLevelArmResourceInner * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -422,12 +420,13 @@ public SyncPoller, TopLevelArmResourceInner */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( - String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, - String parameter, Context context) { + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource) { + final String parameter = null; + final String newParameter = null; Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, - resource, parameter, context); + resource, parameter, newParameter); return this.client.getLroResult(response, - TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); + TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, Context.NONE); } /** @@ -436,6 +435,9 @@ public SyncPoller, TopLevelArmResourceInner * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -444,13 +446,12 @@ public SyncPoller, TopLevelArmResourceInner */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( - String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource) { - final String parameter = null; - final String newParameter = null; + String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, + String parameter, String newParameter, Context context) { Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, - resource, parameter, newParameter); + resource, parameter, newParameter, context); return this.client.getLroResult(response, - TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, Context.NONE); + TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); } /** @@ -460,7 +461,6 @@ public SyncPoller, TopLevelArmResourceInner * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -471,9 +471,9 @@ public SyncPoller, TopLevelArmResourceInner @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) public SyncPoller, TopLevelArmResourceInner> beginCreateOrUpdate( String resourceGroupName, String topLevelArmResourcePropertiesName, TopLevelArmResourceInner resource, - String parameter, String newParameter, Context context) { + String parameter, Context context) { Response response = createOrUpdateWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, - resource, parameter, newParameter, context); + resource, parameter, context); return this.client.getLroResult(response, TopLevelArmResourceInner.class, TopLevelArmResourceInner.class, context); } @@ -527,8 +527,6 @@ private Mono createOrUpdateAsync(String resourceGroupN * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -536,9 +534,11 @@ private Mono createOrUpdateAsync(String resourceGroupN */ @ServiceMethod(returns = ReturnType.SINGLE) public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource, String parameter, Context context) { - return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, context) - .getFinalResult(); + TopLevelArmResourceInner resource) { + final String parameter = null; + final String newParameter = null; + return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, + newParameter).getFinalResult(); } /** @@ -547,6 +547,9 @@ public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. @@ -554,11 +557,9 @@ public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String */ @ServiceMethod(returns = ReturnType.SINGLE) public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource) { - final String parameter = null; - final String newParameter = null; + TopLevelArmResourceInner resource, String parameter, String newParameter, Context context) { return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, - newParameter).getFinalResult(); + newParameter, context).getFinalResult(); } /** @@ -568,7 +569,6 @@ public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param resource Resource create parameters. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -577,9 +577,9 @@ public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String */ @ServiceMethod(returns = ReturnType.SINGLE) public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String topLevelArmResourcePropertiesName, - TopLevelArmResourceInner resource, String parameter, String newParameter, Context context) { - return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, - newParameter, context).getFinalResult(); + TopLevelArmResourceInner resource, String parameter, Context context) { + return beginCreateOrUpdate(resourceGroupName, topLevelArmResourcePropertiesName, resource, parameter, context) + .getFinalResult(); } /** @@ -659,6 +659,7 @@ private PagedResponse listSinglePage(String parameter, * List TopLevelArmResource resources by subscription ID. * * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -666,8 +667,8 @@ private PagedResponse listSinglePage(String parameter, * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listSinglePage(String parameter, Context context) { - final String newParameter = null; + private PagedResponse listSinglePage(String parameter, String newParameter, + Context context) { final String accept = "application/json"; Response res = service.listSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), parameter, newParameter, accept, context); @@ -679,7 +680,6 @@ private PagedResponse listSinglePage(String parameter, * List TopLevelArmResource resources by subscription ID. * * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -687,8 +687,8 @@ private PagedResponse listSinglePage(String parameter, * @return the response of a TopLevelArmResource list operation along with {@link PagedResponse}. */ @ServiceMethod(returns = ReturnType.SINGLE) - private PagedResponse listSinglePage(String parameter, String newParameter, - Context context) { + private PagedResponse listSinglePage(String parameter, Context context) { + final String newParameter = null; final String accept = "application/json"; Response res = service.listSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), parameter, newParameter, accept, context); @@ -699,39 +699,39 @@ private PagedResponse listSinglePage(String parameter, /** * List TopLevelArmResource resources by subscription ID. * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable list(String parameter, Context context) { - return new PagedIterable<>(() -> listSinglePage(parameter, context), - nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); + public PagedIterable list() { + final String parameter = null; + final String newParameter = null; + return new PagedIterable<>(() -> listSinglePage(parameter, newParameter), + nextLink -> listBySubscriptionNextSinglePage(nextLink)); } /** * List TopLevelArmResource resources by subscription ID. * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable list() { - final String parameter = null; - final String newParameter = null; - return new PagedIterable<>(() -> listSinglePage(parameter, newParameter), - nextLink -> listBySubscriptionNextSinglePage(nextLink)); + public PagedIterable list(String parameter, String newParameter, Context context) { + return new PagedIterable<>(() -> listSinglePage(parameter, newParameter, context), + nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); } /** * List TopLevelArmResource resources by subscription ID. * * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -739,8 +739,8 @@ public PagedIterable list() { * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable list(String parameter, String newParameter, Context context) { - return new PagedIterable<>(() -> listSinglePage(parameter, newParameter, context), + public PagedIterable list(String parameter, Context context) { + return new PagedIterable<>(() -> listSinglePage(parameter, context), nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); } @@ -830,6 +830,7 @@ private PagedResponse listByResourceGroupSinglePage(St * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -838,8 +839,7 @@ private PagedResponse listByResourceGroupSinglePage(St */ @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listByResourceGroupSinglePage(String resourceGroupName, - String parameter, Context context) { - final String newParameter = null; + String parameter, String newParameter, Context context) { final String accept = "application/json"; Response res = service.listByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), @@ -853,7 +853,6 @@ private PagedResponse listByResourceGroupSinglePage(St * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -862,7 +861,8 @@ private PagedResponse listByResourceGroupSinglePage(St */ @ServiceMethod(returns = ReturnType.SINGLE) private PagedResponse listByResourceGroupSinglePage(String resourceGroupName, - String parameter, String newParameter, Context context) { + String parameter, Context context) { + final String newParameter = null; final String accept = "application/json"; Response res = service.listByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), @@ -875,35 +875,37 @@ private PagedResponse listByResourceGroupSinglePage(St * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, - Context context) { - return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName, parameter, context), - nextLink -> listByResourceGroupNextSinglePage(nextLink, context)); + public PagedIterable listByResourceGroup(String resourceGroupName) { + final String parameter = null; + final String newParameter = null; + return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName, parameter, newParameter), + nextLink -> listByResourceGroupNextSinglePage(nextLink)); } /** * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listByResourceGroup(String resourceGroupName) { - final String parameter = null; - final String newParameter = null; - return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName, parameter, newParameter), - nextLink -> listByResourceGroupNextSinglePage(nextLink)); + public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + String newParameter, Context context) { + return new PagedIterable<>( + () -> listByResourceGroupSinglePage(resourceGroupName, parameter, newParameter, context), + nextLink -> listByResourceGroupNextSinglePage(nextLink, context)); } /** @@ -911,7 +913,6 @@ public PagedIterable listByResourceGroup(String resour * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -920,9 +921,8 @@ public PagedIterable listByResourceGroup(String resour */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, - String newParameter, Context context) { - return new PagedIterable<>( - () -> listByResourceGroupSinglePage(resourceGroupName, parameter, newParameter, context), + Context context) { + return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName, parameter, context), nextLink -> listByResourceGroupNextSinglePage(nextLink, context)); } @@ -974,6 +974,7 @@ private Mono getByResourceGroupAsync(String resourceGr * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -982,8 +983,7 @@ private Mono getByResourceGroupAsync(String resourceGr */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, Context context) { - final String newParameter = null; + String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { final String accept = "application/json"; return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, @@ -996,7 +996,6 @@ public Response getByResourceGroupWithResponse(String * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -1005,7 +1004,8 @@ public Response getByResourceGroupWithResponse(String */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { + String topLevelArmResourcePropertiesName, String parameter, Context context) { + final String newParameter = null; final String accept = "application/json"; return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, @@ -1077,6 +1077,7 @@ private Mono deleteAsync(String resourceGroupName, String topLevelArmResou * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -1085,8 +1086,7 @@ private Mono deleteAsync(String resourceGroupName, String topLevelArmResou */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { - final String newParameter = null; + String parameter, String newParameter, Context context) { return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); @@ -1098,7 +1098,6 @@ public Response deleteWithResponse(String resourceGroupName, String topLev * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -1107,7 +1106,8 @@ public Response deleteWithResponse(String resourceGroupName, String topLev */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter, Context context) { + String parameter, Context context) { + final String newParameter = null; return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); @@ -1175,6 +1175,7 @@ private Mono actionAsync(String resourceGroupName, String topLevelArmResou * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -1183,8 +1184,7 @@ private Mono actionAsync(String resourceGroupName, String topLevelArmResou */ @ServiceMethod(returns = ReturnType.SINGLE) public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { - final String newParameter = null; + String parameter, String newParameter, Context context) { return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); @@ -1196,7 +1196,6 @@ public Response actionWithResponse(String resourceGroupName, String topLev * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws ManagementException thrown if the request is rejected by server. @@ -1205,7 +1204,8 @@ public Response actionWithResponse(String resourceGroupName, String topLev */ @ServiceMethod(returns = ReturnType.SINGLE) public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter, Context context) { + String parameter, Context context) { + final String newParameter = null; return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java index 86e06d5aa5f..a0b31f30dba 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/implementation/TopLevelArmResourcesImpl.java @@ -27,11 +27,6 @@ public TopLevelArmResourcesImpl(TopLevelArmResourcesClient innerClient, this.serviceManager = serviceManager; } - public PagedIterable list(String parameter, Context context) { - PagedIterable inner = this.serviceClient().list(parameter, context); - return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); - } - public PagedIterable list() { PagedIterable inner = this.serviceClient().list(); return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); @@ -42,10 +37,8 @@ public PagedIterable list(String parameter, String newParam return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } - public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, - Context context) { - PagedIterable inner - = this.serviceClient().listByResourceGroup(resourceGroupName, parameter, context); + public PagedIterable list(String parameter, Context context) { + PagedIterable inner = this.serviceClient().list(parameter, context); return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } @@ -61,10 +54,18 @@ public PagedIterable listByResourceGroup(String resourceGro return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); } + public PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + Context context) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName, parameter, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new TopLevelArmResourceImpl(inner1, this.manager())); + } + public Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, Context context) { + String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { Response inner = this.serviceClient() - .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, + newParameter, context); if (inner != null) { return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), new TopLevelArmResourceImpl(inner.getValue(), this.manager())); @@ -74,10 +75,9 @@ public Response getByResourceGroupWithResponse(String resou } public Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context) { + String topLevelArmResourcePropertiesName, String parameter, Context context) { Response inner = this.serviceClient() - .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, - newParameter, context); + .getByResourceGroupWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); if (inner != null) { return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), new TopLevelArmResourceImpl(inner.getValue(), this.manager())); @@ -97,15 +97,15 @@ public TopLevelArmResource getByResourceGroup(String resourceGroupName, String t } public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { + String parameter, String newParameter, Context context) { return this.serviceClient() - .deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + .deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); } public Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter, Context context) { + String parameter, Context context) { return this.serviceClient() - .deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); + .deleteWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); } public void delete(String resourceGroupName, String topLevelArmResourcePropertiesName) { @@ -113,15 +113,15 @@ public void delete(String resourceGroupName, String topLevelArmResourcePropertie } public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context) { + String parameter, String newParameter, Context context) { return this.serviceClient() - .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); } public Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter, Context context) { + String parameter, Context context) { return this.serviceClient() - .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, newParameter, context); + .actionWithResponse(resourceGroupName, topLevelArmResourcePropertiesName, parameter, context); } public void action(String resourceGroupName, String topLevelArmResourcePropertiesName) { diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java index 0305ff904a4..5de933bb660 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResource.java @@ -322,26 +322,26 @@ interface WithNewParameter { * A synchronous resource action. * * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the {@link Response}. */ - Response actionWithResponse(String parameter, Context context); + Response actionWithResponse(String parameter, String newParameter, Context context); /** * A synchronous resource action. * * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the {@link Response}. */ - Response actionWithResponse(String parameter, String newParameter, Context context); + Response actionWithResponse(String parameter, Context context); /** * A synchronous resource action. diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java index 2f9cd86e62f..ebc8b5ca2b2 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/armversioned/models/TopLevelArmResources.java @@ -15,75 +15,75 @@ public interface TopLevelArmResources { /** * List TopLevelArmResource resources by subscription ID. * - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ - PagedIterable list(String parameter, Context context); + PagedIterable list(); /** * List TopLevelArmResource resources by subscription ID. * + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ - PagedIterable list(); + PagedIterable list(String parameter, String newParameter, Context context); /** * List TopLevelArmResource resources by subscription ID. * * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ - PagedIterable list(String parameter, String newParameter, Context context); + PagedIterable list(String parameter, Context context); /** * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. - * @param parameter The parameter parameter. - * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ - PagedIterable listByResourceGroup(String resourceGroupName, String parameter, Context context); + PagedIterable listByResourceGroup(String resourceGroupName); /** * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. + * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ - PagedIterable listByResourceGroup(String resourceGroupName); + PagedIterable listByResourceGroup(String resourceGroupName, String parameter, + String newParameter, Context context); /** * List TopLevelArmResource resources by resource group. * * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response of a TopLevelArmResource list operation as paginated response with {@link PagedIterable}. */ - PagedIterable listByResourceGroup(String resourceGroupName, String parameter, - String newParameter, Context context); + PagedIterable listByResourceGroup(String resourceGroupName, String parameter, Context context); /** * Get a TopLevelArmResource. @@ -91,6 +91,7 @@ PagedIterable listByResourceGroup(String resourceGroupName, * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -98,7 +99,7 @@ PagedIterable listByResourceGroup(String resourceGroupName, * @return a TopLevelArmResource along with {@link Response}. */ Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, Context context); + String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context); /** * Get a TopLevelArmResource. @@ -106,7 +107,6 @@ Response getByResourceGroupWithResponse(String resourceGrou * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -114,7 +114,7 @@ Response getByResourceGroupWithResponse(String resourceGrou * @return a TopLevelArmResource along with {@link Response}. */ Response getByResourceGroupWithResponse(String resourceGroupName, - String topLevelArmResourcePropertiesName, String parameter, String newParameter, Context context); + String topLevelArmResourcePropertiesName, String parameter, Context context); /** * Get a TopLevelArmResource. @@ -134,6 +134,7 @@ Response getByResourceGroupWithResponse(String resourceGrou * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -141,7 +142,7 @@ Response getByResourceGroupWithResponse(String resourceGrou * @return the {@link Response}. */ Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); + String parameter, String newParameter, Context context); /** * Delete a TopLevelArmResource. @@ -149,7 +150,6 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -157,7 +157,7 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe * @return the {@link Response}. */ Response deleteWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter, Context context); + String parameter, Context context); /** * Delete a TopLevelArmResource. @@ -176,6 +176,7 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. + * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -183,7 +184,7 @@ Response deleteWithResponse(String resourceGroupName, String topLevelArmRe * @return the {@link Response}. */ Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, Context context); + String parameter, String newParameter, Context context); /** * A synchronous resource action. @@ -191,7 +192,6 @@ Response actionWithResponse(String resourceGroupName, String topLevelArmRe * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param topLevelArmResourcePropertiesName The name of the TopLevelArmResourceProperties. * @param parameter The parameter parameter. - * @param newParameter The newParameter parameter. * @param context The context to associate with this operation. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. @@ -199,7 +199,7 @@ Response actionWithResponse(String resourceGroupName, String topLevelArmRe * @return the {@link Response}. */ Response actionWithResponse(String resourceGroupName, String topLevelArmResourcePropertiesName, - String parameter, String newParameter, Context context); + String parameter, Context context); /** * A synchronous resource action. From fbba5d92c9bb439896ec5a2d0657d74c7a8213ef Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 28 Nov 2025 10:50:51 +0800 Subject: [PATCH 49/50] comment --- .../generator/core/template/ClientMethodTemplate.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index a0b2b96de59..5798d1ad879 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -141,12 +141,16 @@ protected static void addOptionalVariables(JavaBlock function, ClientMethod clie protected static void addOptionalAndConstantVariables(JavaBlock function, ClientMethod clientMethod, JavaSettings settings) { final List proxyMethodParameters = clientMethod.getProxyMethod().getParameters(); + + // for client method that overload another method (of full parameters) + // clientMethod.getOverloadedClientMethod() List methodParameters = MethodUtil.getParameters(clientMethod, false); List overloadedMethodParameters = clientMethod.getOverloadedClientMethod() == null ? Collections.emptyList() : MethodUtil.getParameters(clientMethod.getOverloadedClientMethod(), false); + for (ProxyMethodParameter parameter : proxyMethodParameters) { if (parameter.isFromClient()) { // parameter is scoped to the client, hence no local variable instantiation for it. @@ -173,13 +177,14 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client // optional parameters will need to be locally instantiated in the method. boolean optionalParameterToInitialize = !parameter.isRequired() && clientMethod.getOnlyRequiredParameters(); if (!parameter.isRequired() && clientMethod.getOverloadedClientMethod() != null) { - // for overload client method for versioning + // for overload client method for versioning of "@added" boolean parameterInClientMethodSignature = methodParameters.stream().anyMatch(p -> p.getProxyMethodParameter() == parameter); boolean parameterInOverloadedClientMethodSignature = overloadedMethodParameters.stream().anyMatch(p -> p.getProxyMethodParameter() == parameter); - // if the parameter is defined in client method signature, - // it does not need to be instantiated in local variable. + // if the parameter is not defined in this client method, + // but it is defined in the overloaded client method (the one with full parameters), + // we would need to treat it as optional parameter and locally initialize it in this client method. optionalParameterToInitialize = !parameterInClientMethodSignature && parameterInOverloadedClientMethodSignature; } From 2dea730e8309b4009d5d78fcae690e5962daec16 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 1 Dec 2025 11:15:47 +0800 Subject: [PATCH 50/50] comment and javadoc --- .../core/mapper/ClientMethodMapper.java | 22 +++++++++++++------ .../core/template/ClientMethodTemplate.java | 4 ++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java index bd8f8dfc932..d666f6b89d2 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java @@ -355,9 +355,19 @@ private static JavaVisibility methodVisibilityInWrapperClient(Operation operatio } } + /** + * Creates overload client methods, on versioning with "@added" parameterrs + * + * @param methods the list of client methods to add to + * @param baseMethod the base method with full parameters, it does not contain SDK parameters like Context + * @param overloadedMethod the overloaded method to be associated with the created overload client methods + * @param methodVisibility the visibility of the overload client methods + * @param methodPageDetails the page details of the overload client methods, can be {@code null} + * @param isProtocolMethod whether the operation is a protocol method + */ protected void createOverloadForVersioning(List methods, ClientMethod baseMethod, - ClientMethod overloadedMethod, JavaVisibility methodWithContextVisibility, - MethodPageDetails methodPageDetailsWithContext, boolean isProtocolMethod) { + ClientMethod overloadedMethod, JavaVisibility methodVisibility, MethodPageDetails methodPageDetails, + boolean isProtocolMethod) { final List parameters = baseMethod.getParameters(); if (!isProtocolMethod) { if (parameters.stream().anyMatch(p -> p.getVersioning() != null && p.getVersioning().getAdded() != null)) { @@ -376,13 +386,11 @@ protected void createOverloadForVersioning(List methods, ClientMet ClientMethod.Builder overloadedMethodBuilder = baseMethod.newBuilder() .overloadedClientMethod(overloadedMethod) .parameters(overloadedParameters); - if (methodPageDetailsWithContext != null) { - overloadedMethodBuilder - = overloadedMethodBuilder.methodPageDetails(methodPageDetailsWithContext); + if (methodPageDetails != null) { + overloadedMethodBuilder = overloadedMethodBuilder.methodPageDetails(methodPageDetails); } final ClientMethod overloadMethod = overloadedMethodBuilder.build(); - addClientMethodWithContext(methods, overloadMethod, methodWithContextVisibility, - isProtocolMethod); + addClientMethodWithContext(methods, overloadMethod, methodVisibility, isProtocolMethod); } } } diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java index 5798d1ad879..54953eb3edd 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ClientMethodTemplate.java @@ -176,6 +176,10 @@ protected static void addOptionalAndConstantVariables(JavaBlock function, Client // If the parameter isn't required and the client method only uses required parameters, // optional parameters will need to be locally instantiated in the method. boolean optionalParameterToInitialize = !parameter.isRequired() && clientMethod.getOnlyRequiredParameters(); + + // For overload client method for versioning of "@added". + // In this case, the client method with required and optional parameters may not be the method with full + // parameters. And we need to refine the value of "optionalParameterToInitialize". if (!parameter.isRequired() && clientMethod.getOverloadedClientMethod() != null) { // for overload client method for versioning of "@added" boolean parameterInClientMethodSignature