From e2ee661c44abe581e16bb5f71b552d03fa75846f Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 5 Jan 2026 16:08:53 +0800 Subject: [PATCH 1/3] sync core --- core | 2 +- .../combined/fluent/Combined.java | 7 - .../combined/implementation/CombinedImpl.java | 15 - .../implementation/DisksClientImpl.java | 21 +- .../VirtualMachinesClientImpl.java | 21 +- .../combined/CombinedBuilder.java | 24 +- .../combined/ServiceAServiceVersion.java | 45 --- .../combined/implementation/BarsImpl.java | 19 +- .../combined/implementation/CombinedImpl.java | 30 +- .../combined/implementation/FoosImpl.java | 19 +- .../multipleapiversion/FirstAsyncClient.java | 89 ----- .../multipleapiversion/FirstClient.java | 86 ----- .../FirstClientBuilder.java | 308 ---------------- .../FirstServiceVersion.java | 45 --- .../NoApiVersionAsyncClient.java | 72 ---- .../NoApiVersionClient.java | 69 ---- .../NoApiVersionClientBuilder.java | 308 ---------------- .../NoApiVersionServiceVersion.java | 45 --- .../multipleapiversion/SecondAsyncClient.java | 89 ----- .../multipleapiversion/SecondClient.java | 86 ----- .../SecondClientBuilder.java | 308 ---------------- .../SecondServiceVersion.java | 45 --- .../implementation/FirstClientImpl.java | 225 ------------ .../NoApiVersionClientImpl.java | 194 ----------- .../implementation/SecondClientImpl.java | 225 ------------ .../implementation/package-info.java | 10 - .../multipleapiversion/models/Resource.java | 125 ------- .../multipleapiversion/models/Resource2.java | 125 ------- .../models/package-info.java | 10 - .../multipleapiversion/package-info.java | 10 - .../tsptest/server/ContosoServiceVersion.java | 40 --- .../tsptest/server/HttpbinAsyncClient.java | 75 ---- .../java/tsptest/server/HttpbinClient.java | 72 ---- .../tsptest/server/HttpbinClientBuilder.java | 326 ----------------- .../server/contoso/models/APIVersions.java | 51 --- .../server/contoso/models/package-info.java | 10 - .../contoso/sub/ContosoAsyncClient.java | 75 ---- .../server/contoso/sub/ContosoClient.java | 72 ---- .../contoso/sub/ContosoClientBuilder.java | 328 ------------------ .../server/contoso/sub/package-info.java | 10 - .../implementation/ContosoClientImpl.java | 216 ------------ .../implementation/HttpbinClientImpl.java | 215 ------------ .../server/implementation/package-info.java | 10 - .../java/tsptest/server/package-info.java | 10 - .../tsptest-multipleapiversion.properties | 2 - .../main/resources/tsptest-server.properties | 2 - .../multiservice/ArmMultipleServiceTests.java | 39 +++ .../multiservice/MultipleServiceTests.java | 21 ++ .../generated/FirstClientTestBase.java | 60 ---- .../test/java/tsptest/server/ServerTests.java | 19 - .../generated/HttpbinClientTestBase.java | 51 --- typespec-tests/tsp/multiple-apiversion.tsp | 101 ------ typespec-tests/tsp/server.tsp | 65 ---- 53 files changed, 104 insertions(+), 4443 deletions(-) delete mode 100644 typespec-tests/src/main/java/service/multiservice/combined/ServiceAServiceVersion.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/FirstAsyncClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/FirstClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/FirstClientBuilder.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/FirstServiceVersion.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionAsyncClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionClientBuilder.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionServiceVersion.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/SecondAsyncClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/SecondClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/SecondClientBuilder.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/SecondServiceVersion.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/FirstClientImpl.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/NoApiVersionClientImpl.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/SecondClientImpl.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/package-info.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/models/Resource.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/models/Resource2.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/models/package-info.java delete mode 100644 typespec-tests/src/main/java/tsptest/multipleapiversion/package-info.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/ContosoServiceVersion.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/HttpbinAsyncClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/HttpbinClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/HttpbinClientBuilder.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/contoso/models/APIVersions.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/contoso/models/package-info.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoAsyncClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoClient.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoClientBuilder.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/contoso/sub/package-info.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/implementation/ContosoClientImpl.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/implementation/HttpbinClientImpl.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/implementation/package-info.java delete mode 100644 typespec-tests/src/main/java/tsptest/server/package-info.java delete mode 100644 typespec-tests/src/main/resources/tsptest-multipleapiversion.properties delete mode 100644 typespec-tests/src/main/resources/tsptest-server.properties create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiservice/ArmMultipleServiceTests.java create mode 100644 typespec-tests/src/test/java/service/multiservice/MultipleServiceTests.java delete mode 100644 typespec-tests/src/test/java/tsptest/multipleapiversion/generated/FirstClientTestBase.java delete mode 100644 typespec-tests/src/test/java/tsptest/server/ServerTests.java delete mode 100644 typespec-tests/src/test/java/tsptest/server/generated/HttpbinClientTestBase.java delete mode 100644 typespec-tests/tsp/multiple-apiversion.tsp delete mode 100644 typespec-tests/tsp/server.tsp diff --git a/core b/core index 664978b3cf..ec964751bf 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 664978b3cf7399e43e2823d3a69043203e740109 +Subproject commit ec964751bff845d8eeb3892b8983f91c1ae72bfa diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/fluent/Combined.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/fluent/Combined.java index 34d52fe5aa..2cca6a21a4 100644 --- a/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/fluent/Combined.java +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/fluent/Combined.java @@ -18,13 +18,6 @@ public interface Combined { */ String getEndpoint(); - /** - * Gets Version parameter. - * - * @return the apiVersion value. - */ - String getApiVersion(); - /** * Gets The ID of the target subscription. The value must be an UUID. * diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/CombinedImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/CombinedImpl.java index 4e1282d491..3082d51ed3 100644 --- a/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/CombinedImpl.java +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/CombinedImpl.java @@ -57,20 +57,6 @@ 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. */ @@ -172,7 +158,6 @@ public DisksClient getDisks() { this.defaultPollInterval = defaultPollInterval; this.endpoint = endpoint; this.subscriptionId = subscriptionId; - this.apiVersion = "2025-04-01"; this.virtualMachines = new VirtualMachinesClientImpl(this); this.disks = new DisksClientImpl(this); } diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/DisksClientImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/DisksClientImpl.java index d46361c0be..163e986aa1 100644 --- a/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/DisksClientImpl.java +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/DisksClientImpl.java @@ -112,9 +112,10 @@ Response createOrUpdateSync(@HostParam("endpoint") String endpoint, */ @ServiceMethod(returns = ReturnType.SINGLE) private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, String diskName) { + final String apiVersion = "2025-01-02"; final String accept = "application/json"; return FluxUtil - .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), resourceGroupName, diskName, accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -149,9 +150,10 @@ private Mono getByResourceGroupAsync(String resourceGroupName, String @ServiceMethod(returns = ReturnType.SINGLE) public Response getByResourceGroupWithResponse(String resourceGroupName, String diskName, Context context) { + final String apiVersion = "2025-01-02"; final String accept = "application/json"; - return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, diskName, accept, context); + return service.getByResourceGroupSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, diskName, accept, context); } /** @@ -183,10 +185,11 @@ public DiskInner getByResourceGroup(String resourceGroupName, String diskName) { @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String diskName, DiskInner resource) { + final String apiVersion = "2025-01-02"; final String contentType = "application/json"; final String accept = "application/json"; return FluxUtil - .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), resourceGroupName, diskName, contentType, accept, resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -205,10 +208,11 @@ private Mono>> createOrUpdateWithResponseAsync(String @ServiceMethod(returns = ReturnType.SINGLE) private Response createOrUpdateWithResponse(String resourceGroupName, String diskName, DiskInner resource) { + final String apiVersion = "2025-01-02"; final String contentType = "application/json"; final String accept = "application/json"; - return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, diskName, contentType, accept, resource, Context.NONE); + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, diskName, contentType, accept, resource, Context.NONE); } /** @@ -226,10 +230,11 @@ private Response createOrUpdateWithResponse(String resourceGroupName @ServiceMethod(returns = ReturnType.SINGLE) private Response createOrUpdateWithResponse(String resourceGroupName, String diskName, DiskInner resource, Context context) { + final String apiVersion = "2025-01-02"; final String contentType = "application/json"; final String accept = "application/json"; - return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, diskName, contentType, accept, resource, context); + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, diskName, contentType, accept, resource, context); } /** diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/VirtualMachinesClientImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/VirtualMachinesClientImpl.java index 2553053f80..46c32f950a 100644 --- a/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/VirtualMachinesClientImpl.java +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservice/combined/implementation/VirtualMachinesClientImpl.java @@ -115,9 +115,10 @@ Response createOrUpdateSync(@HostParam("endpoint") String endpoint, @ServiceMethod(returns = ReturnType.SINGLE) private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, String vmName) { + final String apiVersion = "2025-04-01"; final String accept = "application/json"; return FluxUtil - .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), resourceGroupName, vmName, accept, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -152,9 +153,10 @@ private Mono getByResourceGroupAsync(String resourceGroupNa @ServiceMethod(returns = ReturnType.SINGLE) public Response getByResourceGroupWithResponse(String resourceGroupName, String vmName, Context context) { + final String apiVersion = "2025-04-01"; final String accept = "application/json"; - return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, vmName, accept, context); + return service.getByResourceGroupSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, vmName, accept, context); } /** @@ -187,10 +189,11 @@ public VirtualMachineInner getByResourceGroup(String resourceGroupName, String v @ServiceMethod(returns = ReturnType.SINGLE) private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String vmName, VirtualMachineInner resource) { + final String apiVersion = "2025-04-01"; final String contentType = "application/json"; final String accept = "application/json"; return FluxUtil - .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), resourceGroupName, vmName, contentType, accept, resource, context)) .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); } @@ -210,10 +213,11 @@ private Mono>> createOrUpdateWithResponseAsync(String @ServiceMethod(returns = ReturnType.SINGLE) private Response createOrUpdateWithResponse(String resourceGroupName, String vmName, VirtualMachineInner resource) { + final String apiVersion = "2025-04-01"; final String contentType = "application/json"; final String accept = "application/json"; - return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, vmName, contentType, accept, resource, Context.NONE); + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, vmName, contentType, accept, resource, Context.NONE); } /** @@ -232,10 +236,11 @@ private Response createOrUpdateWithResponse(String resourceGroupName @ServiceMethod(returns = ReturnType.SINGLE) private Response createOrUpdateWithResponse(String resourceGroupName, String vmName, VirtualMachineInner resource, Context context) { + final String apiVersion = "2025-04-01"; final String contentType = "application/json"; final String accept = "application/json"; - return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), - this.client.getSubscriptionId(), resourceGroupName, vmName, contentType, accept, resource, context); + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, vmName, contentType, accept, resource, context); } /** diff --git a/typespec-tests/src/main/java/service/multiservice/combined/CombinedBuilder.java b/typespec-tests/src/main/java/service/multiservice/combined/CombinedBuilder.java index cc8acd00b7..b89f4e03a2 100644 --- a/typespec-tests/src/main/java/service/multiservice/combined/CombinedBuilder.java +++ b/typespec-tests/src/main/java/service/multiservice/combined/CombinedBuilder.java @@ -190,24 +190,6 @@ public CombinedBuilder endpoint(String endpoint) { return this; } - /* - * Service version - */ - @Generated - private ServiceAServiceVersion serviceVersion; - - /** - * Sets Service version. - * - * @param serviceVersion the serviceVersion value. - * @return the CombinedBuilder. - */ - @Generated - public CombinedBuilder serviceVersion(ServiceAServiceVersion serviceVersion) { - this.serviceVersion = serviceVersion; - return this; - } - /* * The retry policy that will attempt to retry failed requests, if applicable. */ @@ -236,10 +218,8 @@ private CombinedImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; - ServiceAServiceVersion localServiceVersion - = (serviceVersion != null) ? serviceVersion : ServiceAServiceVersion.getLatest(); - CombinedImpl client = new CombinedImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), - localEndpoint, localServiceVersion); + CombinedImpl client + = new CombinedImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } diff --git a/typespec-tests/src/main/java/service/multiservice/combined/ServiceAServiceVersion.java b/typespec-tests/src/main/java/service/multiservice/combined/ServiceAServiceVersion.java deleted file mode 100644 index a400682653..0000000000 --- a/typespec-tests/src/main/java/service/multiservice/combined/ServiceAServiceVersion.java +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package service.multiservice.combined; - -import com.azure.core.util.ServiceVersion; - -/** - * Service version of ServiceAClient. - */ -public enum ServiceAServiceVersion implements ServiceVersion { - /** - * Enum value av1. - */ - VAV1("av1"), - - /** - * Enum value av2. - */ - VAV2("av2"); - - private final String version; - - ServiceAServiceVersion(String version) { - this.version = version; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVersion() { - return this.version; - } - - /** - * Gets the latest service version supported by this client library. - * - * @return The latest {@link ServiceAServiceVersion}. - */ - public static ServiceAServiceVersion getLatest() { - return VAV2; - } -} diff --git a/typespec-tests/src/main/java/service/multiservice/combined/implementation/BarsImpl.java b/typespec-tests/src/main/java/service/multiservice/combined/implementation/BarsImpl.java index 21ae41f7af..c481c89603 100644 --- a/typespec-tests/src/main/java/service/multiservice/combined/implementation/BarsImpl.java +++ b/typespec-tests/src/main/java/service/multiservice/combined/implementation/BarsImpl.java @@ -23,7 +23,6 @@ import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; import reactor.core.publisher.Mono; -import service.multiservice.combined.ServiceAServiceVersion; /** * An instance of this class provides access to all the operations defined in Bars. @@ -49,15 +48,6 @@ public final class BarsImpl { this.client = client; } - /** - * Gets Service version. - * - * @return the serviceVersion value. - */ - public ServiceAServiceVersion getServiceVersion() { - return client.getServiceVersion(); - } - /** * The interface defining all the services for CombinedBars to be used by the proxy service to perform REST calls. */ @@ -95,8 +85,9 @@ Response testSync(@HostParam("endpoint") String endpoint, @QueryParam("api */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> testWithResponseAsync(RequestOptions requestOptions) { - return FluxUtil.withContext(context -> service.test(this.client.getEndpoint(), - this.client.getServiceVersion().getVersion(), requestOptions, context)); + final String apiVersion = "bv2"; + return FluxUtil + .withContext(context -> service.test(this.client.getEndpoint(), apiVersion, requestOptions, context)); } /** @@ -111,7 +102,7 @@ public Mono> testWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response testWithResponse(RequestOptions requestOptions) { - return service.testSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), requestOptions, - Context.NONE); + final String apiVersion = "bv2"; + return service.testSync(this.client.getEndpoint(), apiVersion, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/service/multiservice/combined/implementation/CombinedImpl.java b/typespec-tests/src/main/java/service/multiservice/combined/implementation/CombinedImpl.java index 8c18060258..d524e6a1b3 100644 --- a/typespec-tests/src/main/java/service/multiservice/combined/implementation/CombinedImpl.java +++ b/typespec-tests/src/main/java/service/multiservice/combined/implementation/CombinedImpl.java @@ -10,7 +10,6 @@ import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; -import service.multiservice.combined.ServiceAServiceVersion; /** * Initializes a new instance of the Combined type. @@ -30,20 +29,6 @@ public String getEndpoint() { return this.endpoint; } - /** - * Service version. - */ - private final ServiceAServiceVersion serviceVersion; - - /** - * Gets Service version. - * - * @return the serviceVersion value. - */ - public ServiceAServiceVersion getServiceVersion() { - return this.serviceVersion; - } - /** * The HTTP pipeline to send requests through. */ @@ -104,11 +89,10 @@ public BarsImpl getBars() { * Initializes an instance of Combined client. * * @param endpoint Service host. - * @param serviceVersion Service version. */ - public CombinedImpl(String endpoint, ServiceAServiceVersion serviceVersion) { + public CombinedImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -116,10 +100,9 @@ public CombinedImpl(String endpoint, ServiceAServiceVersion serviceVersion) { * * @param httpPipeline The HTTP pipeline to send requests through. * @param endpoint Service host. - * @param serviceVersion Service version. */ - public CombinedImpl(HttpPipeline httpPipeline, String endpoint, ServiceAServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); + public CombinedImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** @@ -128,14 +111,11 @@ public CombinedImpl(HttpPipeline httpPipeline, String endpoint, ServiceAServiceV * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. * @param endpoint Service host. - * @param serviceVersion Service version. */ - public CombinedImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, - ServiceAServiceVersion serviceVersion) { + public CombinedImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; - this.serviceVersion = serviceVersion; this.foos = new FoosImpl(this); this.bars = new BarsImpl(this); } diff --git a/typespec-tests/src/main/java/service/multiservice/combined/implementation/FoosImpl.java b/typespec-tests/src/main/java/service/multiservice/combined/implementation/FoosImpl.java index 59071060d4..fe46738155 100644 --- a/typespec-tests/src/main/java/service/multiservice/combined/implementation/FoosImpl.java +++ b/typespec-tests/src/main/java/service/multiservice/combined/implementation/FoosImpl.java @@ -23,7 +23,6 @@ import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; import reactor.core.publisher.Mono; -import service.multiservice.combined.ServiceAServiceVersion; /** * An instance of this class provides access to all the operations defined in Foos. @@ -49,15 +48,6 @@ public final class FoosImpl { this.client = client; } - /** - * Gets Service version. - * - * @return the serviceVersion value. - */ - public ServiceAServiceVersion getServiceVersion() { - return client.getServiceVersion(); - } - /** * The interface defining all the services for CombinedFoos to be used by the proxy service to perform REST calls. */ @@ -95,8 +85,9 @@ Response testSync(@HostParam("endpoint") String endpoint, @QueryParam("api */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> testWithResponseAsync(RequestOptions requestOptions) { - return FluxUtil.withContext(context -> service.test(this.client.getEndpoint(), - this.client.getServiceVersion().getVersion(), requestOptions, context)); + final String apiVersion = "av2"; + return FluxUtil + .withContext(context -> service.test(this.client.getEndpoint(), apiVersion, requestOptions, context)); } /** @@ -111,7 +102,7 @@ public Mono> testWithResponseAsync(RequestOptions requestOptions) */ @ServiceMethod(returns = ReturnType.SINGLE) public Response testWithResponse(RequestOptions requestOptions) { - return service.testSync(this.client.getEndpoint(), this.client.getServiceVersion().getVersion(), requestOptions, - Context.NONE); + final String apiVersion = "av2"; + return service.testSync(this.client.getEndpoint(), apiVersion, requestOptions, Context.NONE); } } diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstAsyncClient.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstAsyncClient.java deleted file mode 100644 index 1006384b72..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstAsyncClient.java +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import com.azure.core.util.FluxUtil; -import reactor.core.publisher.Mono; -import tsptest.multipleapiversion.implementation.FirstClientImpl; -import tsptest.multipleapiversion.models.Resource; - -/** - * Initializes a new instance of the asynchronous FirstClient type. - */ -@ServiceClient(builder = FirstClientBuilder.class, isAsync = true) -public final class FirstAsyncClient { - @Generated - private final FirstClientImpl serviceClient; - - /** - * Initializes an instance of FirstAsyncClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - FirstAsyncClient(FirstClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * Resource read operation template. - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     name: String (Required)
-     *     type: String (Required)
-     * }
-     * }
-     * 
- * - * @param name The name parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponse(String name, RequestOptions requestOptions) { - return this.serviceClient.getWithResponseAsync(name, requestOptions); - } - - /** - * Resource read operation template. - * - * @param name The name 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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono get(String name) { - // Generated convenience method for getWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(Resource.class)); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstClient.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstClient.java deleted file mode 100644 index 846b3a93e6..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstClient.java +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import tsptest.multipleapiversion.implementation.FirstClientImpl; -import tsptest.multipleapiversion.models.Resource; - -/** - * Initializes a new instance of the synchronous FirstClient type. - */ -@ServiceClient(builder = FirstClientBuilder.class) -public final class FirstClient { - @Generated - private final FirstClientImpl serviceClient; - - /** - * Initializes an instance of FirstClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - FirstClient(FirstClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * Resource read operation template. - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     name: String (Required)
-     *     type: String (Required)
-     * }
-     * }
-     * 
- * - * @param name The name parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String name, RequestOptions requestOptions) { - return this.serviceClient.getWithResponse(name, requestOptions); - } - - /** - * Resource read operation template. - * - * @param name The name 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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Resource get(String name) { - // Generated convenience method for getWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getWithResponse(name, requestOptions).getValue().toObject(Resource.class); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstClientBuilder.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstClientBuilder.java deleted file mode 100644 index 65f18f04bd..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstClientBuilder.java +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.EndpointTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -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.AddHeadersPolicy; -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.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.builder.ClientBuilderUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.serializer.JacksonAdapter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import tsptest.multipleapiversion.implementation.FirstClientImpl; - -/** - * A builder for creating a new instance of the FirstClient type. - */ -@ServiceClientBuilder(serviceClients = { FirstClient.class, FirstAsyncClient.class }) -public final class FirstClientBuilder implements HttpTrait, ConfigurationTrait, - EndpointTrait { - @Generated - private static final String SDK_NAME = "name"; - - @Generated - private static final String SDK_VERSION = "version"; - - @Generated - private static final Map PROPERTIES - = CoreUtils.getProperties("tsptest-multipleapiversion.properties"); - - @Generated - private final List pipelinePolicies; - - /** - * Create an instance of the FirstClientBuilder. - */ - @Generated - public FirstClientBuilder() { - this.pipelinePolicies = new ArrayList<>(); - } - - /* - * The HTTP client used to send the request. - */ - @Generated - private HttpClient httpClient; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public FirstClientBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /* - * The HTTP pipeline to send requests through. - */ - @Generated - private HttpPipeline pipeline; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public FirstClientBuilder pipeline(HttpPipeline pipeline) { - if (this.pipeline != null && pipeline == null) { - LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); - } - this.pipeline = pipeline; - return this; - } - - /* - * The logging configuration for HTTP requests and responses. - */ - @Generated - private HttpLogOptions httpLogOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public FirstClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { - this.httpLogOptions = httpLogOptions; - return this; - } - - /* - * The client options such as application ID and custom headers to set on a request. - */ - @Generated - private ClientOptions clientOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public FirstClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - return this; - } - - /* - * The retry options to configure retry policy for failed requests. - */ - @Generated - private RetryOptions retryOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public FirstClientBuilder retryOptions(RetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public FirstClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { - Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); - pipelinePolicies.add(customPolicy); - return this; - } - - /* - * The configuration store that is used during construction of the service client. - */ - @Generated - private Configuration configuration; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public FirstClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /* - * The service endpoint - */ - @Generated - private String endpoint; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public FirstClientBuilder endpoint(String endpoint) { - this.endpoint = endpoint; - return this; - } - - /* - * Service version - */ - @Generated - private FirstServiceVersion serviceVersion; - - /** - * Sets Service version. - * - * @param serviceVersion the serviceVersion value. - * @return the FirstClientBuilder. - */ - @Generated - public FirstClientBuilder serviceVersion(FirstServiceVersion serviceVersion) { - this.serviceVersion = serviceVersion; - return this; - } - - /* - * The retry policy that will attempt to retry failed requests, if applicable. - */ - @Generated - private RetryPolicy retryPolicy; - - /** - * Sets The retry policy that will attempt to retry failed requests, if applicable. - * - * @param retryPolicy the retryPolicy value. - * @return the FirstClientBuilder. - */ - @Generated - public FirstClientBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - return this; - } - - /** - * Builds an instance of FirstClientImpl with the provided parameters. - * - * @return an instance of FirstClientImpl. - */ - @Generated - private FirstClientImpl buildInnerClient() { - this.validateClient(); - HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - FirstServiceVersion localServiceVersion - = (serviceVersion != null) ? serviceVersion : FirstServiceVersion.getLatest(); - FirstClientImpl client = new FirstClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), - this.endpoint, localServiceVersion); - return client; - } - - @Generated - private void validateClient() { - // This method is invoked from 'buildInnerClient'/'buildClient' method. - // Developer can customize this method, to validate that the necessary conditions are met for the new client. - Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); - } - - @Generated - private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration - = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; - ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; - List policies = new ArrayList<>(); - String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); - policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); - policies.add(new RequestIdPolicy()); - policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); - if (headers != null) { - policies.add(new AddHeadersPolicy(headers)); - } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); - policies.add(new AddDatePolicy()); - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(localHttpLogOptions)); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); - return httpPipeline; - } - - /** - * Builds an instance of FirstAsyncClient class. - * - * @return an instance of FirstAsyncClient. - */ - @Generated - public FirstAsyncClient buildAsyncClient() { - return new FirstAsyncClient(buildInnerClient()); - } - - /** - * Builds an instance of FirstClient class. - * - * @return an instance of FirstClient. - */ - @Generated - public FirstClient buildClient() { - return new FirstClient(buildInnerClient()); - } - - private static final ClientLogger LOGGER = new ClientLogger(FirstClientBuilder.class); -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstServiceVersion.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstServiceVersion.java deleted file mode 100644 index bbc89eb9ab..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/FirstServiceVersion.java +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.util.ServiceVersion; - -/** - * Service version of FirstClient. - */ -public enum FirstServiceVersion implements ServiceVersion { - /** - * Enum value 2022-06-01-preview. - */ - V2022_06_01_PREVIEW("2022-06-01-preview"), - - /** - * Enum value 2022-12-01-preview. - */ - V2022_12_01_PREVIEW("2022-12-01-preview"); - - private final String version; - - FirstServiceVersion(String version) { - this.version = version; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVersion() { - return this.version; - } - - /** - * Gets the latest service version supported by this client library. - * - * @return The latest {@link FirstServiceVersion}. - */ - public static FirstServiceVersion getLatest() { - return V2022_12_01_PREVIEW; - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionAsyncClient.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionAsyncClient.java deleted file mode 100644 index 5ad7d83597..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionAsyncClient.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.FluxUtil; -import reactor.core.publisher.Mono; -import tsptest.multipleapiversion.implementation.NoApiVersionClientImpl; - -/** - * Initializes a new instance of the asynchronous NoApiVersionClient type. - */ -@ServiceClient(builder = NoApiVersionClientBuilder.class, isAsync = true) -public final class NoApiVersionAsyncClient { - @Generated - private final NoApiVersionClientImpl serviceClient; - - /** - * Initializes an instance of NoApiVersionAsyncClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - NoApiVersionAsyncClient(NoApiVersionClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The action operation. - * - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> actionWithResponse(RequestOptions requestOptions) { - return this.serviceClient.actionWithResponseAsync(requestOptions); - } - - /** - * The action operation. - * - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @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. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono action() { - // Generated convenience method for actionWithResponse - RequestOptions requestOptions = new RequestOptions(); - return actionWithResponse(requestOptions).flatMap(FluxUtil::toMono); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionClient.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionClient.java deleted file mode 100644 index 26e024cdf7..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionClient.java +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import tsptest.multipleapiversion.implementation.NoApiVersionClientImpl; - -/** - * Initializes a new instance of the synchronous NoApiVersionClient type. - */ -@ServiceClient(builder = NoApiVersionClientBuilder.class) -public final class NoApiVersionClient { - @Generated - private final NoApiVersionClientImpl serviceClient; - - /** - * Initializes an instance of NoApiVersionClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - NoApiVersionClient(NoApiVersionClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The action operation. - * - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response actionWithResponse(RequestOptions requestOptions) { - return this.serviceClient.actionWithResponse(requestOptions); - } - - /** - * The action operation. - * - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void action() { - // Generated convenience method for actionWithResponse - RequestOptions requestOptions = new RequestOptions(); - actionWithResponse(requestOptions).getValue(); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionClientBuilder.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionClientBuilder.java deleted file mode 100644 index 19caa95670..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionClientBuilder.java +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.EndpointTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -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.AddHeadersPolicy; -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.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.builder.ClientBuilderUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.serializer.JacksonAdapter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import tsptest.multipleapiversion.implementation.NoApiVersionClientImpl; - -/** - * A builder for creating a new instance of the NoApiVersionClient type. - */ -@ServiceClientBuilder(serviceClients = { NoApiVersionClient.class, NoApiVersionAsyncClient.class }) -public final class NoApiVersionClientBuilder implements HttpTrait, - ConfigurationTrait, EndpointTrait { - @Generated - private static final String SDK_NAME = "name"; - - @Generated - private static final String SDK_VERSION = "version"; - - @Generated - private static final Map PROPERTIES - = CoreUtils.getProperties("tsptest-multipleapiversion.properties"); - - @Generated - private final List pipelinePolicies; - - /** - * Create an instance of the NoApiVersionClientBuilder. - */ - @Generated - public NoApiVersionClientBuilder() { - this.pipelinePolicies = new ArrayList<>(); - } - - /* - * The HTTP client used to send the request. - */ - @Generated - private HttpClient httpClient; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public NoApiVersionClientBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /* - * The HTTP pipeline to send requests through. - */ - @Generated - private HttpPipeline pipeline; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public NoApiVersionClientBuilder pipeline(HttpPipeline pipeline) { - if (this.pipeline != null && pipeline == null) { - LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); - } - this.pipeline = pipeline; - return this; - } - - /* - * The logging configuration for HTTP requests and responses. - */ - @Generated - private HttpLogOptions httpLogOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public NoApiVersionClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { - this.httpLogOptions = httpLogOptions; - return this; - } - - /* - * The client options such as application ID and custom headers to set on a request. - */ - @Generated - private ClientOptions clientOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public NoApiVersionClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - return this; - } - - /* - * The retry options to configure retry policy for failed requests. - */ - @Generated - private RetryOptions retryOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public NoApiVersionClientBuilder retryOptions(RetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public NoApiVersionClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { - Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); - pipelinePolicies.add(customPolicy); - return this; - } - - /* - * The configuration store that is used during construction of the service client. - */ - @Generated - private Configuration configuration; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public NoApiVersionClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /* - * The service endpoint - */ - @Generated - private String endpoint; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public NoApiVersionClientBuilder endpoint(String endpoint) { - this.endpoint = endpoint; - return this; - } - - /* - * Service version - */ - @Generated - private NoApiVersionServiceVersion serviceVersion; - - /** - * Sets Service version. - * - * @param serviceVersion the serviceVersion value. - * @return the NoApiVersionClientBuilder. - */ - @Generated - public NoApiVersionClientBuilder serviceVersion(NoApiVersionServiceVersion serviceVersion) { - this.serviceVersion = serviceVersion; - return this; - } - - /* - * The retry policy that will attempt to retry failed requests, if applicable. - */ - @Generated - private RetryPolicy retryPolicy; - - /** - * Sets The retry policy that will attempt to retry failed requests, if applicable. - * - * @param retryPolicy the retryPolicy value. - * @return the NoApiVersionClientBuilder. - */ - @Generated - public NoApiVersionClientBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - return this; - } - - /** - * Builds an instance of NoApiVersionClientImpl with the provided parameters. - * - * @return an instance of NoApiVersionClientImpl. - */ - @Generated - private NoApiVersionClientImpl buildInnerClient() { - this.validateClient(); - HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - NoApiVersionServiceVersion localServiceVersion - = (serviceVersion != null) ? serviceVersion : NoApiVersionServiceVersion.getLatest(); - NoApiVersionClientImpl client = new NoApiVersionClientImpl(localPipeline, - JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); - return client; - } - - @Generated - private void validateClient() { - // This method is invoked from 'buildInnerClient'/'buildClient' method. - // Developer can customize this method, to validate that the necessary conditions are met for the new client. - Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); - } - - @Generated - private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration - = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; - ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; - List policies = new ArrayList<>(); - String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); - policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); - policies.add(new RequestIdPolicy()); - policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); - if (headers != null) { - policies.add(new AddHeadersPolicy(headers)); - } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); - policies.add(new AddDatePolicy()); - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(localHttpLogOptions)); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); - return httpPipeline; - } - - /** - * Builds an instance of NoApiVersionAsyncClient class. - * - * @return an instance of NoApiVersionAsyncClient. - */ - @Generated - public NoApiVersionAsyncClient buildAsyncClient() { - return new NoApiVersionAsyncClient(buildInnerClient()); - } - - /** - * Builds an instance of NoApiVersionClient class. - * - * @return an instance of NoApiVersionClient. - */ - @Generated - public NoApiVersionClient buildClient() { - return new NoApiVersionClient(buildInnerClient()); - } - - private static final ClientLogger LOGGER = new ClientLogger(NoApiVersionClientBuilder.class); -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionServiceVersion.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionServiceVersion.java deleted file mode 100644 index 9b5366b28b..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/NoApiVersionServiceVersion.java +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.util.ServiceVersion; - -/** - * Service version of NoApiVersionClient. - */ -public enum NoApiVersionServiceVersion implements ServiceVersion { - /** - * Enum value 2022-10-01-preview. - */ - V2022_10_01_PREVIEW("2022-10-01-preview"), - - /** - * Enum value 2022-12-01-preview. - */ - V2022_12_01_PREVIEW("2022-12-01-preview"); - - private final String version; - - NoApiVersionServiceVersion(String version) { - this.version = version; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVersion() { - return this.version; - } - - /** - * Gets the latest service version supported by this client library. - * - * @return The latest {@link NoApiVersionServiceVersion}. - */ - public static NoApiVersionServiceVersion getLatest() { - return V2022_12_01_PREVIEW; - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondAsyncClient.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondAsyncClient.java deleted file mode 100644 index 81b61dcdc1..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondAsyncClient.java +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import com.azure.core.util.FluxUtil; -import reactor.core.publisher.Mono; -import tsptest.multipleapiversion.implementation.SecondClientImpl; -import tsptest.multipleapiversion.models.Resource2; - -/** - * Initializes a new instance of the asynchronous SecondClient type. - */ -@ServiceClient(builder = SecondClientBuilder.class, isAsync = true) -public final class SecondAsyncClient { - @Generated - private final SecondClientImpl serviceClient; - - /** - * Initializes an instance of SecondAsyncClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - SecondAsyncClient(SecondClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * Resource read operation template. - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     name: String (Required)
-     *     type: String (Required)
-     * }
-     * }
-     * 
- * - * @param name The name parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponse(String name, RequestOptions requestOptions) { - return this.serviceClient.getWithResponseAsync(name, requestOptions); - } - - /** - * Resource read operation template. - * - * @param name The name 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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono get(String name) { - // Generated convenience method for getWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getWithResponse(name, requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(Resource2.class)); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondClient.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondClient.java deleted file mode 100644 index de503a9120..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondClient.java +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import tsptest.multipleapiversion.implementation.SecondClientImpl; -import tsptest.multipleapiversion.models.Resource2; - -/** - * Initializes a new instance of the synchronous SecondClient type. - */ -@ServiceClient(builder = SecondClientBuilder.class) -public final class SecondClient { - @Generated - private final SecondClientImpl serviceClient; - - /** - * Initializes an instance of SecondClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - SecondClient(SecondClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * Resource read operation template. - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     name: String (Required)
-     *     type: String (Required)
-     * }
-     * }
-     * 
- * - * @param name The name parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String name, RequestOptions requestOptions) { - return this.serviceClient.getWithResponse(name, requestOptions); - } - - /** - * Resource read operation template. - * - * @param name The name 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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Resource2 get(String name) { - // Generated convenience method for getWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getWithResponse(name, requestOptions).getValue().toObject(Resource2.class); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondClientBuilder.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondClientBuilder.java deleted file mode 100644 index a6bb260afa..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondClientBuilder.java +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.EndpointTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -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.AddHeadersPolicy; -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.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.builder.ClientBuilderUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.serializer.JacksonAdapter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import tsptest.multipleapiversion.implementation.SecondClientImpl; - -/** - * A builder for creating a new instance of the SecondClient type. - */ -@ServiceClientBuilder(serviceClients = { SecondClient.class, SecondAsyncClient.class }) -public final class SecondClientBuilder implements HttpTrait, - ConfigurationTrait, EndpointTrait { - @Generated - private static final String SDK_NAME = "name"; - - @Generated - private static final String SDK_VERSION = "version"; - - @Generated - private static final Map PROPERTIES - = CoreUtils.getProperties("tsptest-multipleapiversion.properties"); - - @Generated - private final List pipelinePolicies; - - /** - * Create an instance of the SecondClientBuilder. - */ - @Generated - public SecondClientBuilder() { - this.pipelinePolicies = new ArrayList<>(); - } - - /* - * The HTTP client used to send the request. - */ - @Generated - private HttpClient httpClient; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public SecondClientBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /* - * The HTTP pipeline to send requests through. - */ - @Generated - private HttpPipeline pipeline; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public SecondClientBuilder pipeline(HttpPipeline pipeline) { - if (this.pipeline != null && pipeline == null) { - LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); - } - this.pipeline = pipeline; - return this; - } - - /* - * The logging configuration for HTTP requests and responses. - */ - @Generated - private HttpLogOptions httpLogOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public SecondClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { - this.httpLogOptions = httpLogOptions; - return this; - } - - /* - * The client options such as application ID and custom headers to set on a request. - */ - @Generated - private ClientOptions clientOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public SecondClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - return this; - } - - /* - * The retry options to configure retry policy for failed requests. - */ - @Generated - private RetryOptions retryOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public SecondClientBuilder retryOptions(RetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public SecondClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { - Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); - pipelinePolicies.add(customPolicy); - return this; - } - - /* - * The configuration store that is used during construction of the service client. - */ - @Generated - private Configuration configuration; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public SecondClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /* - * The service endpoint - */ - @Generated - private String endpoint; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public SecondClientBuilder endpoint(String endpoint) { - this.endpoint = endpoint; - return this; - } - - /* - * Service version - */ - @Generated - private SecondServiceVersion serviceVersion; - - /** - * Sets Service version. - * - * @param serviceVersion the serviceVersion value. - * @return the SecondClientBuilder. - */ - @Generated - public SecondClientBuilder serviceVersion(SecondServiceVersion serviceVersion) { - this.serviceVersion = serviceVersion; - return this; - } - - /* - * The retry policy that will attempt to retry failed requests, if applicable. - */ - @Generated - private RetryPolicy retryPolicy; - - /** - * Sets The retry policy that will attempt to retry failed requests, if applicable. - * - * @param retryPolicy the retryPolicy value. - * @return the SecondClientBuilder. - */ - @Generated - public SecondClientBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - return this; - } - - /** - * Builds an instance of SecondClientImpl with the provided parameters. - * - * @return an instance of SecondClientImpl. - */ - @Generated - private SecondClientImpl buildInnerClient() { - this.validateClient(); - HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - SecondServiceVersion localServiceVersion - = (serviceVersion != null) ? serviceVersion : SecondServiceVersion.getLatest(); - SecondClientImpl client = new SecondClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), - this.endpoint, localServiceVersion); - return client; - } - - @Generated - private void validateClient() { - // This method is invoked from 'buildInnerClient'/'buildClient' method. - // Developer can customize this method, to validate that the necessary conditions are met for the new client. - Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); - } - - @Generated - private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration - = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; - ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; - List policies = new ArrayList<>(); - String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); - policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); - policies.add(new RequestIdPolicy()); - policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); - if (headers != null) { - policies.add(new AddHeadersPolicy(headers)); - } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); - policies.add(new AddDatePolicy()); - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(localHttpLogOptions)); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); - return httpPipeline; - } - - /** - * Builds an instance of SecondAsyncClient class. - * - * @return an instance of SecondAsyncClient. - */ - @Generated - public SecondAsyncClient buildAsyncClient() { - return new SecondAsyncClient(buildInnerClient()); - } - - /** - * Builds an instance of SecondClient class. - * - * @return an instance of SecondClient. - */ - @Generated - public SecondClient buildClient() { - return new SecondClient(buildInnerClient()); - } - - private static final ClientLogger LOGGER = new ClientLogger(SecondClientBuilder.class); -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondServiceVersion.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondServiceVersion.java deleted file mode 100644 index c1a76e489b..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/SecondServiceVersion.java +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.util.ServiceVersion; - -/** - * Service version of SecondClient. - */ -public enum SecondServiceVersion implements ServiceVersion { - /** - * Enum value 2022-10-01-preview. - */ - V2022_10_01_PREVIEW("2022-10-01-preview"), - - /** - * Enum value 2022-12-01-preview. - */ - V2022_12_01_PREVIEW("2022-12-01-preview"); - - private final String version; - - SecondServiceVersion(String version) { - this.version = version; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVersion() { - return this.version; - } - - /** - * Gets the latest service version supported by this client library. - * - * @return The latest {@link SecondServiceVersion}. - */ - public static SecondServiceVersion getLatest() { - return V2022_12_01_PREVIEW; - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/FirstClientImpl.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/FirstClientImpl.java deleted file mode 100644 index 6a6d4d320b..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/FirstClientImpl.java +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion.implementation; - -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; -import com.azure.core.annotation.HeaderParam; -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; -import com.azure.core.annotation.ServiceInterface; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.annotation.UnexpectedResponseExceptionType; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -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.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; -import reactor.core.publisher.Mono; -import tsptest.multipleapiversion.FirstServiceVersion; - -/** - * Initializes a new instance of the FirstClient type. - */ -public final class FirstClientImpl { - /** - * The proxy service used to perform REST calls. - */ - private final FirstClientService service; - - /** - * Service host. - */ - private final String endpoint; - - /** - * Gets Service host. - * - * @return the endpoint value. - */ - public String getEndpoint() { - return this.endpoint; - } - - /** - * Service version. - */ - private final FirstServiceVersion serviceVersion; - - /** - * Gets Service version. - * - * @return the serviceVersion value. - */ - public FirstServiceVersion getServiceVersion() { - return this.serviceVersion; - } - - /** - * 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. - */ - public SerializerAdapter getSerializerAdapter() { - return this.serializerAdapter; - } - - /** - * Initializes an instance of FirstClient client. - * - * @param endpoint Service host. - * @param serviceVersion Service version. - */ - public FirstClientImpl(String endpoint, FirstServiceVersion serviceVersion) { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); - } - - /** - * Initializes an instance of FirstClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Service host. - * @param serviceVersion Service version. - */ - public FirstClientImpl(HttpPipeline httpPipeline, String endpoint, FirstServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); - } - - /** - * Initializes an instance of FirstClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Service host. - * @param serviceVersion Service version. - */ - public FirstClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, - FirstServiceVersion serviceVersion) { - this.httpPipeline = httpPipeline; - this.serializerAdapter = serializerAdapter; - this.endpoint = endpoint; - this.serviceVersion = serviceVersion; - this.service = RestProxy.create(FirstClientService.class, this.httpPipeline, this.getSerializerAdapter()); - } - - /** - * The interface defining all the services for FirstClient to be used by the proxy service to perform REST calls. - */ - @Host("{endpoint}") - @ServiceInterface(name = "FirstClient") - public interface FirstClientService { - @Get("/client1/resources/{name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - - @Get("/client1/resources/{name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - } - - /** - * Resource read operation template. - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     name: String (Required)
-     *     type: String (Required)
-     * }
-     * }
-     * 
- * - * @param name The name parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponseAsync(String name, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(this.getEndpoint(), this.getServiceVersion().getVersion(), - name, accept, requestOptions, context)); - } - - /** - * Resource read operation template. - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     name: String (Required)
-     *     type: String (Required)
-     * }
-     * }
-     * 
- * - * @param name The name parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String name, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, requestOptions, - Context.NONE); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/NoApiVersionClientImpl.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/NoApiVersionClientImpl.java deleted file mode 100644 index a8941e6a22..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/NoApiVersionClientImpl.java +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion.implementation; - -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Host; -import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.Post; -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.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -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.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; -import reactor.core.publisher.Mono; -import tsptest.multipleapiversion.NoApiVersionServiceVersion; - -/** - * Initializes a new instance of the NoApiVersionClient type. - */ -public final class NoApiVersionClientImpl { - /** - * The proxy service used to perform REST calls. - */ - private final NoApiVersionClientService service; - - /** - * Service host. - */ - private final String endpoint; - - /** - * Gets Service host. - * - * @return the endpoint value. - */ - public String getEndpoint() { - return this.endpoint; - } - - /** - * Service version. - */ - private final NoApiVersionServiceVersion serviceVersion; - - /** - * Gets Service version. - * - * @return the serviceVersion value. - */ - public NoApiVersionServiceVersion getServiceVersion() { - return this.serviceVersion; - } - - /** - * 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. - */ - public SerializerAdapter getSerializerAdapter() { - return this.serializerAdapter; - } - - /** - * Initializes an instance of NoApiVersionClient client. - * - * @param endpoint Service host. - * @param serviceVersion Service version. - */ - public NoApiVersionClientImpl(String endpoint, NoApiVersionServiceVersion serviceVersion) { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); - } - - /** - * Initializes an instance of NoApiVersionClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Service host. - * @param serviceVersion Service version. - */ - public NoApiVersionClientImpl(HttpPipeline httpPipeline, String endpoint, - NoApiVersionServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); - } - - /** - * Initializes an instance of NoApiVersionClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Service host. - * @param serviceVersion Service version. - */ - public NoApiVersionClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, - NoApiVersionServiceVersion serviceVersion) { - this.httpPipeline = httpPipeline; - this.serializerAdapter = serializerAdapter; - this.endpoint = endpoint; - this.serviceVersion = serviceVersion; - this.service - = RestProxy.create(NoApiVersionClientService.class, this.httpPipeline, this.getSerializerAdapter()); - } - - /** - * The interface defining all the services for NoApiVersionClient to be used by the proxy service to perform REST - * calls. - */ - @Host("{endpoint}") - @ServiceInterface(name = "NoApiVersionClient") - public interface NoApiVersionClientService { - @Post("/client3") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> action(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, - Context context); - - @Post("/client3") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response actionSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions, - Context context); - } - - /** - * The action operation. - * - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> actionWithResponseAsync(RequestOptions requestOptions) { - return FluxUtil.withContext(context -> service.action(this.getEndpoint(), requestOptions, context)); - } - - /** - * The action operation. - * - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response actionWithResponse(RequestOptions requestOptions) { - return service.actionSync(this.getEndpoint(), requestOptions, Context.NONE); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/SecondClientImpl.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/SecondClientImpl.java deleted file mode 100644 index 2902517faa..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/SecondClientImpl.java +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion.implementation; - -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; -import com.azure.core.annotation.HeaderParam; -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; -import com.azure.core.annotation.ServiceInterface; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.annotation.UnexpectedResponseExceptionType; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -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.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; -import reactor.core.publisher.Mono; -import tsptest.multipleapiversion.SecondServiceVersion; - -/** - * Initializes a new instance of the SecondClient type. - */ -public final class SecondClientImpl { - /** - * The proxy service used to perform REST calls. - */ - private final SecondClientService service; - - /** - * Service host. - */ - private final String endpoint; - - /** - * Gets Service host. - * - * @return the endpoint value. - */ - public String getEndpoint() { - return this.endpoint; - } - - /** - * Service version. - */ - private final SecondServiceVersion serviceVersion; - - /** - * Gets Service version. - * - * @return the serviceVersion value. - */ - public SecondServiceVersion getServiceVersion() { - return this.serviceVersion; - } - - /** - * 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. - */ - public SerializerAdapter getSerializerAdapter() { - return this.serializerAdapter; - } - - /** - * Initializes an instance of SecondClient client. - * - * @param endpoint Service host. - * @param serviceVersion Service version. - */ - public SecondClientImpl(String endpoint, SecondServiceVersion serviceVersion) { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); - } - - /** - * Initializes an instance of SecondClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Service host. - * @param serviceVersion Service version. - */ - public SecondClientImpl(HttpPipeline httpPipeline, String endpoint, SecondServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); - } - - /** - * Initializes an instance of SecondClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Service host. - * @param serviceVersion Service version. - */ - public SecondClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, - SecondServiceVersion serviceVersion) { - this.httpPipeline = httpPipeline; - this.serializerAdapter = serializerAdapter; - this.endpoint = endpoint; - this.serviceVersion = serviceVersion; - this.service = RestProxy.create(SecondClientService.class, this.httpPipeline, this.getSerializerAdapter()); - } - - /** - * The interface defining all the services for SecondClient to be used by the proxy service to perform REST calls. - */ - @Host("{endpoint}") - @ServiceInterface(name = "SecondClient") - public interface SecondClientService { - @Get("/client2/resources/{name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - - @Get("/client2/resources/{name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HostParam("endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @PathParam("name") String name, - @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - } - - /** - * Resource read operation template. - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     name: String (Required)
-     *     type: String (Required)
-     * }
-     * }
-     * 
- * - * @param name The name parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponseAsync(String name, RequestOptions requestOptions) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.get(this.getEndpoint(), this.getServiceVersion().getVersion(), - name, accept, requestOptions, context)); - } - - /** - * Resource read operation template. - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     name: String (Required)
-     *     type: String (Required)
-     * }
-     * }
-     * 
- * - * @param name The name parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String name, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, requestOptions, - Context.NONE); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/package-info.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/package-info.java deleted file mode 100644 index ec238a77b2..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/implementation/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// 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 MultipleApiVersion. - * - */ -package tsptest.multipleapiversion.implementation; diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/models/Resource.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/models/Resource.java deleted file mode 100644 index 831c598018..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/models/Resource.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion.models; - -import com.azure.core.annotation.Generated; -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; - -/** - * The Resource model. - */ -@Immutable -public final class Resource implements JsonSerializable { - /* - * The id property. - */ - @Generated - private String id; - - /* - * The name property. - */ - @Generated - private String name; - - /* - * The type property. - */ - @Generated - private final String type; - - /** - * Creates an instance of Resource class. - * - * @param type the type value to set. - */ - @Generated - private Resource(String type) { - this.type = type; - } - - /** - * Get the id property: The id property. - * - * @return the id value. - */ - @Generated - public String getId() { - return this.id; - } - - /** - * Get the name property: The name property. - * - * @return the name value. - */ - @Generated - public String getName() { - return this.name; - } - - /** - * Get the type property: The type property. - * - * @return the type value. - */ - @Generated - public String getType() { - return this.type; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Resource from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Resource 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 Resource. - */ - @Generated - public static Resource fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - String name = null; - String type = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("name".equals(fieldName)) { - name = reader.getString(); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - Resource deserializedResource = new Resource(type); - deserializedResource.id = id; - deserializedResource.name = name; - - return deserializedResource; - }); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/models/Resource2.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/models/Resource2.java deleted file mode 100644 index 99b5658d4f..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/models/Resource2.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion.models; - -import com.azure.core.annotation.Generated; -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; - -/** - * The Resource2 model. - */ -@Immutable -public final class Resource2 implements JsonSerializable { - /* - * The id property. - */ - @Generated - private String id; - - /* - * The name property. - */ - @Generated - private String name; - - /* - * The type property. - */ - @Generated - private final String type; - - /** - * Creates an instance of Resource2 class. - * - * @param type the type value to set. - */ - @Generated - private Resource2(String type) { - this.type = type; - } - - /** - * Get the id property: The id property. - * - * @return the id value. - */ - @Generated - public String getId() { - return this.id; - } - - /** - * Get the name property: The name property. - * - * @return the name value. - */ - @Generated - public String getName() { - return this.name; - } - - /** - * Get the type property: The type property. - * - * @return the type value. - */ - @Generated - public String getType() { - return this.type; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Resource2 from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Resource2 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 Resource2. - */ - @Generated - public static Resource2 fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - String name = null; - String type = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("name".equals(fieldName)) { - name = reader.getString(); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - Resource2 deserializedResource2 = new Resource2(type); - deserializedResource2.id = id; - deserializedResource2.name = name; - - return deserializedResource2; - }); - } -} diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/models/package-info.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/models/package-info.java deleted file mode 100644 index 61f99c6514..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/models/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// 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 MultipleApiVersion. - * - */ -package tsptest.multipleapiversion.models; diff --git a/typespec-tests/src/main/java/tsptest/multipleapiversion/package-info.java b/typespec-tests/src/main/java/tsptest/multipleapiversion/package-info.java deleted file mode 100644 index 72648ba3f3..0000000000 --- a/typespec-tests/src/main/java/tsptest/multipleapiversion/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// 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 MultipleApiVersion. - * - */ -package tsptest.multipleapiversion; diff --git a/typespec-tests/src/main/java/tsptest/server/ContosoServiceVersion.java b/typespec-tests/src/main/java/tsptest/server/ContosoServiceVersion.java deleted file mode 100644 index 8e4ca4c468..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/ContosoServiceVersion.java +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server; - -import com.azure.core.util.ServiceVersion; - -/** - * Service version of ContosoClient. - */ -public enum ContosoServiceVersion implements ServiceVersion { - /** - * Enum value v1. - */ - V1("v1"); - - private final String version; - - ContosoServiceVersion(String version) { - this.version = version; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVersion() { - return this.version; - } - - /** - * Gets the latest service version supported by this client library. - * - * @return The latest {@link ContosoServiceVersion}. - */ - public static ContosoServiceVersion getLatest() { - return V1; - } -} diff --git a/typespec-tests/src/main/java/tsptest/server/HttpbinAsyncClient.java b/typespec-tests/src/main/java/tsptest/server/HttpbinAsyncClient.java deleted file mode 100644 index 18fd7b2663..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/HttpbinAsyncClient.java +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.FluxUtil; -import reactor.core.publisher.Mono; -import tsptest.server.implementation.HttpbinClientImpl; - -/** - * Initializes a new instance of the asynchronous HttpbinClient type. - */ -@ServiceClient(builder = HttpbinClientBuilder.class, isAsync = true) -public final class HttpbinAsyncClient { - @Generated - private final HttpbinClientImpl serviceClient; - - /** - * Initializes an instance of HttpbinAsyncClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - HttpbinAsyncClient(HttpbinClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The status operation. - * - * @param code The code parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> statusWithResponse(int code, RequestOptions requestOptions) { - return this.serviceClient.statusWithResponseAsync(code, requestOptions); - } - - /** - * The status operation. - * - * @param code The code 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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @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. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono status(int code) { - // Generated convenience method for statusWithResponse - RequestOptions requestOptions = new RequestOptions(); - return statusWithResponse(code, requestOptions).flatMap(FluxUtil::toMono); - } -} diff --git a/typespec-tests/src/main/java/tsptest/server/HttpbinClient.java b/typespec-tests/src/main/java/tsptest/server/HttpbinClient.java deleted file mode 100644 index 6aecfadf0a..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/HttpbinClient.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import tsptest.server.implementation.HttpbinClientImpl; - -/** - * Initializes a new instance of the synchronous HttpbinClient type. - */ -@ServiceClient(builder = HttpbinClientBuilder.class) -public final class HttpbinClient { - @Generated - private final HttpbinClientImpl serviceClient; - - /** - * Initializes an instance of HttpbinClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - HttpbinClient(HttpbinClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The status operation. - * - * @param code The code parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response statusWithResponse(int code, RequestOptions requestOptions) { - return this.serviceClient.statusWithResponse(code, requestOptions); - } - - /** - * The status operation. - * - * @param code The code 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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void status(int code) { - // Generated convenience method for statusWithResponse - RequestOptions requestOptions = new RequestOptions(); - statusWithResponse(code, requestOptions).getValue(); - } -} diff --git a/typespec-tests/src/main/java/tsptest/server/HttpbinClientBuilder.java b/typespec-tests/src/main/java/tsptest/server/HttpbinClientBuilder.java deleted file mode 100644 index efed384dca..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/HttpbinClientBuilder.java +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -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.AddHeadersPolicy; -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.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.builder.ClientBuilderUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.serializer.JacksonAdapter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import tsptest.server.implementation.HttpbinClientImpl; - -/** - * A builder for creating a new instance of the HttpbinClient type. - */ -@ServiceClientBuilder(serviceClients = { HttpbinClient.class, HttpbinAsyncClient.class }) -public final class HttpbinClientBuilder - implements HttpTrait, ConfigurationTrait { - @Generated - private static final String SDK_NAME = "name"; - - @Generated - private static final String SDK_VERSION = "version"; - - @Generated - private static final Map PROPERTIES = CoreUtils.getProperties("tsptest-server.properties"); - - @Generated - private final List pipelinePolicies; - - /** - * Create an instance of the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder() { - this.pipelinePolicies = new ArrayList<>(); - } - - /* - * The HTTP client used to send the request. - */ - @Generated - private HttpClient httpClient; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /* - * The HTTP pipeline to send requests through. - */ - @Generated - private HttpPipeline pipeline; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder pipeline(HttpPipeline pipeline) { - if (this.pipeline != null && pipeline == null) { - LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); - } - this.pipeline = pipeline; - return this; - } - - /* - * The logging configuration for HTTP requests and responses. - */ - @Generated - private HttpLogOptions httpLogOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { - this.httpLogOptions = httpLogOptions; - return this; - } - - /* - * The client options such as application ID and custom headers to set on a request. - */ - @Generated - private ClientOptions clientOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - return this; - } - - /* - * The retry options to configure retry policy for failed requests. - */ - @Generated - private RetryOptions retryOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder retryOptions(RetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { - Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); - pipelinePolicies.add(customPolicy); - return this; - } - - /* - * The configuration store that is used during construction of the service client. - */ - @Generated - private Configuration configuration; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /* - * second-level domain, use httpbin - */ - @Generated - private String domain; - - /** - * Sets second-level domain, use httpbin. - * - * @param domain the domain value. - * @return the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder domain(String domain) { - this.domain = domain; - return this; - } - - /* - * top-level domain, use org - */ - @Generated - private String tld; - - /** - * Sets top-level domain, use org. - * - * @param tld the tld value. - * @return the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder tld(String tld) { - this.tld = tld; - return this; - } - - /* - * relative path segment, can be empty - */ - @Generated - private String relativePath; - - /** - * Sets relative path segment, can be empty. - * - * @param relativePath the relativePath value. - * @return the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder relativePath(String relativePath) { - this.relativePath = relativePath; - return this; - } - - /* - * The retry policy that will attempt to retry failed requests, if applicable. - */ - @Generated - private RetryPolicy retryPolicy; - - /** - * Sets The retry policy that will attempt to retry failed requests, if applicable. - * - * @param retryPolicy the retryPolicy value. - * @return the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - return this; - } - - /** - * Builds an instance of HttpbinClientImpl with the provided parameters. - * - * @return an instance of HttpbinClientImpl. - */ - @Generated - private HttpbinClientImpl buildInnerClient() { - this.validateClient(); - HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - String localDomain = (domain != null) ? domain : "httpbin"; - String localTld = (tld != null) ? tld : "org"; - HttpbinClientImpl client = new HttpbinClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), - localDomain, localTld, this.relativePath); - return client; - } - - @Generated - private void validateClient() { - // This method is invoked from 'buildInnerClient'/'buildClient' method. - // Developer can customize this method, to validate that the necessary conditions are met for the new client. - Objects.requireNonNull(relativePath, "'relativePath' cannot be null."); - } - - @Generated - private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration - = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; - ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; - List policies = new ArrayList<>(); - String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); - policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); - policies.add(new RequestIdPolicy()); - policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); - if (headers != null) { - policies.add(new AddHeadersPolicy(headers)); - } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); - policies.add(new AddDatePolicy()); - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(localHttpLogOptions)); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); - return httpPipeline; - } - - /** - * Builds an instance of HttpbinAsyncClient class. - * - * @return an instance of HttpbinAsyncClient. - */ - @Generated - public HttpbinAsyncClient buildAsyncClient() { - return new HttpbinAsyncClient(buildInnerClient()); - } - - /** - * Builds an instance of HttpbinClient class. - * - * @return an instance of HttpbinClient. - */ - @Generated - public HttpbinClient buildClient() { - return new HttpbinClient(buildInnerClient()); - } - - private static final ClientLogger LOGGER = new ClientLogger(HttpbinClientBuilder.class); -} diff --git a/typespec-tests/src/main/java/tsptest/server/contoso/models/APIVersions.java b/typespec-tests/src/main/java/tsptest/server/contoso/models/APIVersions.java deleted file mode 100644 index bbd8442bca..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/contoso/models/APIVersions.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.contoso.models; - -/** - * Defines values for APIVersions. - */ -public enum APIVersions { - /** - * Enum value v1. - */ - V1("v1"); - - /** - * The actual serialized value for a APIVersions instance. - */ - private final String value; - - APIVersions(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a APIVersions instance. - * - * @param value the serialized value to parse. - * @return the parsed APIVersions object, or null if unable to parse. - */ - public static APIVersions fromString(String value) { - if (value == null) { - return null; - } - APIVersions[] items = APIVersions.values(); - for (APIVersions item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/typespec-tests/src/main/java/tsptest/server/contoso/models/package-info.java b/typespec-tests/src/main/java/tsptest/server/contoso/models/package-info.java deleted file mode 100644 index 94d43028dd..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/contoso/models/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// 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 Server. - * - */ -package tsptest.server.contoso.models; diff --git a/typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoAsyncClient.java b/typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoAsyncClient.java deleted file mode 100644 index 58149c987b..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoAsyncClient.java +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.contoso.sub; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.FluxUtil; -import reactor.core.publisher.Mono; -import tsptest.server.implementation.ContosoClientImpl; - -/** - * Initializes a new instance of the asynchronous ContosoClient type. - */ -@ServiceClient(builder = ContosoClientBuilder.class, isAsync = true) -public final class ContosoAsyncClient { - @Generated - private final ContosoClientImpl serviceClient; - - /** - * Initializes an instance of ContosoAsyncClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - ContosoAsyncClient(ContosoClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The get operation. - * - * @param group The group parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponse(String group, RequestOptions requestOptions) { - return this.serviceClient.getWithResponseAsync(group, requestOptions); - } - - /** - * The get operation. - * - * @param group The group 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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @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. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono get(String group) { - // Generated convenience method for getWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getWithResponse(group, requestOptions).flatMap(FluxUtil::toMono); - } -} diff --git a/typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoClient.java b/typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoClient.java deleted file mode 100644 index aa786d3070..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoClient.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.contoso.sub; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import tsptest.server.implementation.ContosoClientImpl; - -/** - * Initializes a new instance of the synchronous ContosoClient type. - */ -@ServiceClient(builder = ContosoClientBuilder.class) -public final class ContosoClient { - @Generated - private final ContosoClientImpl serviceClient; - - /** - * Initializes an instance of ContosoClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - ContosoClient(ContosoClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The get operation. - * - * @param group The group parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String group, RequestOptions requestOptions) { - return this.serviceClient.getWithResponse(group, requestOptions); - } - - /** - * The get operation. - * - * @param group The group 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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void get(String group) { - // Generated convenience method for getWithResponse - RequestOptions requestOptions = new RequestOptions(); - getWithResponse(group, requestOptions).getValue(); - } -} diff --git a/typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoClientBuilder.java b/typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoClientBuilder.java deleted file mode 100644 index 3fed7c357c..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/contoso/sub/ContosoClientBuilder.java +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.contoso.sub; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.EndpointTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -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.AddHeadersPolicy; -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.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.builder.ClientBuilderUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.serializer.JacksonAdapter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import tsptest.server.ContosoServiceVersion; -import tsptest.server.contoso.models.APIVersions; -import tsptest.server.implementation.ContosoClientImpl; - -/** - * A builder for creating a new instance of the ContosoClient type. - */ -@ServiceClientBuilder(serviceClients = { ContosoClient.class, ContosoAsyncClient.class }) -public final class ContosoClientBuilder implements HttpTrait, - ConfigurationTrait, EndpointTrait { - @Generated - private static final String SDK_NAME = "name"; - - @Generated - private static final String SDK_VERSION = "version"; - - @Generated - private static final Map PROPERTIES = CoreUtils.getProperties("tsptest-server.properties"); - - @Generated - private final List pipelinePolicies; - - /** - * Create an instance of the ContosoClientBuilder. - */ - @Generated - public ContosoClientBuilder() { - this.pipelinePolicies = new ArrayList<>(); - } - - /* - * The HTTP client used to send the request. - */ - @Generated - private HttpClient httpClient; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /* - * The HTTP pipeline to send requests through. - */ - @Generated - private HttpPipeline pipeline; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder pipeline(HttpPipeline pipeline) { - if (this.pipeline != null && pipeline == null) { - LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); - } - this.pipeline = pipeline; - return this; - } - - /* - * The logging configuration for HTTP requests and responses. - */ - @Generated - private HttpLogOptions httpLogOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { - this.httpLogOptions = httpLogOptions; - return this; - } - - /* - * The client options such as application ID and custom headers to set on a request. - */ - @Generated - private ClientOptions clientOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - return this; - } - - /* - * The retry options to configure retry policy for failed requests. - */ - @Generated - private RetryOptions retryOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder retryOptions(RetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { - Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); - pipelinePolicies.add(customPolicy); - return this; - } - - /* - * The configuration store that is used during construction of the service client. - */ - @Generated - private Configuration configuration; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /* - * The service endpoint - */ - @Generated - private String endpoint; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder endpoint(String endpoint) { - this.endpoint = endpoint; - return this; - } - - /* - * Api Version - */ - @Generated - private APIVersions apiVersion; - - /** - * Sets Api Version. - * - * @param apiVersion the apiVersion value. - * @return the ContosoClientBuilder. - */ - @Generated - public ContosoClientBuilder apiVersion(APIVersions apiVersion) { - this.apiVersion = apiVersion; - return this; - } - - /* - * Service version - */ - @Generated - private ContosoServiceVersion serviceVersion; - - /** - * Sets Service version. - * - * @param serviceVersion the serviceVersion value. - * @return the ContosoClientBuilder. - */ - @Generated - public ContosoClientBuilder serviceVersion(ContosoServiceVersion serviceVersion) { - this.serviceVersion = serviceVersion; - return this; - } - - /* - * The retry policy that will attempt to retry failed requests, if applicable. - */ - @Generated - private RetryPolicy retryPolicy; - - /** - * Sets The retry policy that will attempt to retry failed requests, if applicable. - * - * @param retryPolicy the retryPolicy value. - * @return the ContosoClientBuilder. - */ - @Generated - public ContosoClientBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - return this; - } - - /** - * Builds an instance of ContosoClientImpl with the provided parameters. - * - * @return an instance of ContosoClientImpl. - */ - @Generated - private ContosoClientImpl buildInnerClient() { - this.validateClient(); - HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - ContosoServiceVersion localServiceVersion - = (serviceVersion != null) ? serviceVersion : ContosoServiceVersion.getLatest(); - ContosoClientImpl client = new ContosoClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), - this.endpoint, this.apiVersion, localServiceVersion); - return client; - } - - @Generated - private void validateClient() { - // This method is invoked from 'buildInnerClient'/'buildClient' method. - // Developer can customize this method, to validate that the necessary conditions are met for the new client. - Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); - Objects.requireNonNull(apiVersion, "'apiVersion' cannot be null."); - } - - @Generated - private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration - = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; - ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; - List policies = new ArrayList<>(); - String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); - policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); - policies.add(new RequestIdPolicy()); - policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); - if (headers != null) { - policies.add(new AddHeadersPolicy(headers)); - } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); - policies.add(new AddDatePolicy()); - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(localHttpLogOptions)); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); - return httpPipeline; - } - - /** - * Builds an instance of ContosoAsyncClient class. - * - * @return an instance of ContosoAsyncClient. - */ - @Generated - public ContosoAsyncClient buildAsyncClient() { - return new ContosoAsyncClient(buildInnerClient()); - } - - /** - * Builds an instance of ContosoClient class. - * - * @return an instance of ContosoClient. - */ - @Generated - public ContosoClient buildClient() { - return new ContosoClient(buildInnerClient()); - } - - private static final ClientLogger LOGGER = new ClientLogger(ContosoClientBuilder.class); -} diff --git a/typespec-tests/src/main/java/tsptest/server/contoso/sub/package-info.java b/typespec-tests/src/main/java/tsptest/server/contoso/sub/package-info.java deleted file mode 100644 index 584771a66f..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/contoso/sub/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// 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 ContosoClient. - * - */ -package tsptest.server.contoso.sub; diff --git a/typespec-tests/src/main/java/tsptest/server/implementation/ContosoClientImpl.java b/typespec-tests/src/main/java/tsptest/server/implementation/ContosoClientImpl.java deleted file mode 100644 index 9048cb1193..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/implementation/ContosoClientImpl.java +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.implementation; - -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; -import com.azure.core.annotation.Host; -import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.PathParam; -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.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -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.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; -import reactor.core.publisher.Mono; -import tsptest.server.ContosoServiceVersion; -import tsptest.server.contoso.models.APIVersions; - -/** - * Initializes a new instance of the ContosoClient type. - */ -public final class ContosoClientImpl { - /** - * The proxy service used to perform REST calls. - */ - private final ContosoClientService service; - - /** - * Service endpoint. - */ - private final String endpoint; - - /** - * Gets Service endpoint. - * - * @return the endpoint value. - */ - public String getEndpoint() { - return this.endpoint; - } - - /** - * Api Version. - */ - private final APIVersions apiVersion; - - /** - * Gets Api Version. - * - * @return the apiVersion value. - */ - public APIVersions getApiVersion() { - return this.apiVersion; - } - - /** - * Service version. - */ - private final ContosoServiceVersion serviceVersion; - - /** - * Gets Service version. - * - * @return the serviceVersion value. - */ - public ContosoServiceVersion getServiceVersion() { - return this.serviceVersion; - } - - /** - * 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. - */ - public SerializerAdapter getSerializerAdapter() { - return this.serializerAdapter; - } - - /** - * Initializes an instance of ContosoClient client. - * - * @param endpoint Service endpoint. - * @param apiVersion Api Version. - * @param serviceVersion Service version. - */ - public ContosoClientImpl(String endpoint, APIVersions apiVersion, ContosoServiceVersion serviceVersion) { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), endpoint, apiVersion, serviceVersion); - } - - /** - * Initializes an instance of ContosoClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Service endpoint. - * @param apiVersion Api Version. - * @param serviceVersion Service version. - */ - public ContosoClientImpl(HttpPipeline httpPipeline, String endpoint, APIVersions apiVersion, - ContosoServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, apiVersion, serviceVersion); - } - - /** - * Initializes an instance of ContosoClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Service endpoint. - * @param apiVersion Api Version. - * @param serviceVersion Service version. - */ - public ContosoClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, - APIVersions apiVersion, ContosoServiceVersion serviceVersion) { - this.httpPipeline = httpPipeline; - this.serializerAdapter = serializerAdapter; - this.endpoint = endpoint; - this.apiVersion = apiVersion; - this.serviceVersion = serviceVersion; - this.service = RestProxy.create(ContosoClientService.class, this.httpPipeline, this.getSerializerAdapter()); - } - - /** - * The interface defining all the services for ContosoClient to be used by the proxy service to perform REST calls. - */ - @Host("{Endpoint}/contoso/{ApiVersion}") - @ServiceInterface(name = "ContosoClient") - public interface ContosoClientService { - @Get("/contoso/{group}") - @ExpectedResponses({ 200, 204 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") APIVersions apiVersion, @PathParam(value = "group", encoded = true) String group, - RequestOptions requestOptions, Context context); - - @Get("/contoso/{group}") - @ExpectedResponses({ 200, 204 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") APIVersions apiVersion, - @PathParam(value = "group", encoded = true) String group, RequestOptions requestOptions, Context context); - } - - /** - * The get operation. - * - * @param group The group parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponseAsync(String group, RequestOptions requestOptions) { - return FluxUtil.withContext( - context -> service.get(this.getEndpoint(), this.getApiVersion(), group, requestOptions, context)); - } - - /** - * The get operation. - * - * @param group The group parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String group, RequestOptions requestOptions) { - return service.getSync(this.getEndpoint(), this.getApiVersion(), group, requestOptions, Context.NONE); - } -} diff --git a/typespec-tests/src/main/java/tsptest/server/implementation/HttpbinClientImpl.java b/typespec-tests/src/main/java/tsptest/server/implementation/HttpbinClientImpl.java deleted file mode 100644 index e183ec6ac5..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/implementation/HttpbinClientImpl.java +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.implementation; - -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; -import com.azure.core.annotation.Host; -import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.PathParam; -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.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -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.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; -import reactor.core.publisher.Mono; - -/** - * Initializes a new instance of the HttpbinClient type. - */ -public final class HttpbinClientImpl { - /** - * The proxy service used to perform REST calls. - */ - private final HttpbinClientService service; - - /** - * second-level domain, use httpbin. - */ - private final String domain; - - /** - * Gets second-level domain, use httpbin. - * - * @return the domain value. - */ - public String getDomain() { - return this.domain; - } - - /** - * top-level domain, use org. - */ - private final String tld; - - /** - * Gets top-level domain, use org. - * - * @return the tld value. - */ - public String getTld() { - return this.tld; - } - - /** - * relative path segment, can be empty. - */ - private final String relativePath; - - /** - * Gets relative path segment, can be empty. - * - * @return the relativePath value. - */ - public String getRelativePath() { - return this.relativePath; - } - - /** - * 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. - */ - public SerializerAdapter getSerializerAdapter() { - return this.serializerAdapter; - } - - /** - * Initializes an instance of HttpbinClient client. - * - * @param domain second-level domain, use httpbin. - * @param tld top-level domain, use org. - * @param relativePath relative path segment, can be empty. - */ - public HttpbinClientImpl(String domain, String tld, String relativePath) { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), domain, tld, relativePath); - } - - /** - * Initializes an instance of HttpbinClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param domain second-level domain, use httpbin. - * @param tld top-level domain, use org. - * @param relativePath relative path segment, can be empty. - */ - public HttpbinClientImpl(HttpPipeline httpPipeline, String domain, String tld, String relativePath) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), domain, tld, relativePath); - } - - /** - * Initializes an instance of HttpbinClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param serializerAdapter The serializer to serialize an object into a string. - * @param domain second-level domain, use httpbin. - * @param tld top-level domain, use org. - * @param relativePath relative path segment, can be empty. - */ - public HttpbinClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String domain, String tld, - String relativePath) { - this.httpPipeline = httpPipeline; - this.serializerAdapter = serializerAdapter; - this.domain = domain; - this.tld = tld; - this.relativePath = relativePath; - this.service = RestProxy.create(HttpbinClientService.class, this.httpPipeline, this.getSerializerAdapter()); - } - - /** - * The interface defining all the services for HttpbinClient to be used by the proxy service to perform REST calls. - */ - @Host("https://{domain}.{tld}{relative-path}") - @ServiceInterface(name = "HttpbinClient") - public interface HttpbinClientService { - @Get("/status/{code}") - @ExpectedResponses({ 200, 204 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> status(@HostParam("domain") String domain, @HostParam("tld") String tld, - @HostParam("relative-path") String relativePath, @PathParam("code") int code, RequestOptions requestOptions, - Context context); - - @Get("/status/{code}") - @ExpectedResponses({ 200, 204 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response statusSync(@HostParam("domain") String domain, @HostParam("tld") String tld, - @HostParam("relative-path") String relativePath, @PathParam("code") int code, RequestOptions requestOptions, - Context context); - } - - /** - * The status operation. - * - * @param code The code parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> statusWithResponseAsync(int code, RequestOptions requestOptions) { - return FluxUtil.withContext(context -> service.status(this.getDomain(), this.getTld(), this.getRelativePath(), - code, requestOptions, context)); - } - - /** - * The status operation. - * - * @param code The code parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @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. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response statusWithResponse(int code, RequestOptions requestOptions) { - return service.statusSync(this.getDomain(), this.getTld(), this.getRelativePath(), code, requestOptions, - Context.NONE); - } -} diff --git a/typespec-tests/src/main/java/tsptest/server/implementation/package-info.java b/typespec-tests/src/main/java/tsptest/server/implementation/package-info.java deleted file mode 100644 index eb40ad2258..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/implementation/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// 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 Server. - * - */ -package tsptest.server.implementation; diff --git a/typespec-tests/src/main/java/tsptest/server/package-info.java b/typespec-tests/src/main/java/tsptest/server/package-info.java deleted file mode 100644 index 5e0b067c32..0000000000 --- a/typespec-tests/src/main/java/tsptest/server/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// 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 Server. - * - */ -package tsptest.server; diff --git a/typespec-tests/src/main/resources/tsptest-multipleapiversion.properties b/typespec-tests/src/main/resources/tsptest-multipleapiversion.properties deleted file mode 100644 index ca812989b4..0000000000 --- a/typespec-tests/src/main/resources/tsptest-multipleapiversion.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/typespec-tests/src/main/resources/tsptest-server.properties b/typespec-tests/src/main/resources/tsptest-server.properties deleted file mode 100644 index ca812989b4..0000000000 --- a/typespec-tests/src/main/resources/tsptest-server.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiservice/ArmMultipleServiceTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiservice/ArmMultipleServiceTests.java new file mode 100644 index 0000000000..690005694e --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiservice/ArmMultipleServiceTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azure.resourcemanager.multiservice; + +import azure.resourcemanager.multiservice.combined.CombinedManager; +import azure.resourcemanager.multiservice.combined.models.DiskProperties; +import azure.resourcemanager.multiservice.combined.models.VirtualMachineProperties; +import com.azure.core.management.Region; +import org.junit.jupiter.api.Test; +import org.utils.ArmUtils; + +public final class ArmMultipleServiceTests { + + private final CombinedManager manager + = CombinedManager.authenticate(ArmUtils.createTestHttpPipeline(), ArmUtils.getAzureProfile()); + + private static final String RESOURCE_GROUP_NAME = "test-rg"; + private static final Region REGION = Region.US_EAST; + + @Test + public void testCombinedClient() { + manager.disks() + .define("disk1") + .withRegion(REGION) + .withExistingResourceGroup(RESOURCE_GROUP_NAME) + .withProperties(new DiskProperties()) + .create(); + manager.disks().getByResourceGroup(RESOURCE_GROUP_NAME, "disk1"); + + manager.virtualMachines() + .define("vm1") + .withRegion(REGION) + .withExistingResourceGroup(RESOURCE_GROUP_NAME) + .withProperties(new VirtualMachineProperties()) + .create(); + manager.virtualMachines().getByResourceGroup(RESOURCE_GROUP_NAME, "vm1"); + } +} diff --git a/typespec-tests/src/test/java/service/multiservice/MultipleServiceTests.java b/typespec-tests/src/test/java/service/multiservice/MultipleServiceTests.java new file mode 100644 index 0000000000..f80736805a --- /dev/null +++ b/typespec-tests/src/test/java/service/multiservice/MultipleServiceTests.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package service.multiservice; + +import org.junit.jupiter.api.Test; +import service.multiservice.combined.BarClient; +import service.multiservice.combined.CombinedBuilder; +import service.multiservice.combined.FooClient; + +public final class MultipleServiceTests { + + private final FooClient fooClient = new CombinedBuilder().buildFooClient(); + private final BarClient barClient = new CombinedBuilder().buildBarClient(); + + @Test + public void testCombinedClient() { + fooClient.test(); + barClient.test(); + } +} diff --git a/typespec-tests/src/test/java/tsptest/multipleapiversion/generated/FirstClientTestBase.java b/typespec-tests/src/test/java/tsptest/multipleapiversion/generated/FirstClientTestBase.java deleted file mode 100644 index f95717e79a..0000000000 --- a/typespec-tests/src/test/java/tsptest/multipleapiversion/generated/FirstClientTestBase.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion.generated; - -// The Java test files under 'generated' package are generated for your reference. -// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. -// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. - -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.test.TestMode; -import com.azure.core.test.TestProxyTestBase; -import com.azure.core.util.Configuration; -import tsptest.multipleapiversion.FirstClient; -import tsptest.multipleapiversion.FirstClientBuilder; -import tsptest.multipleapiversion.NoApiVersionClient; -import tsptest.multipleapiversion.NoApiVersionClientBuilder; -import tsptest.multipleapiversion.SecondClient; -import tsptest.multipleapiversion.SecondClientBuilder; - -class FirstClientTestBase extends TestProxyTestBase { - protected FirstClient firstClient; - - protected SecondClient secondClient; - - protected NoApiVersionClient noApiVersionClient; - - @Override - protected void beforeTest() { - FirstClientBuilder firstClientbuilder - = new FirstClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - firstClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - firstClient = firstClientbuilder.buildClient(); - - SecondClientBuilder secondClientbuilder - = new SecondClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - secondClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - secondClient = secondClientbuilder.buildClient(); - - NoApiVersionClientBuilder noApiVersionClientbuilder = new NoApiVersionClientBuilder() - .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - noApiVersionClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - noApiVersionClient = noApiVersionClientbuilder.buildClient(); - - } -} diff --git a/typespec-tests/src/test/java/tsptest/server/ServerTests.java b/typespec-tests/src/test/java/tsptest/server/ServerTests.java deleted file mode 100644 index 4db130449b..0000000000 --- a/typespec-tests/src/test/java/tsptest/server/ServerTests.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package tsptest.server; - -import com.azure.core.http.rest.RequestOptions; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class ServerTests { - - @Disabled("test calls httpbin.org") - @Test - public void serverTests() { - HttpbinClient client = new HttpbinClientBuilder().domain("httpbin").tld("org").buildClient(); - Assertions.assertEquals(204, client.statusWithResponse(204, new RequestOptions()).getStatusCode()); - } -} diff --git a/typespec-tests/src/test/java/tsptest/server/generated/HttpbinClientTestBase.java b/typespec-tests/src/test/java/tsptest/server/generated/HttpbinClientTestBase.java deleted file mode 100644 index f51d39cc4c..0000000000 --- a/typespec-tests/src/test/java/tsptest/server/generated/HttpbinClientTestBase.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.generated; - -// The Java test files under 'generated' package are generated for your reference. -// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. -// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. - -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.test.TestMode; -import com.azure.core.test.TestProxyTestBase; -import com.azure.core.util.Configuration; -import tsptest.server.HttpbinClient; -import tsptest.server.HttpbinClientBuilder; -import tsptest.server.contoso.models.APIVersions; -import tsptest.server.contoso.sub.ContosoClient; -import tsptest.server.contoso.sub.ContosoClientBuilder; - -class HttpbinClientTestBase extends TestProxyTestBase { - protected HttpbinClient httpbinClient; - - protected ContosoClient contosoClient; - - @Override - protected void beforeTest() { - HttpbinClientBuilder httpbinClientbuilder - = new HttpbinClientBuilder().domain(Configuration.getGlobalConfiguration().get("DOMAIN", "httpbin")) - .tld(Configuration.getGlobalConfiguration().get("TLD", "org")) - .relativePath(Configuration.getGlobalConfiguration().get("RELATIVEPATH", "relativepath")) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - httpbinClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - httpbinClient = httpbinClientbuilder.buildClient(); - - ContosoClientBuilder contosoClientbuilder = new ContosoClientBuilder() - .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .apiVersion(APIVersions.fromString(Configuration.getGlobalConfiguration().get("APIVERSION", "apiversion"))) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - contosoClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - contosoClient = contosoClientbuilder.buildClient(); - - } -} diff --git a/typespec-tests/tsp/multiple-apiversion.tsp b/typespec-tests/tsp/multiple-apiversion.tsp deleted file mode 100644 index e6c06188d0..0000000000 --- a/typespec-tests/tsp/multiple-apiversion.tsp +++ /dev/null @@ -1,101 +0,0 @@ -import "@typespec/rest"; -import "@azure-tools/typespec-azure-core"; -import "@azure-tools/typespec-client-generator-core"; - -using TypeSpec.Http; -using TypeSpec.Rest; -using TypeSpec.Versioning; -using Azure.Core; -using Azure.Core.Foundations; -using Azure.Core.Traits; -using Azure.ClientGenerator.Core; - -@service(#{ title: "MultipleApiVersion" }) -@versioned(TspTest.MultipleApiVersion.Versions) -@Azure.ClientGenerator.Core.client({ - name: "FirstClient", -}) -@clientNamespace("tsptest.multipleapiversion", "java") -namespace TspTest.MultipleApiVersion { - @resource("resources") - model Resource { - @visibility(Lifecycle.Read) - id: string; - - @key - @visibility(Lifecycle.Read) - name: string; - - type: string; - } - - interface ResourceOperations - extends Azure.Core.ResourceOperations {} - - enum Versions { - v2022_06_01_preview: "2022-06-01-preview", - v2022_12_01_preview: "2022-12-01-preview", - } - - @route("/client1") - interface Client { - get is ResourceOperations.ResourceRead; - } -} - -@service(#{ title: "MultipleApiVersion2" }) -@versioned(TspTest.MultipleApiVersion2.Versions) -@Azure.ClientGenerator.Core.client({ - name: "SecondClient", -}) -@clientNamespace("tsptest.multipleapiversion", "java") -namespace TspTest.MultipleApiVersion2 { - @resource("resources") - model Resource2 { - @visibility(Lifecycle.Read) - id: string; - - @key - @visibility(Lifecycle.Read) - name: string; - - type: string; - } - - interface ResourceOperations - extends Azure.Core.ResourceOperations {} - - enum Versions { - v2022_10_01_preview: "2022-10-01-preview", - v2022_12_01_preview: "2022-12-01-preview", - } - - @route("/client2") - interface Client { - get is ResourceOperations.ResourceRead; - } -} - -@service(#{ title: "MultipleApiVersion3" }) -@versioned(TspTest.MultipleApiVersion3.Versions) -@Azure.ClientGenerator.Core.client({ - name: "NoApiVersionClient", -}) -@clientNamespace("tsptest.multipleapiversion", "java") -namespace TspTest.MultipleApiVersion3 { - enum Versions { - v2022_10_01_preview: "2022-10-01-preview", - v2022_12_01_preview: "2022-12-01-preview", - } - - @route("/client3") - interface Client { - // no api-version query parameter in the API - @post - action(@added(Versions.v2022_12_01_preview) @query param1?: string): OkResponse; - } -} diff --git a/typespec-tests/tsp/server.tsp b/typespec-tests/tsp/server.tsp deleted file mode 100644 index 37b50aadee..0000000000 --- a/typespec-tests/tsp/server.tsp +++ /dev/null @@ -1,65 +0,0 @@ -import "@typespec/rest"; -import "@typespec/versioning"; -import "@azure-tools/typespec-client-generator-core"; - -using TypeSpec.Http; -using TypeSpec.Versioning; -using Azure.ClientGenerator.Core; - -@service(#{ title: "HttpbinServer" }) -@server( - "https://{domain}.{tld}{relative-path}", - "Httpbin endpoint", - { - @doc("second-level domain, use httpbin") - domain: string = "httpbin", - - @doc("top-level domain, use org") - tld: string = "org", - - @doc("relative path segment, can be empty") - `relative-path`?: string, - } -) -@clientNamespace("tsptest.server", "java") -namespace TspTest.Server { - @Azure.ClientGenerator.Core.client({ - name: "HttpbinClient", - service: TspTest.Server, - }) - @route("/status/{code}") - interface ServerOp { - status(@path code: int32): OkResponse | NoContentResponse; - } -} - -@service(#{ title: "ContosoServer" }) -@versioned(TspTest.ContosoServer.APIVersions) -@server( - "{Endpoint}/contoso/{ApiVersion}", - "Service endpoint", - { - @doc("Service endpoint") - Endpoint: url, - - @doc("Api Version") - @path - ApiVersion: APIVersions, - } -) -@clientNamespace("tsptest.server.contoso", "java") -namespace TspTest.ContosoServer { - enum APIVersions { - v1: "v1", - } - - @client({ - name: "ContosoClient", - service: TspTest.ContosoServer, - }) - @route("/contoso/") - @clientNamespace("tsptest.server.contoso.sub", "java") - interface ServerOp { - get(@path(#{ allowReserved: true }) group: string): OkResponse | NoContentResponse; - } -} From 3289f4b81f9f84fbd3f7127d789383651dedb909 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 5 Jan 2026 17:24:24 +0800 Subject: [PATCH 2/3] update core --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index ec964751bf..92b8c8ddf1 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit ec964751bff845d8eeb3892b8983f91c1ae72bfa +Subproject commit 92b8c8ddf1af226d986888a9841918aedfcbb2a8 From 7aecc6f22b9a94b00cddcbc85e767d96957d7ae8 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Thu, 8 Jan 2026 10:50:22 +0800 Subject: [PATCH 3/3] prepare 0.38.0 --- typespec-extension/changelog.md | 6 + typespec-extension/package-lock.json | 178 +++++++++++++-------------- typespec-extension/package.json | 16 +-- typespec-tests/package.json | 4 +- 4 files changed, 105 insertions(+), 99 deletions(-) diff --git a/typespec-extension/changelog.md b/typespec-extension/changelog.md index 97f9274fac..253dbc1012 100644 --- a/typespec-extension/changelog.md +++ b/typespec-extension/changelog.md @@ -1,5 +1,11 @@ # Release History +## 0.38.0 (2026-01-08) + +Compatible with compiler 1.7.1. + +- Supported merging of multiple services into a single root client. + ## 0.37.4 (2025-12-18) Compatible with compiler 1.7.1. diff --git a/typespec-extension/package-lock.json b/typespec-extension/package-lock.json index c33ca8852e..86c10ae688 100644 --- a/typespec-extension/package-lock.json +++ b/typespec-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "@azure-tools/typespec-java", - "version": "0.37.4", + "version": "0.38.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@azure-tools/typespec-java", - "version": "0.37.4", + "version": "0.38.0", "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.1", @@ -15,7 +15,7 @@ }, "devDependencies": { "@azure-tools/typespec-autorest": "0.63.1", - "@azure-tools/typespec-azure-core": "0.63.0", + "@azure-tools/typespec-azure-core": "0.63.1", "@azure-tools/typespec-azure-resource-manager": "0.63.0", "@azure-tools/typespec-azure-rulesets": "0.63.0", "@azure-tools/typespec-client-generator-core": "0.63.3", @@ -24,8 +24,8 @@ "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.21", "@types/node": "~25.0.3", - "@typescript-eslint/eslint-plugin": "~8.51.0", - "@typescript-eslint/parser": "~8.51.0", + "@typescript-eslint/eslint-plugin": "~8.52.0", + "@typescript-eslint/parser": "~8.52.0", "@typespec/compiler": "1.7.1", "@typespec/events": "0.77.0", "@typespec/http": "1.7.0", @@ -46,7 +46,7 @@ "prettier": "~3.7.4", "rimraf": "~6.1.2", "typescript": "~5.9.3", - "typescript-eslint": "^8.51.0", + "typescript-eslint": "^8.52.0", "vitest": "^4.0.16" }, "engines": { @@ -54,7 +54,7 @@ }, "peerDependencies": { "@azure-tools/typespec-autorest": ">=0.63.1 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.63.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.63.1 <1.0.0", "@azure-tools/typespec-azure-resource-manager": ">=0.63.0 <1.0.0", "@azure-tools/typespec-azure-rulesets": ">=0.63.0 <1.0.0", "@azure-tools/typespec-client-generator-core": ">=0.63.3 <1.0.0", @@ -180,9 +180,9 @@ } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.63.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.63.0.tgz", - "integrity": "sha512-FbEmpZSQENzBt/Y8qSF1b98T8CqT3bV7IRV8AGGm/73NQZiWQCm2LvQzR0/lbqGntS2EnSBrt394Kt69wM4ifA==", + "version": "0.63.1", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.63.1.tgz", + "integrity": "sha512-r5bJLDNUYAoP3i6topz3P7Y7vFMig92pO/zUuTgo4Q5hTbFoUgKPBBBmamVSwBh5MO4lMSLekZC3QoEYnsVUDg==", "dev": true, "license": "MIT", "engines": { @@ -794,9 +794,9 @@ } }, "node_modules/@eslint-community/eslint-utils": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz", - "integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==", + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz", + "integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2437,20 +2437,20 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.51.0.tgz", - "integrity": "sha512-XtssGWJvypyM2ytBnSnKtHYOGT+4ZwTnBVl36TA4nRO2f4PRNGz5/1OszHzcZCvcBMh+qb7I06uoCmLTRdR9og==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.52.0.tgz", + "integrity": "sha512-okqtOgqu2qmZJ5iN4TWlgfF171dZmx2FzdOv2K/ixL2LZWDStL8+JgQerI2sa8eAEfoydG9+0V96m7V+P8yE1Q==", "dev": true, "license": "MIT", "dependencies": { - "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.51.0", - "@typescript-eslint/type-utils": "8.51.0", - "@typescript-eslint/utils": "8.51.0", - "@typescript-eslint/visitor-keys": "8.51.0", - "ignore": "^7.0.0", + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.52.0", + "@typescript-eslint/type-utils": "8.52.0", + "@typescript-eslint/utils": "8.52.0", + "@typescript-eslint/visitor-keys": "8.52.0", + "ignore": "^7.0.5", "natural-compare": "^1.4.0", - "ts-api-utils": "^2.2.0" + "ts-api-utils": "^2.4.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2460,15 +2460,15 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.51.0", + "@typescript-eslint/parser": "^8.52.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.4.tgz", - "integrity": "sha512-gJzzk+PQNznz8ysRrC0aOkBNVRBDtE1n53IqyqEf3PXrYwomFs5q4pGMizBMJF+ykh03insJ27hB8gSrD2Hn8A==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", "dev": true, "license": "MIT", "engines": { @@ -2489,17 +2489,17 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.51.0.tgz", - "integrity": "sha512-3xP4XzzDNQOIqBMWogftkwxhg5oMKApqY0BAflmLZiFYHqyhSOxv/cd/zPQLTcCXr4AkaKb25joocY0BD1WC6A==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.52.0.tgz", + "integrity": "sha512-iIACsx8pxRnguSYhHiMn2PvhvfpopO9FXHyn1mG5txZIsAaB6F0KwbFnUQN3KCiG3Jcuad/Cao2FAs1Wp7vAyg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.51.0", - "@typescript-eslint/types": "8.51.0", - "@typescript-eslint/typescript-estree": "8.51.0", - "@typescript-eslint/visitor-keys": "8.51.0", - "debug": "^4.3.4" + "@typescript-eslint/scope-manager": "8.52.0", + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/typescript-estree": "8.52.0", + "@typescript-eslint/visitor-keys": "8.52.0", + "debug": "^4.4.3" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2514,15 +2514,15 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.51.0.tgz", - "integrity": "sha512-Luv/GafO07Z7HpiI7qeEW5NW8HUtZI/fo/kE0YbtQEFpJRUuR0ajcWfCE5bnMvL7QQFrmT/odMe8QZww8X2nfQ==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.52.0.tgz", + "integrity": "sha512-xD0MfdSdEmeFa3OmVqonHi+Cciab96ls1UhIF/qX/O/gPu5KXD0bY9lu33jj04fjzrXHcuvjBcBC+D3SNSadaw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.51.0", - "@typescript-eslint/types": "^8.51.0", - "debug": "^4.3.4" + "@typescript-eslint/tsconfig-utils": "^8.52.0", + "@typescript-eslint/types": "^8.52.0", + "debug": "^4.4.3" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2536,14 +2536,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.51.0.tgz", - "integrity": "sha512-JhhJDVwsSx4hiOEQPeajGhCWgBMBwVkxC/Pet53EpBVs7zHHtayKefw1jtPaNRXpI9RA2uocdmpdfE7T+NrizA==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.52.0.tgz", + "integrity": "sha512-ixxqmmCcc1Nf8S0mS0TkJ/3LKcC8mruYJPOU6Ia2F/zUUR4pApW7LzrpU3JmtePbRUTes9bEqRc1Gg4iyRnDzA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.51.0", - "@typescript-eslint/visitor-keys": "8.51.0" + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/visitor-keys": "8.52.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2554,9 +2554,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.51.0.tgz", - "integrity": "sha512-Qi5bSy/vuHeWyir2C8u/uqGMIlIDu8fuiYWv48ZGlZ/k+PRPHtaAu7erpc7p5bzw2WNNSniuxoMSO4Ar6V9OXw==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.52.0.tgz", + "integrity": "sha512-jl+8fzr/SdzdxWJznq5nvoI7qn2tNYV/ZBAEcaFMVXf+K6jmXvAFrgo/+5rxgnL152f//pDEAYAhhBAZGrVfwg==", "dev": true, "license": "MIT", "engines": { @@ -2571,17 +2571,17 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.51.0.tgz", - "integrity": "sha512-0XVtYzxnobc9K0VU7wRWg1yiUrw4oQzexCG2V2IDxxCxhqBMSMbjB+6o91A+Uc0GWtgjCa3Y8bi7hwI0Tu4n5Q==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.52.0.tgz", + "integrity": "sha512-JD3wKBRWglYRQkAtsyGz1AewDu3mTc7NtRjR/ceTyGoPqmdS5oCdx/oZMWD5Zuqmo6/MpsYs0wp6axNt88/2EQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.51.0", - "@typescript-eslint/typescript-estree": "8.51.0", - "@typescript-eslint/utils": "8.51.0", - "debug": "^4.3.4", - "ts-api-utils": "^2.2.0" + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/typescript-estree": "8.52.0", + "@typescript-eslint/utils": "8.52.0", + "debug": "^4.4.3", + "ts-api-utils": "^2.4.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2609,9 +2609,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.51.0.tgz", - "integrity": "sha512-TizAvWYFM6sSscmEakjY3sPqGwxZRSywSsPEiuZF6d5GmGD9Gvlsv0f6N8FvAAA0CD06l3rIcWNbsN1e5F/9Ag==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.52.0.tgz", + "integrity": "sha512-LWQV1V4q9V4cT4H5JCIx3481iIFxH1UkVk+ZkGGAV1ZGcjGI9IoFOfg3O6ywz8QqCDEp7Inlg6kovMofsNRaGg==", "dev": true, "license": "MIT", "engines": { @@ -2623,21 +2623,21 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.51.0.tgz", - "integrity": "sha512-1qNjGqFRmlq0VW5iVlcyHBbCjPB7y6SxpBkrbhNWMy/65ZoncXCEPJxkRZL8McrseNH6lFhaxCIaX+vBuFnRng==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.52.0.tgz", + "integrity": "sha512-XP3LClsCc0FsTK5/frGjolyADTh3QmsLp6nKd476xNI9CsSsLnmn4f0jrzNoAulmxlmNIpeXuHYeEQv61Q6qeQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.51.0", - "@typescript-eslint/tsconfig-utils": "8.51.0", - "@typescript-eslint/types": "8.51.0", - "@typescript-eslint/visitor-keys": "8.51.0", - "debug": "^4.3.4", - "minimatch": "^9.0.4", - "semver": "^7.6.0", + "@typescript-eslint/project-service": "8.52.0", + "@typescript-eslint/tsconfig-utils": "8.52.0", + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/visitor-keys": "8.52.0", + "debug": "^4.4.3", + "minimatch": "^9.0.5", + "semver": "^7.7.3", "tinyglobby": "^0.2.15", - "ts-api-utils": "^2.2.0" + "ts-api-utils": "^2.4.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2664,16 +2664,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.51.0.tgz", - "integrity": "sha512-11rZYxSe0zabiKaCP2QAwRf/dnmgFgvTmeDTtZvUvXG3UuAdg/GU02NExmmIXzz3vLGgMdtrIosI84jITQOxUA==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.52.0.tgz", + "integrity": "sha512-wYndVMWkweqHpEpwPhwqE2lnD2DxC6WVLupU/DOt/0/v+/+iQbbzO3jOHjmBMnhu0DgLULvOaU4h4pwHYi2oRQ==", "dev": true, "license": "MIT", "dependencies": { - "@eslint-community/eslint-utils": "^4.7.0", - "@typescript-eslint/scope-manager": "8.51.0", - "@typescript-eslint/types": "8.51.0", - "@typescript-eslint/typescript-estree": "8.51.0" + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.52.0", + "@typescript-eslint/types": "8.52.0", + "@typescript-eslint/typescript-estree": "8.52.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2688,13 +2688,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.51.0.tgz", - "integrity": "sha512-mM/JRQOzhVN1ykejrvwnBRV3+7yTKK8tVANVN3o1O0t0v7o+jqdVu9crPy5Y9dov15TJk/FTIgoUGHrTOVL3Zg==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.52.0.tgz", + "integrity": "sha512-ink3/Zofus34nmBsPjow63FP5M7IGff0RKAgqR6+CFpdk22M7aLwC9gOcLGYqr7MczLPzZVERW9hRog3O4n1sQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.51.0", + "@typescript-eslint/types": "8.52.0", "eslint-visitor-keys": "^4.2.1" }, "engines": { @@ -8099,16 +8099,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.51.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.51.0.tgz", - "integrity": "sha512-jh8ZuM5oEh2PSdyQG9YAEM1TCGuWenLSuSUhf/irbVUNW9O5FhbFVONviN2TgMTBnUmyHv7E56rYnfLZK6TkiA==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.52.0.tgz", + "integrity": "sha512-atlQQJ2YkO4pfTVQmQ+wvYQwexPDOIgo+RaVcD7gHgzy/IQA+XTyuxNM9M9TVXvttkF7koBHmcwisKdOAf2EcA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.51.0", - "@typescript-eslint/parser": "8.51.0", - "@typescript-eslint/typescript-estree": "8.51.0", - "@typescript-eslint/utils": "8.51.0" + "@typescript-eslint/eslint-plugin": "8.52.0", + "@typescript-eslint/parser": "8.52.0", + "@typescript-eslint/typescript-estree": "8.52.0", + "@typescript-eslint/utils": "8.52.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/typespec-extension/package.json b/typespec-extension/package.json index 422da42e59..67fd1cdc67 100644 --- a/typespec-extension/package.json +++ b/typespec-extension/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/typespec-java", - "version": "0.37.4", + "version": "0.38.0", "description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding", "keywords": [ "TypeSpec" @@ -48,7 +48,7 @@ ], "peerDependencies": { "@azure-tools/typespec-autorest": ">=0.63.1 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.63.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.63.1 <1.0.0", "@azure-tools/typespec-azure-resource-manager": ">=0.63.0 <1.0.0", "@azure-tools/typespec-azure-rulesets": ">=0.63.0 <1.0.0", "@azure-tools/typespec-client-generator-core": ">=0.63.3 <1.0.0", @@ -67,7 +67,7 @@ }, "devDependencies": { "@azure-tools/typespec-autorest": "0.63.1", - "@azure-tools/typespec-azure-core": "0.63.0", + "@azure-tools/typespec-azure-core": "0.63.1", "@azure-tools/typespec-azure-resource-manager": "0.63.0", "@azure-tools/typespec-azure-rulesets": "0.63.0", "@azure-tools/typespec-client-generator-core": "0.63.3", @@ -76,8 +76,8 @@ "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.21", "@types/node": "~25.0.3", - "@typescript-eslint/eslint-plugin": "~8.51.0", - "@typescript-eslint/parser": "~8.51.0", + "@typescript-eslint/eslint-plugin": "~8.52.0", + "@typescript-eslint/parser": "~8.52.0", "@typespec/compiler": "1.7.1", "@typespec/events": "0.77.0", "@typespec/http": "1.7.0", @@ -98,12 +98,12 @@ "prettier": "~3.7.4", "rimraf": "~6.1.2", "typescript": "~5.9.3", - "typescript-eslint": "^8.51.0", + "typescript-eslint": "^8.52.0", "vitest": "^4.0.16" }, "overrides": { "eslint": "~9.39.2", - "@typescript-eslint/eslint-plugin": "~8.51.0", - "@typescript-eslint/parser": "~8.51.0" + "@typescript-eslint/eslint-plugin": "~8.52.0", + "@typescript-eslint/parser": "~8.52.0" } } diff --git a/typespec-tests/package.json b/typespec-tests/package.json index 9735643d43..29b0ed3f4d 100644 --- a/typespec-tests/package.json +++ b/typespec-tests/package.json @@ -13,7 +13,7 @@ "@typespec/spector": "0.1.0-alpha.21", "@typespec/http-specs": "0.1.0-alpha.29", "@azure-tools/azure-http-specs": "0.1.0-alpha.34", - "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.37.4.tgz" + "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.38.0.tgz" }, "devDependencies": { "@typespec/prettier-plugin-typespec": "^1.7.0", @@ -30,7 +30,7 @@ "@typespec/events": "0.77.0", "@typespec/sse": "0.77.0", "@typespec/streams": "0.77.0", - "@azure-tools/typespec-azure-core": "0.63.0", + "@azure-tools/typespec-azure-core": "0.63.1", "@azure-tools/typespec-client-generator-core": "0.63.3", "@azure-tools/typespec-azure-resource-manager": "0.63.0", "@azure-tools/typespec-autorest": "0.63.1",