Skip to content

Commit fd97b9c

Browse files
committed
incorporating review feedback (simplify createFluentLroWithResponseSyncClientMethods, JavaDoc, var-names)
1 parent cf00577 commit fd97b9c

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/ClientMethodMapper.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -609,33 +609,33 @@ private void createFluentLroWithResponseSyncClientMethods(Operation operation, C
609609

610610
final JavaSettings settings = createMethodArgs.settings;
611611
final boolean isProtocolMethod = createMethodArgs.isProtocolMethod;
612-
final MethodOverloadType defaultOverloadType = createMethodArgs.defaultOverloadType;
613612
final ClientMethodsReturnDescription methodsReturnDescription = createMethodArgs.methodsReturnDescription;
614613
final ProxyMethod proxyMethod = baseMethod.getProxyMethod();
615614

616-
final JavaVisibility methodWithContextVisibility;
617-
if (settings.isDataPlaneClient()) {
618-
methodWithContextVisibility = NOT_VISIBLE;
619-
} else {
620-
methodWithContextVisibility = methodVisibility(ClientMethodType.SimpleSyncRestResponse, defaultOverloadType,
621-
true, isProtocolMethod);
622-
}
623-
624615
final IType baseType = ClassType.BINARY_DATA;
625616
final IType returnType = ResponseTypeFactory.createSyncResponse(operation, baseType, isProtocolMethod, settings,
626617
proxyMethod.isCustomHeaderIgnored());
627618
final ReturnValue binaryDataResponse = methodsReturnDescription.createReturnValue(returnType, baseType);
628619

629-
// Fluent '[Operation]WithResponse' LRO sync method, with required and optional parameters.
630-
// Fluent + Sync stack needs simple rest response for implementation only.
620+
// Fluent + Sync-Stack needs LRO '[Operation]WithResponse' in implementation scope to enable LRO
621+
// 'begin[Operation]'.
622+
// Design discussion: https://github.com/Azure/autorest.java/issues/2284
623+
//
624+
// The sync api corresponding to the below 'withResponseSyncMethod' ClientMethod would look like,
625+
//
626+
// - private Response<BinaryData> createOrUpdateWithResponse(..)
627+
//
628+
// such a private api will be used to implement the public LRO 'begin[Operation]' sync method:
629+
//
630+
// - public SyncPoller<PollResult<Foo>, Foo> beginCreateOrUpdate(..)
631631
//
632632
final ClientMethod withResponseSyncMethod = baseMethod.newBuilder()
633633
.returnValue(binaryDataResponse)
634634
.name(proxyMethod.getSimpleRestResponseMethodName())
635635
.onlyRequiredParameters(false)
636636
.type(ClientMethodType.SimpleSyncRestResponse)
637637
.groupedParameterRequired(false)
638-
.hasWithContextOverload(methodWithContextVisibility != NOT_GENERATE)
638+
.hasWithContextOverload(true)
639639
.proxyMethod(proxyMethod.toSync())
640640
.methodVisibility(NOT_VISIBLE)
641641
.build();

packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/mapper/PollingMetadata.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,19 @@ private static PollingMetadata create(LongRunningMetadata lroMetadata, PollingSe
218218
if (lroMetadata.getPollingStrategy() != null) {
219219
final String strategyName = lroMetadata.getPollingStrategy().getLanguage().getJava().getName();
220220
final String strategyFqName = packageName + "." + strategyName;
221-
final String syncStrategyFqdnName = packageName + "." + "Sync" + strategyName;
221+
final String syncStrategyFqName = packageName + "." + "Sync" + strategyName;
222222

223223
if (lroMetadata.getFinalResultPropertySerializedName() != null) {
224224
final String finalResultArg
225225
= ClassType.STRING.defaultValueExpression(lroMetadata.getFinalResultPropertySerializedName());
226226
pollingStrategy = String.format(PollingSettings.INSTANTIATE_POLLING_STRATEGY_WITH_RESULT_FORMAT,
227227
strategyFqName, finalResultArg);
228228
syncPollingStrategy = String.format(PollingSettings.INSTANTIATE_POLLING_STRATEGY_WITH_RESULT_FORMAT,
229-
syncStrategyFqdnName, finalResultArg);
229+
syncStrategyFqName, finalResultArg);
230230
} else {
231231
pollingStrategy = String.format(PollingSettings.INSTANTIATE_POLLING_STRATEGY_FORMAT, strategyFqName);
232232
syncPollingStrategy
233-
= String.format(PollingSettings.INSTANTIATE_POLLING_STRATEGY_FORMAT, syncStrategyFqdnName);
233+
= String.format(PollingSettings.INSTANTIATE_POLLING_STRATEGY_FORMAT, syncStrategyFqName);
234234
}
235235
} else {
236236
pollingStrategy = pollingSettings.getPollingStrategy();

packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClientMethod.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,22 @@ public class ClientMethod {
4646
*/
4747
private final String name;
4848
/**
49-
* The parameters of this ClientMethod.
49+
* An immutable list containing all parameters defined for the operation-endpoint, including constants, client
50+
* and method-scoped parameters.
5051
*/
5152
private final List<ClientMethodParameter> _parameters;
53+
/**
54+
* A copy of {@code _parameters} returned from the {@link ClientMethod#getParameters()}.
55+
*/
5256
private final List<ClientMethodParameter> parameters;
57+
/**
58+
* The subset of parameters in {@code parameters} that are scoped only to the method.
59+
*/
5360
private final List<ClientMethodParameter> methodParameters;
61+
/**
62+
* The subset of parameters in {@code methodParameters} that are required for the method.
63+
*/
5464
private final List<ClientMethodParameter> methodRequiredParameters;
55-
5665
/**
5766
* Whether this ClientMethod has omitted optional parameters.
5867
*/

0 commit comments

Comments
 (0)