diff --git a/typespec-extension/src/code-model-builder.ts b/typespec-extension/src/code-model-builder.ts index e35ea1ad93..f53c36847c 100644 --- a/typespec-extension/src/code-model-builder.ts +++ b/typespec-extension/src/code-model-builder.ts @@ -267,7 +267,7 @@ export class CodeModelBuilder { private processHost(server: HttpServer | undefined): Parameter[] { const hostParameters: Parameter[] = []; - if (server) { + if (server && !this.isArmSynthesizedServer(server)) { server.parameters.forEach((it) => { let parameter; @@ -542,7 +542,7 @@ export class CodeModelBuilder { // server let baseUri = "{endpoint}"; const servers = getServers(this.program, client.service); - if (servers && servers.length === 1) { + if (servers && servers.length === 1 && !this.isArmSynthesizedServer(servers[0])) { baseUri = servers[0].url; } const hostParameters = this.processHost(servers?.length === 1 ? servers[0] : undefined); @@ -629,6 +629,18 @@ export class CodeModelBuilder { return clients; } + /** + * `@armProviderNamespace` currently will add a default server if not defined globally: + * https://github.com/Azure/typespec-azure/blob/8b8d7c05f168d9305a09691c4fedcb88f4a57652/packages/typespec-azure-resource-manager/src/namespace.ts#L121-L128 + * TODO: if the synthesized server has the right hostParameter, we can use that insteadß + * + * @param server returned by getServers + * @returns whether it's synthesized by `@armProviderNamespace` + */ + private isArmSynthesizedServer(server: HttpServer): boolean { + return this.isArm() && (!server.parameters || server.parameters.size == 0); + } + private needToSkipProcessingOperation(operation: Operation, clientContext: ClientContext): boolean { // don't generate protocol and convenience method for overloaded operations // issue link: https://github.com/Azure/autorest.java/issues/1958#issuecomment-1562558219 we will support generate overload methods for non-union type in future (TODO issue: https://github.com/Azure/autorest.java/issues/2160) @@ -2778,8 +2790,8 @@ export class CodeModelBuilder { } } - private isArm() { - return this.codeModel.arm; + private isArm(): boolean { + return Boolean(this.codeModel.arm); } private isSchemaUsageEmpty(schema: Schema): boolean { diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/ArmResourceProviderManager.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/ArmResourceProviderManager.java index 5377b8c316..2b8e88c943 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/ArmResourceProviderManager.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/ArmResourceProviderManager.java @@ -55,7 +55,8 @@ private ArmResourceProviderManager(HttpPipeline httpPipeline, AzureProfile profi Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); Objects.requireNonNull(profile, "'profile' cannot be null."); this.clientObject = new ArmResourceProviderClientBuilder().pipeline(httpPipeline) - .subscriptionId(profile.getSubscriptionId()).defaultPollInterval(defaultPollInterval).buildClient(); + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()).subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval).buildClient(); } /** diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java index f7b0986155..b26726eaa4 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/fluent/ArmResourceProviderClient.java @@ -11,6 +11,13 @@ * The interface for ArmResourceProviderClient class. */ public interface ArmResourceProviderClient { + /** + * Gets Server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + /** * Gets Version parameter. * diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java index b45d274793..7a0be0c466 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientBuilder.java @@ -19,6 +19,22 @@ */ @ServiceClientBuilder(serviceClients = { ArmResourceProviderClientImpl.class }) public final class ArmResourceProviderClientBuilder { + /* + * Server parameter + */ + private String endpoint; + + /** + * Sets Server parameter. + * + * @param endpoint the endpoint value. + * @return the ArmResourceProviderClientBuilder. + */ + public ArmResourceProviderClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + /* * The ID of the target subscription. */ @@ -113,7 +129,7 @@ public ArmResourceProviderClientImpl buildClient() { SerializerAdapter localSerializerAdapter = (serializerAdapter != null) ? serializerAdapter : SerializerFactory.createDefaultManagementSerializerAdapter(); ArmResourceProviderClientImpl client = new ArmResourceProviderClientImpl(localPipeline, localSerializerAdapter, - localDefaultPollInterval, localEnvironment, this.subscriptionId); + localDefaultPollInterval, localEnvironment, this.endpoint, this.subscriptionId); return client; } } diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java index 9d0da89fb2..1a6ce62d02 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ArmResourceProviderClientImpl.java @@ -40,6 +40,20 @@ */ @ServiceClient(builder = ArmResourceProviderClientBuilder.class) public final class ArmResourceProviderClientImpl implements ArmResourceProviderClient { + /** + * Server parameter. + */ + private final String endpoint; + + /** + * Gets Server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + /** * Version parameter. */ @@ -159,13 +173,15 @@ public OperationsClient getOperations() { * @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 Server parameter. * @param subscriptionId The ID of the target subscription. */ ArmResourceProviderClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, - Duration defaultPollInterval, AzureEnvironment environment, String subscriptionId) { + 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 = "2023-11-01"; this.childResourcesInterfaces = new ChildResourcesInterfacesClientImpl(this); diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java index f9c0648149..c9d79aa611 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/ChildResourcesInterfacesClientImpl.java @@ -11,6 +11,7 @@ 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.Patch; import com.azure.core.annotation.PathParam; import com.azure.core.annotation.Put; @@ -68,15 +69,15 @@ public final class ChildResourcesInterfacesClientImpl implements ChildResourcesI * The interface defining all the services for ArmResourceProviderClientChildResourcesInterfaces to be used by the * proxy service to perform REST calls. */ - @Host("https://management.azure.com") + @Host("{endpoint}") @ServiceInterface(name = "ArmResourceProviderC") public interface ChildResourcesInterfacesService { @Headers({ "Content-Type: application/json" }) @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> get(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono> get(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @PathParam("childResourceName") String childResourceName, @HeaderParam("accept") String accept, @@ -86,8 +87,8 @@ Mono> get(@QueryParam("api-version") String apiVers @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") @ExpectedResponses({ 200, 201 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono>> createOrUpdate(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @PathParam("childResourceName") String childResourceName, @HeaderParam("accept") String accept, @@ -97,8 +98,8 @@ Mono>> createOrUpdate(@QueryParam("api-version") Strin @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> update(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @PathParam("childResourceName") String childResourceName, @HeaderParam("accept") String accept, @@ -108,8 +109,8 @@ Mono> update(@QueryParam("api-version") String apiV @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources/{childResourceName}") @ExpectedResponses({ 200, 202, 204 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono>> delete(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @PathParam("childResourceName") String childResourceName, @HeaderParam("accept") String accept, @@ -119,8 +120,8 @@ Mono>> delete(@QueryParam("api-version") String apiVer @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}/childResources") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> listByTopLevelArmResource(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono> listByTopLevelArmResource(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("accept") String accept, Context context); @@ -130,8 +131,8 @@ Mono> listByTopLevelArmResource(@QueryParam("a @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) Mono> listByTopLevelArmResourceNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, @HeaderParam("accept") String accept, - Context context); + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, Context context); } /** @@ -148,6 +149,10 @@ Mono> listByTopLevelArmResourceNext( @ServiceMethod(returns = ReturnType.SINGLE) private Mono> getWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, String childResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -166,8 +171,9 @@ private Mono> getWithResponseAsync(String resourceG } final String accept = "application/json"; return FluxUtil - .withContext(context -> service.get(this.client.getApiVersion(), this.client.getSubscriptionId(), - resourceGroupName, topLevelArmResourceName, childResourceName, accept, context)) + .withContext(context -> service.get(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, accept, + context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -186,6 +192,10 @@ private Mono> getWithResponseAsync(String resourceG @ServiceMethod(returns = ReturnType.SINGLE) private Mono> getWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, String childResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -204,8 +214,8 @@ private Mono> getWithResponseAsync(String resourceG } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.get(this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, - topLevelArmResourceName, childResourceName, accept, context); + return service.get(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, childResourceName, accept, context); } /** @@ -276,6 +286,10 @@ public ChildResourceInner get(String resourceGroupName, String topLevelArmResour @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, String childResourceName, ChildResourceInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -299,8 +313,9 @@ private Mono>> createOrUpdateWithResponseAsync(String } final String accept = "application/json"; return FluxUtil - .withContext(context -> service.createOrUpdate(this.client.getApiVersion(), this.client.getSubscriptionId(), - resourceGroupName, topLevelArmResourceName, childResourceName, accept, resource, context)) + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, accept, + resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -321,6 +336,10 @@ private Mono>> createOrUpdateWithResponseAsync(String @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, String childResourceName, ChildResourceInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -344,8 +363,9 @@ private Mono>> createOrUpdateWithResponseAsync(String } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.createOrUpdate(this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, - topLevelArmResourceName, childResourceName, accept, resource, context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, accept, + resource, context); } /** @@ -527,6 +547,10 @@ public ChildResourceInner createOrUpdate(String resourceGroupName, String topLev @ServiceMethod(returns = ReturnType.SINGLE) private Mono> updateWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, String childResourceName, ChildResourceUpdate properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -550,8 +574,9 @@ private Mono> updateWithResponseAsync(String resour } final String accept = "application/json"; return FluxUtil - .withContext(context -> service.update(this.client.getApiVersion(), this.client.getSubscriptionId(), - resourceGroupName, topLevelArmResourceName, childResourceName, accept, properties, context)) + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, accept, + properties, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -572,6 +597,10 @@ private Mono> updateWithResponseAsync(String resour @ServiceMethod(returns = ReturnType.SINGLE) private Mono> updateWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, String childResourceName, ChildResourceUpdate properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -595,8 +624,8 @@ private Mono> updateWithResponseAsync(String resour } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.update(this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, - topLevelArmResourceName, childResourceName, accept, properties, context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, childResourceName, accept, properties, context); } /** @@ -671,6 +700,10 @@ public ChildResourceInner update(String resourceGroupName, String topLevelArmRes @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> deleteWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, String childResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -689,8 +722,9 @@ private Mono>> deleteWithResponseAsync(String resource } final String accept = "application/json"; return FluxUtil - .withContext(context -> service.delete(this.client.getApiVersion(), this.client.getSubscriptionId(), - resourceGroupName, topLevelArmResourceName, childResourceName, accept, context)) + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, childResourceName, accept, + context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -709,6 +743,10 @@ private Mono>> deleteWithResponseAsync(String resource @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> deleteWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, String childResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -727,8 +765,8 @@ private Mono>> deleteWithResponseAsync(String resource } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.delete(this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, - topLevelArmResourceName, childResourceName, accept, context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, childResourceName, accept, context); } /** @@ -891,6 +929,10 @@ public void delete(String resourceGroupName, String topLevelArmResourceName, Str @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listByTopLevelArmResourceSinglePageAsync(String resourceGroupName, String topLevelArmResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -905,8 +947,9 @@ private Mono> listByTopLevelArmResourceSingleP } final String accept = "application/json"; return FluxUtil - .withContext(context -> service.listByTopLevelArmResource(this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context)) + .withContext( + context -> service.listByTopLevelArmResource(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, 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())); @@ -927,6 +970,10 @@ private Mono> listByTopLevelArmResourceSingleP @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listByTopLevelArmResourceSinglePageAsync(String resourceGroupName, String topLevelArmResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -942,8 +989,8 @@ private Mono> listByTopLevelArmResourceSingleP final String accept = "application/json"; context = this.client.mergeContext(context); return service - .listByTopLevelArmResource(this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, - topLevelArmResourceName, accept, context) + .listByTopLevelArmResource(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context) .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)); } @@ -1035,8 +1082,14 @@ private Mono> listByTopLevelArmResourceNextSin if (nextLink == null) { return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; - return FluxUtil.withContext(context -> service.listByTopLevelArmResourceNext(nextLink, accept, context)) + return FluxUtil + .withContext( + context -> service.listByTopLevelArmResourceNext(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())); @@ -1061,9 +1114,13 @@ private Mono> listByTopLevelArmResourceNextSin if (nextLink == null) { return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.listByTopLevelArmResourceNext(nextLink, accept, context) + return service.listByTopLevelArmResourceNext(nextLink, this.client.getEndpoint(), accept, context) .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)); } diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java index 3fb60f3a33..12d43bc83f 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/OperationsClientImpl.java @@ -9,6 +9,7 @@ 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.QueryParam; import com.azure.core.annotation.ReturnType; @@ -58,22 +59,22 @@ public final class OperationsClientImpl implements OperationsClient { * The interface defining all the services for ArmResourceProviderClientOperations to be used by the proxy service * to perform REST calls. */ - @Host("https://management.azure.com") + @Host("{endpoint}") @ServiceInterface(name = "ArmResourceProviderC") public interface OperationsService { @Headers({ "Content-Type: application/json" }) @Get("/providers/Cadl.ArmResourceProvider/operations") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> list(@QueryParam("api-version") String apiVersion, - @HeaderParam("accept") String accept, Context context); + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, Context context); @Headers({ "Content-Type: application/json" }) @Get("{nextLink}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, - @HeaderParam("accept") String accept, Context context); + @HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, Context context); } /** @@ -86,8 +87,14 @@ Mono> listNext(@PathParam(value = "nextLink", encoded = */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; - return FluxUtil.withContext(context -> service.list(this.client.getApiVersion(), accept, context)) + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), 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())); @@ -105,9 +112,13 @@ private Mono> listSinglePageAsync() { */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.list(this.client.getApiVersion(), accept, context) + return service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)); } @@ -186,8 +197,12 @@ private Mono> listNextSinglePageAsync(String nextL if (nextLink == null) { return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; - return FluxUtil.withContext(context -> service.listNext(nextLink, accept, context)) + return FluxUtil.withContext(context -> service.listNext(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())); @@ -211,9 +226,14 @@ private Mono> listNextSinglePageAsync(String nextL if (nextLink == null) { return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.listNext(nextLink, accept, context).map(res -> new PagedResponseBase<>(res.getRequest(), - res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)); + return service.listNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); } } diff --git a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java index 344ea12645..9e74504679 100644 --- a/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java +++ b/typespec-tests/src/main/java/com/cadl/armresourceprovider/implementation/TopLevelArmResourceInterfacesClientImpl.java @@ -11,6 +11,7 @@ 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.Patch; import com.azure.core.annotation.PathParam; import com.azure.core.annotation.Put; @@ -68,15 +69,15 @@ public final class TopLevelArmResourceInterfacesClientImpl implements TopLevelAr * The interface defining all the services for ArmResourceProviderClientTopLevelArmResourceInterfaces to be used by * the proxy service to perform REST calls. */ - @Host("https://management.azure.com") + @Host("{endpoint}") @ServiceInterface(name = "ArmResourceProviderC") public interface TopLevelArmResourceInterfacesService { @Headers({ "Content-Type: application/json" }) @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> getByResourceGroup(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("accept") String accept, Context context); @@ -85,8 +86,8 @@ Mono> getByResourceGroup(@QueryParam("api-ver @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}") @ExpectedResponses({ 200, 201 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono>> createOrUpdate(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("accept") String accept, @BodyParam("application/json") TopLevelArmResourceInner resource, Context context); @@ -95,8 +96,8 @@ Mono>> createOrUpdate(@QueryParam("api-version") Strin @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> update(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("accept") String accept, @BodyParam("application/json") TopLevelArmResourceUpdate properties, Context context); @@ -105,8 +106,8 @@ Mono> update(@QueryParam("api-version") Strin @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources/{topLevelArmResourceName}") @ExpectedResponses({ 200, 202, 204 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono>> delete(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("topLevelArmResourceName") String topLevelArmResourceName, @HeaderParam("accept") String accept, Context context); @@ -115,8 +116,8 @@ Mono>> delete(@QueryParam("api-version") String apiVer @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Cadl.ArmResourceProvider/topLevelArmResources") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> listByResourceGroup(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, + Mono> listByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("accept") String accept, Context context); @@ -124,24 +125,25 @@ Mono> listByResourceGroup(@QueryParam("a @Get("/subscriptions/{subscriptionId}/providers/Cadl.ArmResourceProvider/topLevelArmResources") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(ManagementException.class) - Mono> list(@QueryParam("api-version") String apiVersion, - @PathParam("subscriptionId") String subscriptionId, @HeaderParam("accept") String accept, Context context); + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @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, @HeaderParam("accept") String accept, - Context context); + @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> listBySubscriptionNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, @HeaderParam("accept") String accept, - Context context); + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, Context context); } /** @@ -157,6 +159,10 @@ Mono> listBySubscriptionNext( @ServiceMethod(returns = ReturnType.SINGLE) private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, String topLevelArmResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -171,7 +177,7 @@ private Mono> getByResourceGroupWithResponseA } final String accept = "application/json"; return FluxUtil - .withContext(context -> service.getByResourceGroup(this.client.getApiVersion(), + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -190,6 +196,10 @@ private Mono> getByResourceGroupWithResponseA @ServiceMethod(returns = ReturnType.SINGLE) private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -204,8 +214,8 @@ private Mono> getByResourceGroupWithResponseA } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.getByResourceGroup(this.client.getApiVersion(), this.client.getSubscriptionId(), - resourceGroupName, topLevelArmResourceName, accept, context); + return service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context); } /** @@ -272,6 +282,10 @@ public TopLevelArmResourceInner getByResourceGroup(String resourceGroupName, Str @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -291,8 +305,8 @@ private Mono>> createOrUpdateWithResponseAsync(String } final String accept = "application/json"; return FluxUtil - .withContext(context -> service.createOrUpdate(this.client.getApiVersion(), this.client.getSubscriptionId(), - resourceGroupName, topLevelArmResourceName, accept, resource, context)) + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -312,6 +326,10 @@ private Mono>> createOrUpdateWithResponseAsync(String @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -331,8 +349,8 @@ private Mono>> createOrUpdateWithResponseAsync(String } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.createOrUpdate(this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, - topLevelArmResourceName, accept, resource, context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, resource, context); } /** @@ -507,6 +525,10 @@ public TopLevelArmResourceInner createOrUpdate(String resourceGroupName, String @ServiceMethod(returns = ReturnType.SINGLE) private Mono> updateWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceUpdate properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -525,9 +547,8 @@ private Mono> updateWithResponseAsync(String properties.validate(); } final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.update(this.client.getApiVersion(), this.client.getSubscriptionId(), - resourceGroupName, topLevelArmResourceName, accept, properties, context)) + return FluxUtil.withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, properties, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -547,6 +568,10 @@ private Mono> updateWithResponseAsync(String @ServiceMethod(returns = ReturnType.SINGLE) private Mono> updateWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, TopLevelArmResourceUpdate properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -566,8 +591,8 @@ private Mono> updateWithResponseAsync(String } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.update(this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, - topLevelArmResourceName, accept, properties, context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, accept, properties, context); } /** @@ -638,6 +663,10 @@ public TopLevelArmResourceInner update(String resourceGroupName, String topLevel @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> deleteWithResponseAsync(String resourceGroupName, String topLevelArmResourceName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -652,8 +681,8 @@ private Mono>> deleteWithResponseAsync(String resource } final String accept = "application/json"; return FluxUtil - .withContext(context -> service.delete(this.client.getApiVersion(), this.client.getSubscriptionId(), - resourceGroupName, topLevelArmResourceName, accept, context)) + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, topLevelArmResourceName, accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -671,6 +700,10 @@ private Mono>> deleteWithResponseAsync(String resource @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> deleteWithResponseAsync(String resourceGroupName, String topLevelArmResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -685,8 +718,8 @@ private Mono>> deleteWithResponseAsync(String resource } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.delete(this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, - topLevelArmResourceName, accept, context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, topLevelArmResourceName, accept, context); } /** @@ -834,6 +867,10 @@ public void delete(String resourceGroupName, String topLevelArmResourceName, Con */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -844,7 +881,7 @@ private Mono> listByResourceGroupSingleP } final String accept = "application/json"; return FluxUtil - .withContext(context -> service.listByResourceGroup(this.client.getApiVersion(), + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, accept, context)) .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) @@ -865,6 +902,10 @@ private Mono> listByResourceGroupSingleP @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); @@ -876,8 +917,8 @@ private Mono> listByResourceGroupSingleP final String accept = "application/json"; context = this.client.mergeContext(context); return service - .listByResourceGroup(this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, - accept, context) + .listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context) .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)); } @@ -952,14 +993,18 @@ public PagedIterable listByResourceGroup(String resour */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); } final String accept = "application/json"; return FluxUtil - .withContext( - context -> service.list(this.client.getApiVersion(), this.client.getSubscriptionId(), accept, context)) + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), 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())); @@ -977,13 +1022,19 @@ private Mono> listSinglePageAsync() { */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } if (this.client.getSubscriptionId() == null) { return Mono.error(new IllegalArgumentException( "Parameter this.client.getSubscriptionId() is required and cannot be null.")); } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.list(this.client.getApiVersion(), this.client.getSubscriptionId(), accept, context) + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), accept, + context) .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)); } @@ -1059,8 +1110,14 @@ private Mono> listByResourceGroupNextSin if (nextLink == null) { return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; - return FluxUtil.withContext(context -> service.listByResourceGroupNext(nextLink, accept, context)) + 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())); @@ -1085,9 +1142,13 @@ private Mono> listByResourceGroupNextSin if (nextLink == null) { return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.listByResourceGroupNext(nextLink, accept, context) + return 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)); } @@ -1109,8 +1170,14 @@ private Mono> listBySubscriptionNextSing if (nextLink == null) { return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; - return FluxUtil.withContext(context -> service.listBySubscriptionNext(nextLink, accept, context)) + 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())); @@ -1135,9 +1202,13 @@ private Mono> listBySubscriptionNextSing if (nextLink == null) { return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } final String accept = "application/json"; context = this.client.mergeContext(context); - return service.listBySubscriptionNext(nextLink, accept, context) + return 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)); }