Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
7c81a00
fallback to version compare by date
weidongxu-microsoft Oct 21, 2025
941939b
set to undefined, if cannot find version in apiVersions
weidongxu-microsoft Oct 21, 2025
c598d4e
nit
weidongxu-microsoft Oct 21, 2025
e49c321
fix lint
weidongxu-microsoft Oct 21, 2025
225dd59
test case
weidongxu-microsoft Oct 21, 2025
a668d88
nit to cover the case of the erasure of preview api-version
weidongxu-microsoft Oct 21, 2025
ea588f3
Merge branch 'main' into http-client-java_versioning-non-dpg
weidongxu-microsoft Oct 22, 2025
8d2f7ab
partial tool
weidongxu-microsoft Oct 22, 2025
ff2e84e
simple method uses WithResponse
weidongxu-microsoft Oct 22, 2025
bb96c02
enhance
weidongxu-microsoft Oct 23, 2025
032f3a9
Merge branch 'main' into http-client-java_versioning-non-dpg
weidongxu-microsoft Nov 18, 2025
99ae880
improve client method template to recognize parameter that need to be…
weidongxu-microsoft Nov 18, 2025
f01061b
format
weidongxu-microsoft Nov 18, 2025
d6652f0
regen
weidongxu-microsoft Nov 18, 2025
0aa271a
advanced versioning for arm-versioned test
weidongxu-microsoft Nov 18, 2025
5e17044
regen with advanced-versioning
weidongxu-microsoft Nov 18, 2025
a61c34a
test
weidongxu-microsoft Nov 18, 2025
ce526d0
Merge branch 'main' into http-client-java_versioning-non-dpg
weidongxu-microsoft Nov 25, 2025
0fa3f33
update addOptionalVariables
weidongxu-microsoft Nov 25, 2025
b4fa958
Revert "update addOptionalVariables"
weidongxu-microsoft Nov 25, 2025
d8f7ed4
overload for LRO createOrUpdate in mgmt
weidongxu-microsoft Nov 25, 2025
ffb4c88
overload for method for lro and pageable
weidongxu-microsoft Nov 25, 2025
a451335
regen
weidongxu-microsoft Nov 25, 2025
64218ae
mgmt, update logic for taking the client method of full parameters
weidongxu-microsoft Nov 25, 2025
d99c9cd
update npm deps
weidongxu-microsoft Nov 25, 2025
2b3b222
bug fix
weidongxu-microsoft Nov 25, 2025
9653e35
regen
weidongxu-microsoft Nov 25, 2025
7648f09
update test
weidongxu-microsoft Nov 25, 2025
4991205
make a diff
weidongxu-microsoft Nov 25, 2025
2fe0045
Revert "make a diff"
weidongxu-microsoft Nov 25, 2025
00fcc47
Merge branch 'http-client-java_versioning-non-dpg' of https://github.…
weidongxu-microsoft Nov 25, 2025
0686df8
comment
weidongxu-microsoft Nov 25, 2025
1f57aed
delete type that not used
weidongxu-microsoft Nov 25, 2025
218b6ba
we can remove the condition
weidongxu-microsoft Nov 25, 2025
ccf67b6
Update packages/http-client-java/generator/http-client-generator-core…
weidongxu-microsoft Nov 26, 2025
7c93f90
format
weidongxu-microsoft Nov 26, 2025
bf9d6ea
Merge branch 'main' into http-client-java_versioning-non-dpg
weidongxu-microsoft Nov 26, 2025
e730949
add more API to test case
weidongxu-microsoft Nov 26, 2025
f4f4461
bug fix for not taking the client method of full parameters
weidongxu-microsoft Nov 26, 2025
7e90d5c
Merge branch 'http-client-java_versioning-non-dpg' of https://github.…
weidongxu-microsoft Nov 26, 2025
dd89acb
regen
weidongxu-microsoft Nov 26, 2025
66dcfba
update test
weidongxu-microsoft Nov 26, 2025
55551cf
regen
weidongxu-microsoft Nov 26, 2025
f420686
update test
weidongxu-microsoft Nov 26, 2025
07fb92f
fix and test
weidongxu-microsoft Nov 26, 2025
8e13f79
comment
weidongxu-microsoft Nov 26, 2025
3f11d0d
regen
weidongxu-microsoft Nov 26, 2025
6a8d204
demonstrate for case without advanced-versioning
weidongxu-microsoft Nov 26, 2025
2fba784
Revert "demonstrate for case without advanced-versioning"
weidongxu-microsoft Nov 26, 2025
90c1119
rename to make the var easier to understand
weidongxu-microsoft Nov 27, 2025
ef26163
add overloadedClientMethod var to ClientMethod
weidongxu-microsoft Nov 27, 2025
a041c47
refine the logic
weidongxu-microsoft Nov 27, 2025
02dd013
fix
weidongxu-microsoft Nov 27, 2025
18abe5b
regen
weidongxu-microsoft Nov 27, 2025
fbba5d9
comment
weidongxu-microsoft Nov 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,35 @@ private static JavaVisibility methodVisibilityInWrapperClient(Operation operatio
}
}

private static void createOverloadForVersioning(boolean isProtocolMethod, List<ClientMethod> methods,
ClientMethod baseMethod) {
protected void createOverloadForVersioning(List<ClientMethod> methods, ClientMethod baseMethod,
Copy link
Member

Choose a reason for hiding this comment

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

might be worth to add some javadoc about this method.

ClientMethod overloadedMethod, JavaVisibility methodWithContextVisibility,
MethodPageDetails methodPageDetailsWithContext, boolean isProtocolMethod) {
final List<ClientMethodParameter> parameters = baseMethod.getParameters();
if (!isProtocolMethod && JavaSettings.getInstance().isDataPlaneClient()) {
if (!isProtocolMethod) {
if (parameters.stream().anyMatch(p -> p.getVersioning() != null && p.getVersioning().getAdded() != null)) {
// versioning of @added exists
final List<List<ClientMethodParameter>> signatures = findOverloadedSignatures(parameters);
for (List<ClientMethodParameter> overloadedParameters : signatures) {
final ClientMethod overloadedMethod
= baseMethod.newBuilder().parameters(overloadedParameters).build();
methods.add(overloadedMethod);
if (JavaSettings.getInstance().isDataPlaneClient()) {
// DPG
final ClientMethod overloadMethod = baseMethod.newBuilder()
.overloadedClientMethod(overloadedMethod)
.parameters(overloadedParameters)
.build();
methods.add(overloadMethod);
} else {
// non-DPG
ClientMethod.Builder overloadedMethodBuilder = baseMethod.newBuilder()
.overloadedClientMethod(overloadedMethod)
.parameters(overloadedParameters);
if (methodPageDetailsWithContext != null) {
overloadedMethodBuilder
= overloadedMethodBuilder.methodPageDetails(methodPageDetailsWithContext);
}
final ClientMethod overloadMethod = overloadedMethodBuilder.build();
addClientMethodWithContext(methods, overloadMethod, methodWithContextVisibility,
isProtocolMethod);
}
}
}
}
Expand Down Expand Up @@ -457,7 +476,12 @@ private void createSinglePageClientMethods(boolean isSync, ClientMethod baseMeth
}

// 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,
Expand Down Expand Up @@ -508,8 +532,6 @@ 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
createOverloadForVersioning(isProtocolMethod, methods, pagingMethod);
}

if (generateRequiredOnlyParametersOverload) {
Expand All @@ -526,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<ClientMethod> methods,
Expand Down Expand Up @@ -575,7 +602,13 @@ private void createLroWithResponseClientMethods(boolean isSync, ClientMethod bas
.hasWithContextOverload(methodWithContextVisibility != NOT_GENERATE)
.build();
methods.add(withResponseMethod);
addClientMethodWithContext(methods, withResponseMethod, methodWithContextVisibility, isProtocolMethod);

ClientMethod clientMethodWithContext
= 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,
Expand Down Expand Up @@ -614,7 +647,13 @@ private void createFluentLroWithResponseSyncClientMethods(Operation operation, C
.methodVisibility(NOT_VISIBLE)
.build();
methods.add(withResponseSyncMethod);
addClientMethodWithContext(methods, withResponseSyncMethod, NOT_VISIBLE, isProtocolMethod);

ClientMethod clientMethodWithContext
= 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,
Expand Down Expand Up @@ -704,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(isProtocolMethod, methods, beginLroMethod);

if (generateRequiredOnlyParametersOverload) {
// LRO 'begin[Operation]' sync or async method overload with only required parameters.
final ClientMethod beginLroMethodWithRequiredParameters = beginLroMethod.newBuilder()
Expand All @@ -717,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<ClientMethod> methods,
Expand Down Expand Up @@ -764,10 +805,16 @@ private void createSimpleWithResponseClientMethods(boolean isSync, ClientMethod
.hasWithContextOverload(hasContextOverload)
.methodVisibility(methodVisibility)
.build();

// 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<ClientMethod> methods,
Expand Down Expand Up @@ -807,17 +854,19 @@ private void createSimpleValueClientMethods(boolean isSync, ClientMethod baseMet
.build();
methods.add(simpleMethod);

// overload for versioning
createOverloadForVersioning(isProtocolMethod, methods, simpleMethod);

if (generateRequiredOnlyParametersOverload) {
final ClientMethod simpleMethodWithRequiredParameters = simpleMethod.newBuilder()
.methodVisibility(methodWithRequiredParametersVisibility)
.onlyRequiredParameters(true)
.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);
}

/**
Expand Down Expand Up @@ -937,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<ClientMethod> methods, ClientMethod baseMethod,
protected ClientMethod addClientMethodWithContext(List<ClientMethod> methods, ClientMethod baseMethod,
JavaVisibility visibility, boolean isProtocolMethod) {
final ClientMethodParameter contextParameter = getContextParameter(isProtocolMethod);
final List<ClientMethodParameter> parameters = new ArrayList<>(baseMethod.getParameters());
Expand All @@ -954,6 +1004,7 @@ protected void addClientMethodWithContext(List<ClientMethod> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected ClientMethodParameter getContextParameter(boolean isProtocolMethod) {
}

@Override
protected void addClientMethodWithContext(List<ClientMethod> methods, ClientMethod baseMethod,
protected ClientMethod addClientMethodWithContext(List<ClientMethod> methods, ClientMethod baseMethod,
JavaVisibility visibility, boolean isProtocolMethod) {
final ClientMethodParameter contextParameter = getContextParameter(isProtocolMethod);
final List<ClientMethodParameter> parameters = new ArrayList<>(baseMethod.getParameters());
Expand All @@ -48,5 +48,6 @@ protected void addClientMethodWithContext(List<ClientMethod> methods, ClientMeth
.hasWithContextOverload(false)
.build();
methods.add(withContextMethod);
return withContextMethod;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -137,7 +139,8 @@ public ClientMethod.Builder newBuilder() {
.methodDocumentation(externalDocumentation)
.operationInstrumentationInfo(instrumentationInfo)
.setCrossLanguageDefinitionId(crossLanguageDefinitionId)
.hasWithContextOverload(hasWithContextOverload);
.hasWithContextOverload(hasWithContextOverload)
.overloadedClientMethod(overloadedClientMethod);
}

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -443,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.
*
Expand Down Expand Up @@ -633,6 +646,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;
Expand Down Expand Up @@ -882,6 +896,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.
*/
Expand All @@ -891,7 +916,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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public enum ClientMethodType {
* Mono&lt;PagedResponseBase&lt;H,T&gt;&gt;.
*/
PagingAsyncSinglePage(2, true, false, false),
SimulatedPagingSync(3, false, false, true), // unused
Copy link
Member

Choose a reason for hiding this comment

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

double confirm: is this just code clean up unrelated to advanced versioning?

SimulatedPagingAsync(4, false, false, false), // unused
/**
* represents long-running method that returns T where T is the final result of the LRO.
*/
Expand Down
Loading
Loading