From fea9d2e45bfcf39aeb8730a74bb1f1390905e3eb Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 9 Jan 2026 23:54:26 +0800 Subject: [PATCH 01/17] core on http-client-java_subclass-property-change --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 8c4d64c094..c515fdd341 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 8c4d64c0943f9643308a6fd0bd98b5ea2aa57342 +Subproject commit c515fdd3419857041f2a0d0d1e72a5e7252f2aa2 From e33b7a20161965e7c8f7ae962aff227cc6950bab Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Sun, 11 Jan 2026 18:19:09 +0800 Subject: [PATCH 02/17] update 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 +- .../tsptest/armlegacy/ArmLegacyManager.java | 282 ++++++++ .../armlegacy/fluent/ArmLegacyClient.java | 55 ++ .../tsptest/armlegacy/fluent/SkusClient.java | 207 ++++++ .../fluent/models/SkuResourceInner.java | 155 ++++ .../armlegacy/fluent/models/package-info.java | 9 + .../armlegacy/fluent/package-info.java | 9 + .../ArmLegacyClientBuilder.java | 138 ++++ .../implementation/ArmLegacyClientImpl.java | 308 ++++++++ .../implementation/ResourceManagerUtils.java | 195 ++++++ .../implementation/SkuResourceImpl.java | 105 +++ .../implementation/SkusClientImpl.java | 662 ++++++++++++++++++ .../armlegacy/implementation/SkusImpl.java | 202 ++++++ .../implementation/package-info.java | 9 + .../armlegacy/models/ProvisioningState.java | 76 ++ .../armlegacy/models/ResourceTypeSku.java | 73 ++ .../tsptest/armlegacy/models/SkuResource.java | 137 ++++ .../java/tsptest/armlegacy/models/Skus.java | 214 ++++++ .../armlegacy/models/package-info.java | 9 + .../java/tsptest/armlegacy/package-info.java | 9 + .../models/SawShark.java | 1 - .../tsptest/subclass/SubclassAsyncClient.java | 113 +++ .../java/tsptest/subclass/SubclassClient.java | 111 +++ .../subclass/SubclassClientBuilder.java | 287 ++++++++ .../implementation/SubclassClientImpl.java | 107 +++ .../subclass/implementation/SubclassImpl.java | 189 +++++ .../subclass/implementation/package-info.java | 10 + .../java/tsptest/subclass/models/Body.java | 154 ++++ .../models/DuplicateRequiredProperty.java | 83 +++ .../DuplicateRequiredPropertyParent.java | 83 +++ .../models/PropertyChangedToConstant.java | 77 ++ .../PropertyChangedToConstantParent.java | 83 +++ .../models/PropertyChangedToRequired.java | 82 +++ .../PropertyChangedToRequiredParent.java | 93 +++ .../tsptest/subclass/models/package-info.java | 10 + .../java/tsptest/subclass/package-info.java | 10 + .../proxy-config.json | 1 + .../reflect-config.json | 1 + ...urcemanager-armlegacy-generated.properties | 1 + .../resources/tsptest-subclass.properties | 2 + .../multiservice/ArmMultipleServiceTests.java | 39 ++ .../multiservice/MultipleServiceTests.java | 21 + .../subclass/SubclassPropertyTests.java | 33 + .../generated/SubclassClientTestBase.java | 34 + typespec-tests/tsp/arm-legacy.tsp | 129 ++++ typespec-tests/tsp/subclass.tsp | 54 ++ 55 files changed, 4705 insertions(+), 160 deletions(-) delete mode 100644 typespec-tests/src/main/java/service/multiservice/combined/ServiceAServiceVersion.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/ArmLegacyManager.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/fluent/ArmLegacyClient.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/fluent/SkusClient.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/fluent/models/SkuResourceInner.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/fluent/models/package-info.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/fluent/package-info.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/implementation/ArmLegacyClientBuilder.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/implementation/ArmLegacyClientImpl.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/implementation/ResourceManagerUtils.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkuResourceImpl.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkusClientImpl.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkusImpl.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/implementation/package-info.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/models/ProvisioningState.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/models/ResourceTypeSku.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/models/SkuResource.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/models/Skus.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/models/package-info.java create mode 100644 typespec-tests/src/main/java/tsptest/armlegacy/package-info.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/SubclassAsyncClient.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/SubclassClient.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/SubclassClientBuilder.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassClientImpl.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassImpl.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/implementation/package-info.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/models/Body.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredProperty.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredPropertyParent.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToConstant.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToConstantParent.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToRequired.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToRequiredParent.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/models/package-info.java create mode 100644 typespec-tests/src/main/java/tsptest/subclass/package-info.java create mode 100644 typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armlegacy-generated/proxy-config.json create mode 100644 typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armlegacy-generated/reflect-config.json create mode 100644 typespec-tests/src/main/resources/azure-resourcemanager-armlegacy-generated.properties create mode 100644 typespec-tests/src/main/resources/tsptest-subclass.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 create mode 100644 typespec-tests/src/test/java/tsptest/subclass/SubclassPropertyTests.java create mode 100644 typespec-tests/src/test/java/tsptest/subclass/generated/SubclassClientTestBase.java create mode 100644 typespec-tests/tsp/arm-legacy.tsp create mode 100644 typespec-tests/tsp/subclass.tsp diff --git a/core b/core index c515fdd341..993951fca9 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit c515fdd3419857041f2a0d0d1e72a5e7252f2aa2 +Subproject commit 993951fca9b12333a0dbc30867e8a58b5b42cb47 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/armlegacy/ArmLegacyManager.java b/typespec-tests/src/main/java/tsptest/armlegacy/ArmLegacyManager.java new file mode 100644 index 0000000000..234c70b7d1 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/ArmLegacyManager.java @@ -0,0 +1,282 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import tsptest.armlegacy.fluent.ArmLegacyClient; +import tsptest.armlegacy.implementation.ArmLegacyClientBuilder; +import tsptest.armlegacy.implementation.SkusImpl; +import tsptest.armlegacy.models.Skus; + +/** + * Entry point to ArmLegacyManager. + * Arm Resource Provider management API. + */ +public final class ArmLegacyManager { + private Skus skus; + + private final ArmLegacyClient clientObject; + + private ArmLegacyManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new ArmLegacyClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of ArmLegacy service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ArmLegacy service API instance. + */ + public static ArmLegacyManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of ArmLegacy service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the ArmLegacy service API instance. + */ + public static ArmLegacyManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ArmLegacyManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ArmLegacyManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ArmLegacyManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-armlegacy-generated.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of ArmLegacy service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ArmLegacy service API instance. + */ + public ArmLegacyManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("tsptest.armlegacy") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new ArmLegacyManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Skus. It manages SkuResource. + * + * @return Resource collection API of Skus. + */ + public Skus skus() { + if (this.skus == null) { + this.skus = new SkusImpl(clientObject.getSkus(), this); + } + return skus; + } + + /** + * Gets wrapped service client ArmLegacyClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client ArmLegacyClient. + */ + public ArmLegacyClient serviceClient() { + return this.clientObject; + } +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/fluent/ArmLegacyClient.java b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/ArmLegacyClient.java new file mode 100644 index 0000000000..f33b4a5b34 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/ArmLegacyClient.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for ArmLegacyClient class. + */ +public interface ArmLegacyClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the SkusClient object to access its operations. + * + * @return the SkusClient object. + */ + SkusClient getSkus(); +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/fluent/SkusClient.java b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/SkusClient.java new file mode 100644 index 0000000000..26a5b4a17e --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/SkusClient.java @@ -0,0 +1,207 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import tsptest.armlegacy.fluent.models.SkuResourceInner; + +/** + * An instance of this class provides access to all the operations defined in SkusClient. + */ +public interface SkusClient { + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, Context context); + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SkuResourceInner getNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, + String sku); + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, SkuResourceInner resource, Context context); + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SkuResourceInner createNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, + String sku, SkuResourceInner resource); + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, Context context); + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void deleteNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, String sku); + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getRootWithResponse(String providerNamespace, String resourceType, String sku, + Context context); + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SkuResourceInner getRoot(String providerNamespace, String resourceType, String sku); + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createRootWithResponse(String providerNamespace, String resourceType, String sku, + SkuResourceInner resource, Context context); + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + SkuResourceInner createRoot(String providerNamespace, String resourceType, String sku, SkuResourceInner resource); + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteRootWithResponse(String providerNamespace, String resourceType, String sku, Context context); + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void deleteRoot(String providerNamespace, String resourceType, String sku); +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/fluent/models/SkuResourceInner.java b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/models/SkuResourceInner.java new file mode 100644 index 0000000000..21e966d91e --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/models/SkuResourceInner.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import tsptest.armlegacy.models.ResourceTypeSku; + +/** + * Concrete proxy resource types can be created by aliasing this type using a specific property type. + */ +@Fluent +public final class SkuResourceInner extends ProxyResource { + /* + * The resource-specific properties for this resource. + */ + private ResourceTypeSku properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of SkuResourceInner class. + */ + public SkuResourceInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public ResourceTypeSku properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the SkuResourceInner object itself. + */ + public SkuResourceInner withProperties(ResourceTypeSku properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SkuResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SkuResourceInner 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 SkuResourceInner. + */ + public static SkuResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SkuResourceInner deserializedSkuResourceInner = new SkuResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedSkuResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedSkuResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedSkuResourceInner.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedSkuResourceInner.properties = ResourceTypeSku.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedSkuResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedSkuResourceInner; + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/fluent/models/package-info.java b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/models/package-info.java new file mode 100644 index 0000000000..943d736868 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for ArmLegacy. + * Arm Resource Provider management API. + */ +package tsptest.armlegacy.fluent.models; diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/fluent/package-info.java b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/package-info.java new file mode 100644 index 0000000000..f1f346a9dd --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for ArmLegacy. + * Arm Resource Provider management API. + */ +package tsptest.armlegacy.fluent; diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/implementation/ArmLegacyClientBuilder.java b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/ArmLegacyClientBuilder.java new file mode 100644 index 0000000000..cdf55e7013 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/ArmLegacyClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the ArmLegacyClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { ArmLegacyClientImpl.class }) +public final class ArmLegacyClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the ArmLegacyClientBuilder. + */ + public ArmLegacyClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the ArmLegacyClientBuilder. + */ + public ArmLegacyClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the ArmLegacyClientBuilder. + */ + public ArmLegacyClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the ArmLegacyClientBuilder. + */ + public ArmLegacyClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the ArmLegacyClientBuilder. + */ + public ArmLegacyClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the ArmLegacyClientBuilder. + */ + public ArmLegacyClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ArmLegacyClientImpl with the provided parameters. + * + * @return an instance of ArmLegacyClientImpl. + */ + public ArmLegacyClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + ArmLegacyClientImpl client = new ArmLegacyClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/implementation/ArmLegacyClientImpl.java b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/ArmLegacyClientImpl.java new file mode 100644 index 0000000000..032d64f27d --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/ArmLegacyClientImpl.java @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import tsptest.armlegacy.fluent.ArmLegacyClient; +import tsptest.armlegacy.fluent.SkusClient; + +/** + * Initializes a new instance of the ArmLegacyClientImpl type. + */ +@ServiceClient(builder = ArmLegacyClientBuilder.class) +public final class ArmLegacyClientImpl implements ArmLegacyClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The SkusClient object to access its operations. + */ + private final SkusClient skus; + + /** + * Gets the SkusClient object to access its operations. + * + * @return the SkusClient object. + */ + public SkusClient getSkus() { + return this.skus; + } + + /** + * Initializes an instance of ArmLegacyClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + ArmLegacyClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2024-12-01"; + this.skus = new SkusClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, () -> activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ArmLegacyClientImpl.class); +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/implementation/ResourceManagerUtils.java b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/ResourceManagerUtils.java new file mode 100644 index 0000000000..96b4a0a5a0 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkuResourceImpl.java b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkuResourceImpl.java new file mode 100644 index 0000000000..c0d6172ee3 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkuResourceImpl.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.implementation; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import tsptest.armlegacy.fluent.models.SkuResourceInner; +import tsptest.armlegacy.models.ResourceTypeSku; +import tsptest.armlegacy.models.SkuResource; + +public final class SkuResourceImpl implements SkuResource, SkuResource.Definition { + private SkuResourceInner innerObject; + + private final tsptest.armlegacy.ArmLegacyManager serviceManager; + + SkuResourceImpl(SkuResourceInner innerObject, tsptest.armlegacy.ArmLegacyManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public ResourceTypeSku properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public SkuResourceInner innerModel() { + return this.innerObject; + } + + private tsptest.armlegacy.ArmLegacyManager manager() { + return this.serviceManager; + } + + private String providerNamespace; + + private String resourceType; + + private String sku; + + public SkuResourceImpl withExistingResourcetypeRegistration(String providerNamespace, String resourceType) { + this.providerNamespace = providerNamespace; + this.resourceType = resourceType; + return this; + } + + public SkuResource create() { + this.innerObject = serviceManager.serviceClient() + .getSkus() + .createRootWithResponse(providerNamespace, resourceType, sku, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public SkuResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSkus() + .createRootWithResponse(providerNamespace, resourceType, sku, this.innerModel(), context) + .getValue(); + return this; + } + + SkuResourceImpl(String name, tsptest.armlegacy.ArmLegacyManager serviceManager) { + this.innerObject = new SkuResourceInner(); + this.serviceManager = serviceManager; + this.sku = name; + } + + public SkuResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getSkus() + .getRootWithResponse(providerNamespace, resourceType, sku, Context.NONE) + .getValue(); + return this; + } + + public SkuResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getSkus() + .getRootWithResponse(providerNamespace, resourceType, sku, context) + .getValue(); + return this; + } + + public SkuResourceImpl withProperties(ResourceTypeSku properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkusClientImpl.java b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkusClientImpl.java new file mode 100644 index 0000000000..094bde3847 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkusClientImpl.java @@ -0,0 +1,662 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import reactor.core.publisher.Mono; +import tsptest.armlegacy.fluent.SkusClient; +import tsptest.armlegacy.fluent.models.SkuResourceInner; + +/** + * An instance of this class provides access to all the operations defined in SkusClient. + */ +public final class SkusClientImpl implements SkusClient { + /** + * The proxy service used to perform REST calls. + */ + private final SkusService service; + + /** + * The service client containing this operation class. + */ + private final ArmLegacyClientImpl client; + + /** + * Initializes an instance of SkusClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SkusClientImpl(ArmLegacyClientImpl client) { + this.service = RestProxy.create(SkusService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ArmLegacyClientSkus to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "ArmLegacyClientSkus") + public interface SkusService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getNested(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getNestedSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createNested(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") SkuResourceInner resource, Context context); + + @Put("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createNestedSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") SkuResourceInner resource, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> deleteNested(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku, + Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/resourcetypeRegistrations/{nestedResourceTypeFirst}/skus/{sku}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response deleteNestedSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("nestedResourceTypeFirst") String nestedResourceTypeFirst, @PathParam("sku") String sku, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getRoot(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("sku") String sku, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getRootSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("sku") String sku, @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createRoot(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("sku") String sku, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") SkuResourceInner resource, + Context context); + + @Put("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createRootSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("sku") String sku, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") SkuResourceInner resource, + Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> deleteRoot(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("sku") String sku, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/providers/Microsoft.ThisWillBeReplaced/providerRegistrations/{providerNamespace}/resourcetypeRegistrations/{resourceType}/skus/{sku}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response deleteRootSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("providerNamespace") String providerNamespace, @PathParam("resourceType") String resourceType, + @PathParam("sku") String sku, Context context); + } + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getNestedWithResponseAsync(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNested(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getNestedAsync(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku) { + return getNestedWithResponseAsync(providerNamespace, resourceType, nestedResourceTypeFirst, sku) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, Context context) { + final String accept = "application/json"; + return service.getNestedSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, accept, + context); + } + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SkuResourceInner getNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, + String sku) { + return getNestedWithResponse(providerNamespace, resourceType, nestedResourceTypeFirst, sku, Context.NONE) + .getValue(); + } + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createNestedWithResponseAsync(String providerNamespace, + String resourceType, String nestedResourceTypeFirst, String sku, SkuResourceInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createNested(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, + contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createNestedAsync(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, SkuResourceInner resource) { + return createNestedWithResponseAsync(providerNamespace, resourceType, nestedResourceTypeFirst, sku, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, SkuResourceInner resource, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createNestedSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, contentType, + accept, resource, context); + } + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SkuResourceInner createNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, + String sku, SkuResourceInner resource) { + return createNestedWithResponse(providerNamespace, resourceType, nestedResourceTypeFirst, sku, resource, + Context.NONE).getValue(); + } + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteNestedWithResponseAsync(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku) { + return FluxUtil + .withContext(context -> service.deleteNested(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteNestedAsync(String providerNamespace, String resourceType, String nestedResourceTypeFirst, + String sku) { + return deleteNestedWithResponseAsync(providerNamespace, resourceType, nestedResourceTypeFirst, sku) + .flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, Context context) { + return service.deleteNestedSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, nestedResourceTypeFirst, sku, context); + } + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, + String sku) { + deleteNestedWithResponse(providerNamespace, resourceType, nestedResourceTypeFirst, sku, Context.NONE); + } + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getRootWithResponseAsync(String providerNamespace, String resourceType, + String sku) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getRoot(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, sku, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getRootAsync(String providerNamespace, String resourceType, String sku) { + return getRootWithResponseAsync(providerNamespace, resourceType, sku) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getRootWithResponse(String providerNamespace, String resourceType, String sku, + Context context) { + final String accept = "application/json"; + return service.getRootSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, sku, accept, context); + } + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SkuResourceInner getRoot(String providerNamespace, String resourceType, String sku) { + return getRootWithResponse(providerNamespace, resourceType, sku, Context.NONE).getValue(); + } + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createRootWithResponseAsync(String providerNamespace, String resourceType, + String sku, SkuResourceInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createRoot(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, sku, contentType, accept, resource, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createRootAsync(String providerNamespace, String resourceType, String sku, + SkuResourceInner resource) { + return createRootWithResponseAsync(providerNamespace, resourceType, sku, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createRootWithResponse(String providerNamespace, String resourceType, String sku, + SkuResourceInner resource, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createRootSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, sku, contentType, accept, resource, + context); + } + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public SkuResourceInner createRoot(String providerNamespace, String resourceType, String sku, + SkuResourceInner resource) { + return createRootWithResponse(providerNamespace, resourceType, sku, resource, Context.NONE).getValue(); + } + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteRootWithResponseAsync(String providerNamespace, String resourceType, + String sku) { + return FluxUtil + .withContext(context -> service.deleteRoot(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, sku, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteRootAsync(String providerNamespace, String resourceType, String sku) { + return deleteRootWithResponseAsync(providerNamespace, resourceType, sku).flatMap(ignored -> Mono.empty()); + } + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteRootWithResponse(String providerNamespace, String resourceType, String sku, + Context context) { + return service.deleteRootSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), providerNamespace, resourceType, sku, context); + } + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteRoot(String providerNamespace, String resourceType, String sku) { + deleteRootWithResponse(providerNamespace, resourceType, sku, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkusImpl.java b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkusImpl.java new file mode 100644 index 0000000000..99a246c7ae --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/SkusImpl.java @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.implementation; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import tsptest.armlegacy.fluent.SkusClient; +import tsptest.armlegacy.fluent.models.SkuResourceInner; +import tsptest.armlegacy.models.SkuResource; +import tsptest.armlegacy.models.Skus; + +public final class SkusImpl implements Skus { + private static final ClientLogger LOGGER = new ClientLogger(SkusImpl.class); + + private final SkusClient innerClient; + + private final tsptest.armlegacy.ArmLegacyManager serviceManager; + + public SkusImpl(SkusClient innerClient, tsptest.armlegacy.ArmLegacyManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, Context context) { + Response inner = this.serviceClient() + .getNestedWithResponse(providerNamespace, resourceType, nestedResourceTypeFirst, sku, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SkuResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public SkuResource getNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, + String sku) { + SkuResourceInner inner + = this.serviceClient().getNested(providerNamespace, resourceType, nestedResourceTypeFirst, sku); + if (inner != null) { + return new SkuResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response createNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, SkuResourceInner resource, Context context) { + Response inner = this.serviceClient() + .createNestedWithResponse(providerNamespace, resourceType, nestedResourceTypeFirst, sku, resource, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SkuResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public SkuResource createNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, + String sku, SkuResourceInner resource) { + SkuResourceInner inner = this.serviceClient() + .createNested(providerNamespace, resourceType, nestedResourceTypeFirst, sku, resource); + if (inner != null) { + return new SkuResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, Context context) { + return this.serviceClient() + .deleteNestedWithResponse(providerNamespace, resourceType, nestedResourceTypeFirst, sku, context); + } + + public void deleteNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, + String sku) { + this.serviceClient().deleteNested(providerNamespace, resourceType, nestedResourceTypeFirst, sku); + } + + public Response getRootWithResponse(String providerNamespace, String resourceType, String sku, + Context context) { + Response inner + = this.serviceClient().getRootWithResponse(providerNamespace, resourceType, sku, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new SkuResourceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public SkuResource getRoot(String providerNamespace, String resourceType, String sku) { + SkuResourceInner inner = this.serviceClient().getRoot(providerNamespace, resourceType, sku); + if (inner != null) { + return new SkuResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteRootWithResponse(String providerNamespace, String resourceType, String sku, + Context context) { + return this.serviceClient().deleteRootWithResponse(providerNamespace, resourceType, sku, context); + } + + public void deleteRoot(String providerNamespace, String resourceType, String sku) { + this.serviceClient().deleteRoot(providerNamespace, resourceType, sku); + } + + public SkuResource getRootById(String id) { + String providerNamespace = ResourceManagerUtils.getValueFromIdByName(id, "providerRegistrations"); + if (providerNamespace == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'providerRegistrations'.", id))); + } + String resourceType = ResourceManagerUtils.getValueFromIdByName(id, "resourcetypeRegistrations"); + if (resourceType == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'resourcetypeRegistrations'.", id))); + } + String sku = ResourceManagerUtils.getValueFromIdByName(id, "skus"); + if (sku == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'skus'.", id))); + } + return this.getRootWithResponse(providerNamespace, resourceType, sku, Context.NONE).getValue(); + } + + public Response getRootByIdWithResponse(String id, Context context) { + String providerNamespace = ResourceManagerUtils.getValueFromIdByName(id, "providerRegistrations"); + if (providerNamespace == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'providerRegistrations'.", id))); + } + String resourceType = ResourceManagerUtils.getValueFromIdByName(id, "resourcetypeRegistrations"); + if (resourceType == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'resourcetypeRegistrations'.", id))); + } + String sku = ResourceManagerUtils.getValueFromIdByName(id, "skus"); + if (sku == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'skus'.", id))); + } + return this.getRootWithResponse(providerNamespace, resourceType, sku, context); + } + + public void deleteRootById(String id) { + String providerNamespace = ResourceManagerUtils.getValueFromIdByName(id, "providerRegistrations"); + if (providerNamespace == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'providerRegistrations'.", id))); + } + String resourceType = ResourceManagerUtils.getValueFromIdByName(id, "resourcetypeRegistrations"); + if (resourceType == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'resourcetypeRegistrations'.", id))); + } + String sku = ResourceManagerUtils.getValueFromIdByName(id, "skus"); + if (sku == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'skus'.", id))); + } + this.deleteRootWithResponse(providerNamespace, resourceType, sku, Context.NONE); + } + + public Response deleteRootByIdWithResponse(String id, Context context) { + String providerNamespace = ResourceManagerUtils.getValueFromIdByName(id, "providerRegistrations"); + if (providerNamespace == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'providerRegistrations'.", id))); + } + String resourceType = ResourceManagerUtils.getValueFromIdByName(id, "resourcetypeRegistrations"); + if (resourceType == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException(String + .format("The resource ID '%s' is not valid. Missing path segment 'resourcetypeRegistrations'.", id))); + } + String sku = ResourceManagerUtils.getValueFromIdByName(id, "skus"); + if (sku == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'skus'.", id))); + } + return this.deleteRootWithResponse(providerNamespace, resourceType, sku, context); + } + + private SkusClient serviceClient() { + return this.innerClient; + } + + private tsptest.armlegacy.ArmLegacyManager manager() { + return this.serviceManager; + } + + public SkuResourceImpl define(String name) { + return new SkuResourceImpl(name, this.manager()); + } +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/implementation/package-info.java b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/package-info.java new file mode 100644 index 0000000000..7c77130eb6 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for ArmLegacy. + * Arm Resource Provider management API. + */ +package tsptest.armlegacy.implementation; diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/models/ProvisioningState.java b/typespec-tests/src/main/java/tsptest/armlegacy/models/ProvisioningState.java new file mode 100644 index 0000000000..4c5281afda --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/models/ProvisioningState.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ProvisioningState. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** + * Static value Provisioning for ProvisioningState. + */ + public static final ProvisioningState PROVISIONING = fromString("Provisioning"); + + /** + * Static value Updating for ProvisioningState. + */ + public static final ProvisioningState UPDATING = fromString("Updating"); + + /** + * Static value Deleting for ProvisioningState. + */ + public static final ProvisioningState DELETING = fromString("Deleting"); + + /** + * Static value Accepted for ProvisioningState. + */ + public static final ProvisioningState ACCEPTED = fromString("Accepted"); + + /** + * Creates a new instance of ProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ProvisioningState() { + } + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** + * Gets known ProvisioningState values. + * + * @return known ProvisioningState values. + */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/models/ResourceTypeSku.java b/typespec-tests/src/main/java/tsptest/armlegacy/models/ResourceTypeSku.java new file mode 100644 index 0000000000..470a039632 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/models/ResourceTypeSku.java @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ResourceTypeSku model. + */ +@Immutable +public final class ResourceTypeSku implements JsonSerializable { + /* + * The provisioningState property. + */ + private ProvisioningState provisioningState; + + /** + * Creates an instance of ResourceTypeSku class. + */ + public ResourceTypeSku() { + } + + /** + * Get the provisioningState property: The provisioningState property. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceTypeSku from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceTypeSku if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ResourceTypeSku. + */ + public static ResourceTypeSku fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceTypeSku deserializedResourceTypeSku = new ResourceTypeSku(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedResourceTypeSku.provisioningState = ProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceTypeSku; + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/models/SkuResource.java b/typespec-tests/src/main/java/tsptest/armlegacy/models/SkuResource.java new file mode 100644 index 0000000000..7136d52dbf --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/models/SkuResource.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.models; + +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import tsptest.armlegacy.fluent.models.SkuResourceInner; + +/** + * An immutable client-side representation of SkuResource. + */ +public interface SkuResource { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + ResourceTypeSku properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the inner tsptest.armlegacy.fluent.models.SkuResourceInner object. + * + * @return the inner object. + */ + SkuResourceInner innerModel(); + + /** + * The entirety of the SkuResource definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithParentResource, DefinitionStages.WithCreate { + } + + /** + * The SkuResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the SkuResource definition. + */ + interface Blank extends WithParentResource { + } + + /** + * The stage of the SkuResource definition allowing to specify parent resource. + */ + interface WithParentResource { + /** + * Specifies providerNamespace, resourceType. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @return the next definition stage. + */ + WithCreate withExistingResourcetypeRegistration(String providerNamespace, String resourceType); + } + + /** + * The stage of the SkuResource definition which contains all the minimum required properties for the resource + * to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + SkuResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + SkuResource create(Context context); + } + + /** + * The stage of the SkuResource definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(ResourceTypeSku properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + SkuResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + SkuResource refresh(Context context); +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/models/Skus.java b/typespec-tests/src/main/java/tsptest/armlegacy/models/Skus.java new file mode 100644 index 0000000000..ea55ce0b7c --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/models/Skus.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armlegacy.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import tsptest.armlegacy.fluent.models.SkuResourceInner; + +/** + * Resource collection API of Skus. + */ +public interface Skus { + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response}. + */ + Response getNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, Context context); + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource. + */ + SkuResource getNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, String sku); + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type along + * with {@link Response}. + */ + Response createNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, SkuResourceInner resource, Context context); + + /** + * Create a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return concrete proxy resource types can be created by aliasing this type using a specific property type. + */ + SkuResource createNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, String sku, + SkuResourceInner resource); + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteNestedWithResponse(String providerNamespace, String resourceType, + String nestedResourceTypeFirst, String sku, Context context); + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param nestedResourceTypeFirst The first child resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteNested(String providerNamespace, String resourceType, String nestedResourceTypeFirst, String sku); + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response}. + */ + Response getRootWithResponse(String providerNamespace, String resourceType, String sku, + Context context); + + /** + * Get a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource. + */ + SkuResource getRoot(String providerNamespace, String resourceType, String sku); + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteRootWithResponse(String providerNamespace, String resourceType, String sku, Context context); + + /** + * Delete a SkuResource. + * + * @param providerNamespace The name of the resource provider hosted within ProviderHub. + * @param resourceType The resource type. + * @param sku The SKU. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteRoot(String providerNamespace, String resourceType, String sku); + + /** + * Get a SkuResource. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response}. + */ + SkuResource getRootById(String id); + + /** + * Get a SkuResource. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SkuResource along with {@link Response}. + */ + Response getRootByIdWithResponse(String id, Context context); + + /** + * Delete a SkuResource. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteRootById(String id); + + /** + * Delete a SkuResource. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteRootByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new SkuResource resource. + * + * @param name resource name. + * @return the first stage of the new SkuResource definition. + */ + SkuResource.DefinitionStages.Blank define(String name); +} diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/models/package-info.java b/typespec-tests/src/main/java/tsptest/armlegacy/models/package-info.java new file mode 100644 index 0000000000..c58defcfc9 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for ArmLegacy. + * Arm Resource Provider management API. + */ +package tsptest.armlegacy.models; diff --git a/typespec-tests/src/main/java/tsptest/armlegacy/package-info.java b/typespec-tests/src/main/java/tsptest/armlegacy/package-info.java new file mode 100644 index 0000000000..c5f766eb6d --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armlegacy/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for ArmLegacy. + * Arm Resource Provider management API. + */ +package tsptest.armlegacy; diff --git a/typespec-tests/src/main/java/tsptest/armstreamstyleserialization/models/SawShark.java b/typespec-tests/src/main/java/tsptest/armstreamstyleserialization/models/SawShark.java index dad701b3bc..49590e9c11 100644 --- a/typespec-tests/src/main/java/tsptest/armstreamstyleserialization/models/SawShark.java +++ b/typespec-tests/src/main/java/tsptest/armstreamstyleserialization/models/SawShark.java @@ -276,7 +276,6 @@ public void validate() { public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("kind", this.kind); - jsonWriter.writeIntField("age", age()); jsonWriter.writeJsonField("properties", innerProperties()); jsonWriter.writeJsonField("anotherProperties", innerAnotherProperties()); jsonWriter.writeStringField("dna", this.dna); diff --git a/typespec-tests/src/main/java/tsptest/subclass/SubclassAsyncClient.java b/typespec-tests/src/main/java/tsptest/subclass/SubclassAsyncClient.java new file mode 100644 index 0000000000..6b4b01bb4d --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/SubclassAsyncClient.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass; + +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.subclass.implementation.SubclassImpl; +import tsptest.subclass.models.Body; + +/** + * Initializes a new instance of the asynchronous SubclassClient type. + */ +@ServiceClient(builder = SubclassClientBuilder.class, isAsync = true) +public final class SubclassAsyncClient { + @Generated + private final SubclassImpl serviceClient; + + /** + * Initializes an instance of SubclassAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SubclassAsyncClient(SubclassImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The propertyInSubclass operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     duplicateRequiredProperty (Optional): {
+     *         duplicateRequiredProperty: String (Required)
+     *     }
+     *     propertyChangedToRequired (Optional): {
+     *         propertyChangedToRequired: String (Required)
+     *     }
+     *     propertyChangedToConstant (Optional): {
+     *         propertyChangedToConstant: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     duplicateRequiredProperty (Optional): {
+     *         duplicateRequiredProperty: String (Required)
+     *     }
+     *     propertyChangedToRequired (Optional): {
+     *         propertyChangedToRequired: String (Required)
+     *     }
+     *     propertyChangedToConstant (Optional): {
+     *         propertyChangedToConstant: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body The body 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> propertyInSubclassWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.propertyInSubclassWithResponseAsync(body, requestOptions); + } + + /** + * The propertyInSubclass operation. + * + * @param body The body 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 propertyInSubclass(Body body) { + // Generated convenience method for propertyInSubclassWithResponse + RequestOptions requestOptions = new RequestOptions(); + return propertyInSubclassWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(Body.class)); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/SubclassClient.java b/typespec-tests/src/main/java/tsptest/subclass/SubclassClient.java new file mode 100644 index 0000000000..7dfe8614ef --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/SubclassClient.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass; + +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.subclass.implementation.SubclassImpl; +import tsptest.subclass.models.Body; + +/** + * Initializes a new instance of the synchronous SubclassClient type. + */ +@ServiceClient(builder = SubclassClientBuilder.class) +public final class SubclassClient { + @Generated + private final SubclassImpl serviceClient; + + /** + * Initializes an instance of SubclassClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SubclassClient(SubclassImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The propertyInSubclass operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     duplicateRequiredProperty (Optional): {
+     *         duplicateRequiredProperty: String (Required)
+     *     }
+     *     propertyChangedToRequired (Optional): {
+     *         propertyChangedToRequired: String (Required)
+     *     }
+     *     propertyChangedToConstant (Optional): {
+     *         propertyChangedToConstant: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     duplicateRequiredProperty (Optional): {
+     *         duplicateRequiredProperty: String (Required)
+     *     }
+     *     propertyChangedToRequired (Optional): {
+     *         propertyChangedToRequired: String (Required)
+     *     }
+     *     propertyChangedToConstant (Optional): {
+     *         propertyChangedToConstant: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body The body 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 propertyInSubclassWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.propertyInSubclassWithResponse(body, requestOptions); + } + + /** + * The propertyInSubclass operation. + * + * @param body The body 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 Body propertyInSubclass(Body body) { + // Generated convenience method for propertyInSubclassWithResponse + RequestOptions requestOptions = new RequestOptions(); + return propertyInSubclassWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(Body.class); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/SubclassClientBuilder.java b/typespec-tests/src/main/java/tsptest/subclass/SubclassClientBuilder.java new file mode 100644 index 0000000000..13b233af8f --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/SubclassClientBuilder.java @@ -0,0 +1,287 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass; + +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.subclass.implementation.SubclassClientImpl; + +/** + * A builder for creating a new instance of the SubclassClient type. + */ +@ServiceClientBuilder(serviceClients = { SubclassClient.class, SubclassAsyncClient.class }) +public final class SubclassClientBuilder 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-subclass.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the SubclassClientBuilder. + */ + @Generated + public SubclassClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SubclassClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SubclassClientBuilder 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 SubclassClientBuilder 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 SubclassClientBuilder 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 SubclassClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SubclassClientBuilder 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 SubclassClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SubclassClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + 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 SubclassClientBuilder. + */ + @Generated + public SubclassClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SubclassClientImpl with the provided parameters. + * + * @return an instance of SubclassClientImpl. + */ + @Generated + private SubclassClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + SubclassClientImpl client + = new SubclassClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + 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 SubclassAsyncClient class. + * + * @return an instance of SubclassAsyncClient. + */ + @Generated + public SubclassAsyncClient buildAsyncClient() { + return new SubclassAsyncClient(buildInnerClient().getSubclass()); + } + + /** + * Builds an instance of SubclassClient class. + * + * @return an instance of SubclassClient. + */ + @Generated + public SubclassClient buildClient() { + return new SubclassClient(buildInnerClient().getSubclass()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SubclassClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassClientImpl.java b/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassClientImpl.java new file mode 100644 index 0000000000..5566742f36 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassClientImpl.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.implementation; + +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.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; + +/** + * Initializes a new instance of the SubclassClient type. + */ +public final class SubclassClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * The SubclassImpl object to access its operations. + */ + private final SubclassImpl subclass; + + /** + * Gets the SubclassImpl object to access its operations. + * + * @return the SubclassImpl object. + */ + public SubclassImpl getSubclass() { + return this.subclass; + } + + /** + * Initializes an instance of SubclassClient client. + * + * @param endpoint Service host. + */ + public SubclassClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SubclassClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public SubclassClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of SubclassClient 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. + */ + public SubclassClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.subclass = new SubclassImpl(this); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassImpl.java b/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassImpl.java new file mode 100644 index 0000000000..306cb98244 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassImpl.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +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.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 reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Subclass. + */ +public final class SubclassImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SubclassService service; + + /** + * The service client containing this operation class. + */ + private final SubclassClientImpl client; + + /** + * Initializes an instance of SubclassImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SubclassImpl(SubclassClientImpl client) { + this.service = RestProxy.create(SubclassService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for SubclassClientSubclass to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "SubclassClientSubclass") + public interface SubclassService { + @Post("/subclass/property-in-subclass") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> propertyInSubclass(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/subclass/property-in-subclass") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response propertyInSubclassSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** + * The propertyInSubclass operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     duplicateRequiredProperty (Optional): {
+     *         duplicateRequiredProperty: String (Required)
+     *     }
+     *     propertyChangedToRequired (Optional): {
+     *         propertyChangedToRequired: String (Required)
+     *     }
+     *     propertyChangedToConstant (Optional): {
+     *         propertyChangedToConstant: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     duplicateRequiredProperty (Optional): {
+     *         duplicateRequiredProperty: String (Required)
+     *     }
+     *     propertyChangedToRequired (Optional): {
+     *         propertyChangedToRequired: String (Required)
+     *     }
+     *     propertyChangedToConstant (Optional): {
+     *         propertyChangedToConstant: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body The body 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> propertyInSubclassWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.propertyInSubclass(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); + } + + /** + * The propertyInSubclass operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     duplicateRequiredProperty (Optional): {
+     *         duplicateRequiredProperty: String (Required)
+     *     }
+     *     propertyChangedToRequired (Optional): {
+     *         propertyChangedToRequired: String (Required)
+     *     }
+     *     propertyChangedToConstant (Optional): {
+     *         propertyChangedToConstant: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     duplicateRequiredProperty (Optional): {
+     *         duplicateRequiredProperty: String (Required)
+     *     }
+     *     propertyChangedToRequired (Optional): {
+     *         propertyChangedToRequired: String (Required)
+     *     }
+     *     propertyChangedToConstant (Optional): {
+     *         propertyChangedToConstant: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body The body 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 propertyInSubclassWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.propertyInSubclassSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/implementation/package-info.java b/typespec-tests/src/main/java/tsptest/subclass/implementation/package-info.java new file mode 100644 index 0000000000..4cc0977cd8 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/implementation/package-info.java @@ -0,0 +1,10 @@ +// 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 Subclass. + * + */ +package tsptest.subclass.implementation; diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/Body.java b/typespec-tests/src/main/java/tsptest/subclass/models/Body.java new file mode 100644 index 0000000000..432ee35a8b --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/models/Body.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +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 Body model. + */ +@Fluent +public final class Body implements JsonSerializable { + /* + * The duplicateRequiredProperty property. + */ + @Generated + private DuplicateRequiredProperty duplicateRequiredProperty; + + /* + * The propertyChangedToRequired property. + */ + @Generated + private PropertyChangedToRequired propertyChangedToRequired; + + /* + * The propertyChangedToConstant property. + */ + @Generated + private PropertyChangedToConstant propertyChangedToConstant; + + /** + * Creates an instance of Body class. + */ + @Generated + public Body() { + } + + /** + * Get the duplicateRequiredProperty property: The duplicateRequiredProperty property. + * + * @return the duplicateRequiredProperty value. + */ + @Generated + public DuplicateRequiredProperty getDuplicateRequiredProperty() { + return this.duplicateRequiredProperty; + } + + /** + * Set the duplicateRequiredProperty property: The duplicateRequiredProperty property. + * + * @param duplicateRequiredProperty the duplicateRequiredProperty value to set. + * @return the Body object itself. + */ + @Generated + public Body setDuplicateRequiredProperty(DuplicateRequiredProperty duplicateRequiredProperty) { + this.duplicateRequiredProperty = duplicateRequiredProperty; + return this; + } + + /** + * Get the propertyChangedToRequired property: The propertyChangedToRequired property. + * + * @return the propertyChangedToRequired value. + */ + @Generated + public PropertyChangedToRequired getPropertyChangedToRequired() { + return this.propertyChangedToRequired; + } + + /** + * Set the propertyChangedToRequired property: The propertyChangedToRequired property. + * + * @param propertyChangedToRequired the propertyChangedToRequired value to set. + * @return the Body object itself. + */ + @Generated + public Body setPropertyChangedToRequired(PropertyChangedToRequired propertyChangedToRequired) { + this.propertyChangedToRequired = propertyChangedToRequired; + return this; + } + + /** + * Get the propertyChangedToConstant property: The propertyChangedToConstant property. + * + * @return the propertyChangedToConstant value. + */ + @Generated + public PropertyChangedToConstant getPropertyChangedToConstant() { + return this.propertyChangedToConstant; + } + + /** + * Set the propertyChangedToConstant property: The propertyChangedToConstant property. + * + * @param propertyChangedToConstant the propertyChangedToConstant value to set. + * @return the Body object itself. + */ + @Generated + public Body setPropertyChangedToConstant(PropertyChangedToConstant propertyChangedToConstant) { + this.propertyChangedToConstant = propertyChangedToConstant; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("duplicateRequiredProperty", this.duplicateRequiredProperty); + jsonWriter.writeJsonField("propertyChangedToRequired", this.propertyChangedToRequired); + jsonWriter.writeJsonField("propertyChangedToConstant", this.propertyChangedToConstant); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Body from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Body if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IOException If an error occurs while reading the Body. + */ + @Generated + public static Body fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Body deserializedBody = new Body(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("duplicateRequiredProperty".equals(fieldName)) { + deserializedBody.duplicateRequiredProperty = DuplicateRequiredProperty.fromJson(reader); + } else if ("propertyChangedToRequired".equals(fieldName)) { + deserializedBody.propertyChangedToRequired = PropertyChangedToRequired.fromJson(reader); + } else if ("propertyChangedToConstant".equals(fieldName)) { + deserializedBody.propertyChangedToConstant = PropertyChangedToConstant.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedBody; + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredProperty.java b/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredProperty.java new file mode 100644 index 0000000000..828f6a0797 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredProperty.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The DuplicateRequiredProperty model. + */ +@Immutable +public final class DuplicateRequiredProperty extends DuplicateRequiredPropertyParent { + /* + * The duplicateRequiredProperty property. + */ + @Generated + private final String duplicateRequiredProperty; + + /** + * Creates an instance of DuplicateRequiredProperty class. + * + * @param duplicateRequiredProperty the duplicateRequiredProperty value to set. + */ + @Generated + public DuplicateRequiredProperty(String duplicateRequiredProperty) { + super(duplicateRequiredProperty); + this.duplicateRequiredProperty = duplicateRequiredProperty; + } + + /** + * Get the duplicateRequiredProperty property: The duplicateRequiredProperty property. + * + * @return the duplicateRequiredProperty value. + */ + @Generated + public String getDuplicateRequiredProperty() { + return this.duplicateRequiredProperty; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("duplicateRequiredProperty", this.duplicateRequiredProperty); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DuplicateRequiredProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DuplicateRequiredProperty 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 DuplicateRequiredProperty. + */ + @Generated + public static DuplicateRequiredProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String duplicateRequiredProperty = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("duplicateRequiredProperty".equals(fieldName)) { + duplicateRequiredProperty = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new DuplicateRequiredProperty(duplicateRequiredProperty); + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredPropertyParent.java b/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredPropertyParent.java new file mode 100644 index 0000000000..f936a25bb6 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredPropertyParent.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.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 DuplicateRequiredPropertyParent model. + */ +@Immutable +public class DuplicateRequiredPropertyParent implements JsonSerializable { + /* + * The duplicateRequiredProperty property. + */ + @Generated + private final String duplicateRequiredProperty; + + /** + * Creates an instance of DuplicateRequiredPropertyParent class. + * + * @param duplicateRequiredProperty the duplicateRequiredProperty value to set. + */ + @Generated + public DuplicateRequiredPropertyParent(String duplicateRequiredProperty) { + this.duplicateRequiredProperty = duplicateRequiredProperty; + } + + /** + * Get the duplicateRequiredProperty property: The duplicateRequiredProperty property. + * + * @return the duplicateRequiredProperty value. + */ + @Generated + public String getDuplicateRequiredProperty() { + return this.duplicateRequiredProperty; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("duplicateRequiredProperty", this.duplicateRequiredProperty); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DuplicateRequiredPropertyParent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DuplicateRequiredPropertyParent 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 DuplicateRequiredPropertyParent. + */ + @Generated + public static DuplicateRequiredPropertyParent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String duplicateRequiredProperty = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("duplicateRequiredProperty".equals(fieldName)) { + duplicateRequiredProperty = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new DuplicateRequiredPropertyParent(duplicateRequiredProperty); + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToConstant.java b/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToConstant.java new file mode 100644 index 0000000000..4112d8e0e6 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToConstant.java @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The PropertyChangedToConstant model. + */ +@Immutable +public final class PropertyChangedToConstant extends PropertyChangedToConstantParent { + /* + * The propertyChangedToConstant property. + */ + @Generated + private final String propertyChangedToConstant = "constantValue"; + + /** + * Creates an instance of PropertyChangedToConstant class. + */ + @Generated + public PropertyChangedToConstant() { + super("constantValue"); + } + + /** + * Get the propertyChangedToConstant property: The propertyChangedToConstant property. + * + * @return the propertyChangedToConstant value. + */ + @Generated + public String getPropertyChangedToConstant() { + return this.propertyChangedToConstant; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("propertyChangedToConstant", this.propertyChangedToConstant); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PropertyChangedToConstant from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PropertyChangedToConstant 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 PropertyChangedToConstant. + */ + @Generated + public static PropertyChangedToConstant fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PropertyChangedToConstant deserializedPropertyChangedToConstant = new PropertyChangedToConstant(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedPropertyChangedToConstant; + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToConstantParent.java b/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToConstantParent.java new file mode 100644 index 0000000000..42ec9ff3a1 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToConstantParent.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.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 PropertyChangedToConstantParent model. + */ +@Immutable +public class PropertyChangedToConstantParent implements JsonSerializable { + /* + * The propertyChangedToConstant property. + */ + @Generated + private final String propertyChangedToConstant; + + /** + * Creates an instance of PropertyChangedToConstantParent class. + * + * @param propertyChangedToConstant the propertyChangedToConstant value to set. + */ + @Generated + public PropertyChangedToConstantParent(String propertyChangedToConstant) { + this.propertyChangedToConstant = propertyChangedToConstant; + } + + /** + * Get the propertyChangedToConstant property: The propertyChangedToConstant property. + * + * @return the propertyChangedToConstant value. + */ + @Generated + public String getPropertyChangedToConstant() { + return this.propertyChangedToConstant; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("propertyChangedToConstant", this.propertyChangedToConstant); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PropertyChangedToConstantParent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PropertyChangedToConstantParent 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 PropertyChangedToConstantParent. + */ + @Generated + public static PropertyChangedToConstantParent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String propertyChangedToConstant = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("propertyChangedToConstant".equals(fieldName)) { + propertyChangedToConstant = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new PropertyChangedToConstantParent(propertyChangedToConstant); + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToRequired.java b/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToRequired.java new file mode 100644 index 0000000000..b71da97a6a --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToRequired.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The PropertyChangedToRequired model. + */ +@Fluent +public final class PropertyChangedToRequired extends PropertyChangedToRequiredParent { + /* + * The propertyChangedToRequired property. + */ + @Generated + private final String propertyChangedToRequired; + + /** + * Creates an instance of PropertyChangedToRequired class. + * + * @param propertyChangedToRequired the propertyChangedToRequired value to set. + */ + @Generated + public PropertyChangedToRequired(String propertyChangedToRequired) { + this.propertyChangedToRequired = propertyChangedToRequired; + } + + /** + * Get the propertyChangedToRequired property: The propertyChangedToRequired property. + * + * @return the propertyChangedToRequired value. + */ + @Generated + public String getPropertyChangedToRequired() { + return this.propertyChangedToRequired; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("propertyChangedToRequired", this.propertyChangedToRequired); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PropertyChangedToRequired from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PropertyChangedToRequired 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 PropertyChangedToRequired. + */ + @Generated + public static PropertyChangedToRequired fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String propertyChangedToRequired = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("propertyChangedToRequired".equals(fieldName)) { + propertyChangedToRequired = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new PropertyChangedToRequired(propertyChangedToRequired); + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToRequiredParent.java b/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToRequiredParent.java new file mode 100644 index 0000000000..2ab1511ea6 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/models/PropertyChangedToRequiredParent.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +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 PropertyChangedToRequiredParent model. + */ +@Fluent +public class PropertyChangedToRequiredParent implements JsonSerializable { + /* + * The propertyChangedToRequired property. + */ + @Generated + private String propertyChangedToRequired; + + /** + * Creates an instance of PropertyChangedToRequiredParent class. + */ + @Generated + public PropertyChangedToRequiredParent() { + } + + /** + * Get the propertyChangedToRequired property: The propertyChangedToRequired property. + * + * @return the propertyChangedToRequired value. + */ + @Generated + public String getPropertyChangedToRequired() { + return this.propertyChangedToRequired; + } + + /** + * Set the propertyChangedToRequired property: The propertyChangedToRequired property. + * + * @param propertyChangedToRequired the propertyChangedToRequired value to set. + * @return the PropertyChangedToRequiredParent object itself. + */ + @Generated + public PropertyChangedToRequiredParent setPropertyChangedToRequired(String propertyChangedToRequired) { + this.propertyChangedToRequired = propertyChangedToRequired; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("propertyChangedToRequired", this.propertyChangedToRequired); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PropertyChangedToRequiredParent from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PropertyChangedToRequiredParent if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the PropertyChangedToRequiredParent. + */ + @Generated + public static PropertyChangedToRequiredParent fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PropertyChangedToRequiredParent deserializedPropertyChangedToRequiredParent + = new PropertyChangedToRequiredParent(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("propertyChangedToRequired".equals(fieldName)) { + deserializedPropertyChangedToRequiredParent.propertyChangedToRequired = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPropertyChangedToRequiredParent; + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/package-info.java b/typespec-tests/src/main/java/tsptest/subclass/models/package-info.java new file mode 100644 index 0000000000..a14fc55334 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/models/package-info.java @@ -0,0 +1,10 @@ +// 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 Subclass. + * + */ +package tsptest.subclass.models; diff --git a/typespec-tests/src/main/java/tsptest/subclass/package-info.java b/typespec-tests/src/main/java/tsptest/subclass/package-info.java new file mode 100644 index 0000000000..925d7ab7f0 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/subclass/package-info.java @@ -0,0 +1,10 @@ +// 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 Subclass. + * + */ +package tsptest.subclass; diff --git a/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armlegacy-generated/proxy-config.json b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armlegacy-generated/proxy-config.json new file mode 100644 index 0000000000..14dc57b73c --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armlegacy-generated/proxy-config.json @@ -0,0 +1 @@ +[["tsptest.armlegacy.implementation.SkusClientImpl$SkusService"]] \ No newline at end of file diff --git a/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armlegacy-generated/reflect-config.json b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armlegacy-generated/reflect-config.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-armlegacy-generated/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/typespec-tests/src/main/resources/azure-resourcemanager-armlegacy-generated.properties b/typespec-tests/src/main/resources/azure-resourcemanager-armlegacy-generated.properties new file mode 100644 index 0000000000..defbd48204 --- /dev/null +++ b/typespec-tests/src/main/resources/azure-resourcemanager-armlegacy-generated.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/typespec-tests/src/main/resources/tsptest-subclass.properties b/typespec-tests/src/main/resources/tsptest-subclass.properties new file mode 100644 index 0000000000..ca812989b4 --- /dev/null +++ b/typespec-tests/src/main/resources/tsptest-subclass.properties @@ -0,0 +1,2 @@ +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/subclass/SubclassPropertyTests.java b/typespec-tests/src/test/java/tsptest/subclass/SubclassPropertyTests.java new file mode 100644 index 0000000000..0d425cbad4 --- /dev/null +++ b/typespec-tests/src/test/java/tsptest/subclass/SubclassPropertyTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package tsptest.subclass; + +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import tsptest.subclass.models.PropertyChangedToConstant; +import tsptest.subclass.models.PropertyChangedToRequired; + +public class SubclassPropertyTests { + + @Test + public void testPropertyChangedToRequired() { + PropertyChangedToRequired model = new PropertyChangedToRequired("value"); + String json = BinaryData.fromObject(model).toString(); + Assertions.assertEquals("{\"propertyChangedToRequired\":\"value\"}", json); + + model = BinaryData.fromString(json).toObject(PropertyChangedToRequired.class); + Assertions.assertEquals("value", model.getPropertyChangedToRequired()); + } + + @Test + public void testPropertyChangedToConstant() { + PropertyChangedToConstant model = new PropertyChangedToConstant(); + String json = BinaryData.fromObject(model).toString(); + Assertions.assertEquals("{\"propertyChangedToConstant\":\"constantValue\"}", json); + + model = BinaryData.fromString(json).toObject(PropertyChangedToConstant.class); + Assertions.assertEquals("constantValue", model.getPropertyChangedToConstant()); + } +} diff --git a/typespec-tests/src/test/java/tsptest/subclass/generated/SubclassClientTestBase.java b/typespec-tests/src/test/java/tsptest/subclass/generated/SubclassClientTestBase.java new file mode 100644 index 0000000000..5ade858bbc --- /dev/null +++ b/typespec-tests/src/test/java/tsptest/subclass/generated/SubclassClientTestBase.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.subclass.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.subclass.SubclassClient; +import tsptest.subclass.SubclassClientBuilder; + +class SubclassClientTestBase extends TestProxyTestBase { + protected SubclassClient subclassClient; + + @Override + protected void beforeTest() { + SubclassClientBuilder subclassClientbuilder + = new SubclassClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + subclassClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + subclassClient = subclassClientbuilder.buildClient(); + + } +} diff --git a/typespec-tests/tsp/arm-legacy.tsp b/typespec-tests/tsp/arm-legacy.tsp new file mode 100644 index 0000000000..dbb8f07452 --- /dev/null +++ b/typespec-tests/tsp/arm-legacy.tsp @@ -0,0 +1,129 @@ +import "@typespec/http"; +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.ResourceManager; +using Azure.ClientGenerator.Core; + +@armProviderNamespace +@service(#{ title: "ArmLegacy" }) +@versioned(Versions) +@doc("Arm Resource Provider management API.") +namespace TspTest.ArmLegacy; + +enum Versions { + v2024_12_01: "2024-12-01", +} + +model SkuResource is Azure.ResourceManager.ProxyResource { + ...ResourceNameParameter< + Resource = SkuResource, + KeyName = "sku", + SegmentName = "skus", + NamePattern = "" + >; +} + +@armResourceOperations +interface Skus { + getNested is SkuNested.Read; + + createNested is SkuNested.CreateOrUpdateSync< + SkuResource, + Response = ArmResourceUpdatedResponse + >; + + deleteNested is SkuNested.DeleteSync; + + getRoot is SkuRoot.Read; + + createRoot is SkuRoot.CreateOrUpdateSync< + SkuResource, + Response = ArmResourceUpdatedResponse + >; + + deleteRoot is SkuRoot.DeleteSync; +} + +model ResourceTypeSku { + @visibility(Lifecycle.Read) + provisioningState?: ProvisioningState; +} + +union ProvisioningState { + ResourceProvisioningState, + Provisioning: "Provisioning", + Updating: "Updating", + Deleting: "Deleting", + Accepted: "Accepted", +} + +interface SkuRoot + extends Azure.ResourceManager.Legacy.ExtensionOperations< + { + ...ApiVersionParameter, + ...SubscriptionIdParameter, + ...Azure.ResourceManager.Legacy.Provider, + + /** The name of the resource provider hosted within ProviderHub. */ + @path + @segment("providerRegistrations") + @key + providerNamespace: string, + + /** The resource type. */ + @path + @segment("resourcetypeRegistrations") + @key + resourceType: string, + }, + {}, + { + /** The SKU. */ + @path + @segment("skus") + @key + sku: string, + } + > {} + +interface SkuNested + extends Azure.ResourceManager.Legacy.ExtensionOperations< + { + ...ApiVersionParameter, + ...SubscriptionIdParameter, + ...Azure.ResourceManager.Legacy.Provider, + + /** The name of the resource provider hosted within ProviderHub. */ + @path + @segment("providerRegistrations") + @key + providerNamespace: string, + + /** The resource type. */ + @path + @segment("resourcetypeRegistrations") + @key + resourceType: string, + + /** The first child resource type. */ + @path + @segment("resourcetypeRegistrations") + @key + nestedResourceTypeFirst: string, + }, + {}, + { + /** The SKU. */ + @path + @segment("skus") + @key + sku: string, + } + > {} diff --git a/typespec-tests/tsp/subclass.tsp b/typespec-tests/tsp/subclass.tsp new file mode 100644 index 0000000000..8afbf8e9d6 --- /dev/null +++ b/typespec-tests/tsp/subclass.tsp @@ -0,0 +1,54 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; + +@service(#{ title: "Subclass" }) +namespace TspTest.Subclass; + +model DuplicateRequiredPropertyParent { + duplicateRequiredProperty: string; +} +model DuplicateRequiredProperty extends DuplicateRequiredPropertyParent { + duplicateRequiredProperty: string; +} + +model PropertyChangedToRequiredParent { + propertyChangedToRequired?: string; +} +model PropertyChangedToRequired extends PropertyChangedToRequiredParent { + propertyChangedToRequired: string; +} + +model PropertyChangedToConstantParent { + propertyChangedToConstant: string; +} +model PropertyChangedToConstant extends PropertyChangedToConstantParent { + propertyChangedToConstant: "constantValue"; +} + +// Incompatible return type in Java method override +// model PropertyChangedToEnumParent { +// propertyChangedToEnum: string; +// } +// model PropertyChangedToEnum extends PropertyChangedToEnumParent { +// propertyChangedToEnum: EnumModel; +// } +// union EnumModel { +// string, +// "value1", +// } + +model Body { + duplicateRequiredProperty?: DuplicateRequiredProperty; + propertyChangedToRequired?: PropertyChangedToRequired; + propertyChangedToConstant?: PropertyChangedToConstant; +} + +@route("/subclass") +interface Subclass { + @post + @route("/property-in-subclass") + propertyInSubclass(@body body: Body): Body; +} From f4898f7ad610faad923ac8ac21df6dae7243f1bc Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Sun, 11 Jan 2026 18:20:39 +0800 Subject: [PATCH 03/17] update core --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 993951fca9..dafe0ec77c 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 993951fca9b12333a0dbc30867e8a58b5b42cb47 +Subproject commit dafe0ec77c34474c450c5d56981ba286027c6852 From 1d76c9c4600a9d2568a5ec85adce9def24a8022b Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Sun, 11 Jan 2026 19:10:39 +0800 Subject: [PATCH 04/17] update core --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index dafe0ec77c..a675ba6af6 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit dafe0ec77c34474c450c5d56981ba286027c6852 +Subproject commit a675ba6af68ebaa2b9986eac553dddfa9fca4caa From dc64104b5355c30cc909c319fcc1110062c5a6bc Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Sun, 11 Jan 2026 19:59:03 +0800 Subject: [PATCH 05/17] update core --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index a675ba6af6..bdef8c0b9c 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit a675ba6af68ebaa2b9986eac553dddfa9fca4caa +Subproject commit bdef8c0b9cc8cec9cd4e0cbe2b706bebd3688067 From d8a2e36a569b45cb7e6b0bd091018db861c666b7 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Sun, 11 Jan 2026 20:03:52 +0800 Subject: [PATCH 06/17] sync test --- .../tsptest/subclass/SubclassAsyncClient.java | 2 ++ .../java/tsptest/subclass/SubclassClient.java | 2 ++ .../subclass/implementation/SubclassImpl.java | 4 +++ .../models/DuplicateRequiredProperty.java | 33 +++++++++++-------- .../DuplicateRequiredPropertyParent.java | 28 ++++++++++++++-- typespec-tests/tsp/subclass.tsp | 6 +++- 6 files changed, 57 insertions(+), 18 deletions(-) diff --git a/typespec-tests/src/main/java/tsptest/subclass/SubclassAsyncClient.java b/typespec-tests/src/main/java/tsptest/subclass/SubclassAsyncClient.java index 6b4b01bb4d..b1dde9b3e0 100644 --- a/typespec-tests/src/main/java/tsptest/subclass/SubclassAsyncClient.java +++ b/typespec-tests/src/main/java/tsptest/subclass/SubclassAsyncClient.java @@ -46,6 +46,7 @@ public final class SubclassAsyncClient { * {@code * { * duplicateRequiredProperty (Optional): { + * property: String (Required) * duplicateRequiredProperty: String (Required) * } * propertyChangedToRequired (Optional): { @@ -64,6 +65,7 @@ public final class SubclassAsyncClient { * {@code * { * duplicateRequiredProperty (Optional): { + * property: String (Required) * duplicateRequiredProperty: String (Required) * } * propertyChangedToRequired (Optional): { diff --git a/typespec-tests/src/main/java/tsptest/subclass/SubclassClient.java b/typespec-tests/src/main/java/tsptest/subclass/SubclassClient.java index 7dfe8614ef..775c767336 100644 --- a/typespec-tests/src/main/java/tsptest/subclass/SubclassClient.java +++ b/typespec-tests/src/main/java/tsptest/subclass/SubclassClient.java @@ -44,6 +44,7 @@ public final class SubclassClient { * {@code * { * duplicateRequiredProperty (Optional): { + * property: String (Required) * duplicateRequiredProperty: String (Required) * } * propertyChangedToRequired (Optional): { @@ -62,6 +63,7 @@ public final class SubclassClient { * {@code * { * duplicateRequiredProperty (Optional): { + * property: String (Required) * duplicateRequiredProperty: String (Required) * } * propertyChangedToRequired (Optional): { diff --git a/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassImpl.java b/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassImpl.java index 306cb98244..92a552910a 100644 --- a/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassImpl.java +++ b/typespec-tests/src/main/java/tsptest/subclass/implementation/SubclassImpl.java @@ -86,6 +86,7 @@ Response propertyInSubclassSync(@HostParam("endpoint") String endpoi * {@code * { * duplicateRequiredProperty (Optional): { + * property: String (Required) * duplicateRequiredProperty: String (Required) * } * propertyChangedToRequired (Optional): { @@ -104,6 +105,7 @@ Response propertyInSubclassSync(@HostParam("endpoint") String endpoi * {@code * { * duplicateRequiredProperty (Optional): { + * property: String (Required) * duplicateRequiredProperty: String (Required) * } * propertyChangedToRequired (Optional): { @@ -141,6 +143,7 @@ public Mono> propertyInSubclassWithResponseAsync(BinaryData * {@code * { * duplicateRequiredProperty (Optional): { + * property: String (Required) * duplicateRequiredProperty: String (Required) * } * propertyChangedToRequired (Optional): { @@ -159,6 +162,7 @@ public Mono> propertyInSubclassWithResponseAsync(BinaryData * {@code * { * duplicateRequiredProperty (Optional): { + * property: String (Required) * duplicateRequiredProperty: String (Required) * } * propertyChangedToRequired (Optional): { diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredProperty.java b/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredProperty.java index 828f6a0797..0444173953 100644 --- a/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredProperty.java +++ b/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredProperty.java @@ -20,27 +20,28 @@ public final class DuplicateRequiredProperty extends DuplicateRequiredPropertyPa * The duplicateRequiredProperty property. */ @Generated - private final String duplicateRequiredProperty; + private final String newRequiredProperty; /** * Creates an instance of DuplicateRequiredProperty class. * - * @param duplicateRequiredProperty the duplicateRequiredProperty value to set. + * @param requiredProperty the requiredProperty value to set. + * @param newRequiredProperty the newRequiredProperty value to set. */ @Generated - public DuplicateRequiredProperty(String duplicateRequiredProperty) { - super(duplicateRequiredProperty); - this.duplicateRequiredProperty = duplicateRequiredProperty; + public DuplicateRequiredProperty(String requiredProperty, String newRequiredProperty) { + super(requiredProperty, newRequiredProperty); + this.newRequiredProperty = newRequiredProperty; } /** - * Get the duplicateRequiredProperty property: The duplicateRequiredProperty property. + * Get the newRequiredProperty property: The duplicateRequiredProperty property. * - * @return the duplicateRequiredProperty value. + * @return the newRequiredProperty value. */ @Generated - public String getDuplicateRequiredProperty() { - return this.duplicateRequiredProperty; + public String getNewRequiredProperty() { + return this.newRequiredProperty; } /** @@ -50,7 +51,8 @@ public String getDuplicateRequiredProperty() { @Override public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); - jsonWriter.writeStringField("duplicateRequiredProperty", this.duplicateRequiredProperty); + jsonWriter.writeStringField("property", getRequiredProperty()); + jsonWriter.writeStringField("duplicateRequiredProperty", this.newRequiredProperty); return jsonWriter.writeEndObject(); } @@ -66,18 +68,21 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { @Generated public static DuplicateRequiredProperty fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { - String duplicateRequiredProperty = null; + String requiredProperty = null; + String newRequiredProperty = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("duplicateRequiredProperty".equals(fieldName)) { - duplicateRequiredProperty = reader.getString(); + if ("property".equals(fieldName)) { + requiredProperty = reader.getString(); + } else if ("duplicateRequiredProperty".equals(fieldName)) { + newRequiredProperty = reader.getString(); } else { reader.skipChildren(); } } - return new DuplicateRequiredProperty(duplicateRequiredProperty); + return new DuplicateRequiredProperty(requiredProperty, newRequiredProperty); }); } } diff --git a/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredPropertyParent.java b/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredPropertyParent.java index f936a25bb6..14989bc2da 100644 --- a/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredPropertyParent.java +++ b/typespec-tests/src/main/java/tsptest/subclass/models/DuplicateRequiredPropertyParent.java @@ -17,6 +17,12 @@ */ @Immutable public class DuplicateRequiredPropertyParent implements JsonSerializable { + /* + * The property property. + */ + @Generated + private final String requiredProperty; + /* * The duplicateRequiredProperty property. */ @@ -26,13 +32,25 @@ public class DuplicateRequiredPropertyParent implements JsonSerializable { + String requiredProperty = null; String duplicateRequiredProperty = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("duplicateRequiredProperty".equals(fieldName)) { + if ("property".equals(fieldName)) { + requiredProperty = reader.getString(); + } else if ("duplicateRequiredProperty".equals(fieldName)) { duplicateRequiredProperty = reader.getString(); } else { reader.skipChildren(); } } - return new DuplicateRequiredPropertyParent(duplicateRequiredProperty); + return new DuplicateRequiredPropertyParent(requiredProperty, duplicateRequiredProperty); }); } } diff --git a/typespec-tests/tsp/subclass.tsp b/typespec-tests/tsp/subclass.tsp index 8afbf8e9d6..8f76d84f82 100644 --- a/typespec-tests/tsp/subclass.tsp +++ b/typespec-tests/tsp/subclass.tsp @@ -8,10 +8,14 @@ using TypeSpec.Http; namespace TspTest.Subclass; model DuplicateRequiredPropertyParent { + @encodedName("application/json", "property") + requiredProperty: string; + duplicateRequiredProperty: string; } model DuplicateRequiredProperty extends DuplicateRequiredPropertyParent { - duplicateRequiredProperty: string; + @encodedName("application/json", "duplicateRequiredProperty") + newRequiredProperty: string; } model PropertyChangedToRequiredParent { From 7a2f60490e206b2bdc07b573ba6dd0d4c2f74ddb Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 16 Jan 2026 09:14:15 +0800 Subject: [PATCH 07/17] increase sync sdk timeout to 2 hours --- eng/pipelines/post-publish-sdk.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/post-publish-sdk.yaml b/eng/pipelines/post-publish-sdk.yaml index fff2ca3770..5dbf71a92c 100644 --- a/eng/pipelines/post-publish-sdk.yaml +++ b/eng/pipelines/post-publish-sdk.yaml @@ -22,7 +22,7 @@ resources: jobs: - job: Generate_SDK - timeoutInMinutes: 60 + timeoutInMinutes: 120 variables: - template: /eng/pipelines/variables/globals.yml From a45804ede5d12697a28e48a9f74c365003a47650 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 16 Jan 2026 09:16:29 +0800 Subject: [PATCH 08/17] add openai-typespec to emitter for sync to sdk --- typespec-extension/package-lock.json | 152 ++++++++------------------- typespec-extension/package.json | 1 + 2 files changed, 47 insertions(+), 106 deletions(-) diff --git a/typespec-extension/package-lock.json b/typespec-extension/package-lock.json index bf874a41b5..35618c681e 100644 --- a/typespec-extension/package-lock.json +++ b/typespec-extension/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.1", + "@azure-tools/openai-typespec": "^1.6.1", "js-yaml": "~4.1.1", "lodash": "~4.17.21" }, @@ -144,6 +145,16 @@ "node": ">=12.0.0" } }, + "node_modules/@azure-tools/openai-typespec": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@azure-tools/openai-typespec/-/openai-typespec-1.6.1.tgz", + "integrity": "sha512-K9AhZYV3yQymgTBkGAguprHTgXwfojbZu4QnyHy1u0aDpMZmfWbYzex41a8blBTcLDc4wslfHpocIU2bAl7OTQ==", + "license": "MIT", + "peerDependencies": { + "@typespec/http": "*", + "@typespec/openapi": "*" + } + }, "node_modules/@azure-tools/tasks": { "version": "3.0.255", "resolved": "https://registry.npmjs.org/@azure-tools/tasks/-/tasks-3.0.255.tgz", @@ -185,6 +196,7 @@ "integrity": "sha512-BXiHc5oayhMsG1dHFU1aFK/ZQX2Gl0dKB0FAFceapaFV9093J2obbsdhIDR3Tl0qei9g3Ha+iWKZ4KgnLdhv4w==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -200,6 +212,7 @@ "integrity": "sha512-1HwGo3Nt8ksafoPp1rFOopSzgh68SFsyVNCauzjO8ftf0fEqhRXo70OaGwP6wmTZJsLnW7u1DbrBNu6b0z2sOQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "change-case": "~5.4.4", "pluralize": "^8.0.0" @@ -238,6 +251,7 @@ "integrity": "sha512-u1iWLergQmNG/0Wk3wVjCj/Q9cxUlxLGnLhd0hr3H1Wy1xvg7mLRaH+a62J//wvUZYBQsz1XGnm2QnksAzAdzg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "change-case": "~5.4.4", "pluralize": "^8.0.0", @@ -269,7 +283,6 @@ "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", - "dev": true, "license": "MIT", "dependencies": { "@babel/helper-validator-identifier": "^7.27.1", @@ -294,7 +307,6 @@ "version": "7.28.5", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", - "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -1066,7 +1078,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.2.tgz", "integrity": "sha512-SYLX05PwJVnW+WVegZt1T4Ip1qba1ik+pNJPDiqvk6zS5Y/i8PhRzLpGEtVd7sW0G8cMtkD8t4AZYhQwm8vnww==", - "dev": true, "license": "MIT", "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1076,7 +1087,6 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-5.0.2.tgz", "integrity": "sha512-iTPV4tMMct7iOpwer5qmTP7gjnk1VQJjsNfAaC2b8Q3qiuHM3K2yjjDr5u1MKfkrvp2JD4Flf8sIPpF21pmZmw==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^2.0.2", @@ -1100,7 +1110,6 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-6.0.2.tgz", "integrity": "sha512-A0/13Wyi+8iFeNDX6D4zZYKPoBLIEbE4K/219qHcnpXMer2weWvaTo63+2c7mQPPA206DEMSYVOPnEw3meOlCw==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1122,7 +1131,6 @@ "version": "11.0.2", "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-11.0.2.tgz", "integrity": "sha512-lgMRx/n02ciiNELBvFLHtmcjbV5tf5D/I0UYfCg2YbTZWmBZ10/niLd3IjWBxz8LtM27xP+4oLEa06Slmb7p7A==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^2.0.2", @@ -1149,7 +1157,6 @@ "version": "6.2.2", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -1162,7 +1169,6 @@ "version": "6.2.3", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -1175,14 +1181,12 @@ "version": "10.6.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", - "dev": true, "license": "MIT" }, "node_modules/@inquirer/core/node_modules/string-width": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^10.3.0", @@ -1200,7 +1204,6 @@ "version": "7.1.2", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", - "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^6.0.1" @@ -1216,7 +1219,6 @@ "version": "9.0.2", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^6.2.1", @@ -1234,7 +1236,6 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-5.0.2.tgz", "integrity": "sha512-pXQ4Nf0qmFcJuYB6NlcIIxH6l6zKOwNg1Jh/ZRdKd2dTqBB4OXKUFbFwR2K4LVXVtq15ZFFatBVT+rerYR8hWQ==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1257,7 +1258,6 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-5.0.2.tgz", "integrity": "sha512-siFG1swxfjFIOxIcehtZkh+KUNB/YCpyfHNEGu+nC/SBXIbgUWibvThLn/WesSxLRGOeSKdNKoTm+GQCKFm6Ww==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1279,7 +1279,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/@inquirer/external-editor/-/external-editor-2.0.2.tgz", "integrity": "sha512-X/fMXK7vXomRWEex1j8mnj7s1mpnTeP4CO/h2gysJhHLT2WjBnLv4ZQEGpm/kcYI8QfLZ2fgW+9kTKD+jeopLg==", - "dev": true, "license": "MIT", "dependencies": { "chardet": "^2.1.1", @@ -1301,7 +1300,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-2.0.2.tgz", "integrity": "sha512-qXm6EVvQx/FmnSrCWCIGtMHwqeLgxABP8XgcaAoywsL0NFga9gD5kfG0gXiv80GjK9Hsoz4pgGwF/+CjygyV9A==", - "dev": true, "license": "MIT", "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1311,7 +1309,6 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-5.0.2.tgz", "integrity": "sha512-hN2YRo1QiEc9lD3mK+CPnTS4TK2RhCMmMmP4nCWwTkmQL2vx9jPJWYk+rbUZpwR1D583ZJk1FI3i9JZXIpi/qg==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1333,7 +1330,6 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-4.0.2.tgz", "integrity": "sha512-4McnjTSYrlthNW1ojkkmP75WLRYhQs7GXm6pDDoIrHqJuV5uUYwfdbB0geHdaKMarAqJQgoOVjzIT0jdWCsKew==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1355,7 +1351,6 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-5.0.2.tgz", "integrity": "sha512-oSDziMKiw4G2e4zS+0JRfxuPFFGh6N/9yUaluMgEHp2/Yyj2JGwfDO7XbwtOrxVrz+XsP/iaGyWXdQb9d8A0+g==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^2.0.2", @@ -1378,7 +1373,6 @@ "version": "8.0.2", "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-8.0.2.tgz", "integrity": "sha512-2zK5zY48fZcl6+gG4eqOC/UzZsJckHCRvjXoLuW4D8LKOCVGdcJiSKkLnumSZjR/6PXPINDGOrGHqNxb+sxJDg==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/checkbox": "^5.0.2", @@ -1408,7 +1402,6 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-5.0.2.tgz", "integrity": "sha512-AcNALEdQKUQDeJcpC1a3YC53m1MLv+sMUS+vRZ8Qigs1Yg3Dcdtmi82rscJplogKOY8CXkKW4wvVwHS2ZjCIBQ==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1430,7 +1423,6 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-4.0.2.tgz", "integrity": "sha512-hg63w5toohdzE65S3LiGhdfIL0kT+yisbZARf7zw65PvyMUTutTN3eMAvD/B6y/25z88vTrB7kSB45Vz5CbrXg==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1453,7 +1445,6 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-5.0.2.tgz", "integrity": "sha512-JygTohvQxSNnvt7IKANVlg/eds+yN5sLRilYeGc4ri/9Aqi/2QPoXBMV5Cz/L1VtQv63SnTbPXJZeCK2pSwsOA==", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^2.0.2", @@ -1477,7 +1468,6 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-4.0.2.tgz", "integrity": "sha512-cae7mzluplsjSdgFA6ACLygb5jC8alO0UUnFPyu0E7tNRPrL+q/f8VcSXp+cjZQ7l5CMpDpi2G1+IQvkOiL1Lw==", - "dev": true, "license": "MIT", "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1607,7 +1597,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz", "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==", - "dev": true, "license": "ISC", "dependencies": { "minipass": "^7.0.4" @@ -1773,7 +1762,6 @@ }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", - "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.stat": "2.0.5", @@ -1785,7 +1773,6 @@ }, "node_modules/@nodelib/fs.stat": { "version": "2.0.5", - "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -1793,7 +1780,6 @@ }, "node_modules/@nodelib/fs.walk": { "version": "1.2.8", - "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.scandir": "2.1.5", @@ -2372,7 +2358,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz", "integrity": "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -2465,8 +2450,9 @@ "version": "25.0.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.8.tgz", "integrity": "sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg==", - "dev": true, + "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -2536,6 +2522,7 @@ "integrity": "sha512-npiaib8XzbjtzS2N4HlqPvlpxpmZ14FjSJrteZpPxGUaYPlvhzlzUZ4mZyABo0EFrOWnvyd0Xxroq//hKhtAWg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.53.0", "@typescript-eslint/types": "8.53.0", @@ -2764,8 +2751,8 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.8.0.tgz", "integrity": "sha512-FeLb7Q0z6Bh5dDpqtnU2RlWiIWWWF7rujx2xGMta5dcTuIOZ4jbdyz1hVdxk4iM4qadvaSV4ey/qrSuffNoh3w==", - "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "~7.27.1", "@inquirer/prompts": "^8.0.1", @@ -2797,7 +2784,6 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -2810,7 +2796,6 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -2823,7 +2808,6 @@ "version": "9.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", - "dev": true, "license": "ISC", "dependencies": { "string-width": "^7.2.0", @@ -2838,14 +2822,12 @@ "version": "10.4.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", - "dev": true, "license": "MIT" }, "node_modules/@typespec/compiler/node_modules/globby": { "version": "16.0.0", "resolved": "https://registry.npmjs.org/globby/-/globby-16.0.0.tgz", "integrity": "sha512-ejy4TJFga99yW6Q0uhM3pFawKWZmtZzZD/v/GwI5+9bCV5Ew+D2pSND6W7fUes5UykqSsJkUfxFVdRh7Q1+P3Q==", - "dev": true, "license": "MIT", "dependencies": { "@sindresorhus/merge-streams": "^4.0.0", @@ -2866,7 +2848,6 @@ "version": "7.0.5", "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", - "dev": true, "license": "MIT", "engines": { "node": ">= 4" @@ -2876,7 +2857,6 @@ "version": "3.7.4", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz", "integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==", - "dev": true, "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" @@ -2892,7 +2872,6 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", - "dev": true, "license": "MIT", "engines": { "node": ">=14.16" @@ -2905,7 +2884,6 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^10.3.0", @@ -2923,7 +2901,6 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^6.0.1" @@ -2939,7 +2916,6 @@ "version": "9.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz", "integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^6.2.1", @@ -2957,7 +2933,6 @@ "version": "18.0.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.0.0.tgz", "integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==", - "dev": true, "license": "MIT", "dependencies": { "cliui": "^9.0.1", @@ -2975,7 +2950,6 @@ "version": "22.0.0", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", - "dev": true, "license": "ISC", "engines": { "node": "^20.19.0 || ^22.12.0 || >=23" @@ -2987,6 +2961,7 @@ "integrity": "sha512-gSI4rAexxfYyZX0ZqYNRWQyuMb1UeakjAjOeh/2ntmxWCdYc+wSbJjxrxIArsZC+LwzTxq5WpdtD7+7OWzG4yw==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -2998,8 +2973,8 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.8.0.tgz", "integrity": "sha512-ZKa4RISabwL8cUAmE3BkoNmtCYRjerO0+1Ba6XdDJKG+vJC5EGM2hkDf+ZmYsYZgrX0cvbhPXUKKh28zBV60hw==", - "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3017,8 +2992,8 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.8.0.tgz", "integrity": "sha512-v+RIJpx7vALBSGQmnUWemvXjnrk50HAVqJeg0RbaF3VUnh66Z4itsoNJJmIIc+HmBJng8Ie0V7xv3l02ek6HWA==", - "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3033,6 +3008,7 @@ "integrity": "sha512-1clnDw1JbBvjLcfFvEvHdIrnsQuQI5/Cl6mRIrzWWX0pKJ+R89rCdZD1KpidEXw4B4qscD48LsssyrEIFLtuPg==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3047,6 +3023,7 @@ "integrity": "sha512-jPARl+e1e/nsDW/1uVsGTzvKmjqezVMyUa13igXxk5nV2ScMdFpH1HhBwTmAhUeaZgY3J81dFHNUnIY67HCrmw==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3061,8 +3038,9 @@ "version": "0.78.0", "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.78.0.tgz", "integrity": "sha512-wzh5bVdzh+K+pFQFs/EZkVsTH5TQGi12XwhjxJS0UKRwaW2UwSZeY1HqX07oMMPdYESTbjgMrXcxtn89AlzjvQ==", - "dev": true, + "devOptional": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3249,6 +3227,7 @@ "integrity": "sha512-I14X6+IMd0wFMNI8oMFSeFBi2nD4idub+geSO34vuCs4rwuEj3FNzy+rkNkDDvf0+gIUGxeyg7s+YDUcNyiqOA==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3262,6 +3241,7 @@ "integrity": "sha512-KSDhJX6A/Onsu9FKVZtR/xSy5va3k0y9/U4eiZUn91V/LQyMZNwmResPDHEVYk6JqaIH8bbd6ANWPu3nMd7mmw==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3403,6 +3383,7 @@ "integrity": "sha512-hRDjg6dlDz7JlZAvjbiCdAJ3SDG+NH8tjZe21vjxfvT2ssYAn72SRXMge3dKKABm3bIJ3C+3wdunIdur8PHEAw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@vitest/utils": "4.0.17", "fflate": "^0.8.2", @@ -3456,6 +3437,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -3477,7 +3459,7 @@ "version": "8.17.1", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", - "dev": true, + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -3764,7 +3746,6 @@ }, "node_modules/braces": { "version": "3.0.3", - "dev": true, "license": "MIT", "dependencies": { "fill-range": "^7.1.1" @@ -3793,6 +3774,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.19", "caniuse-lite": "^1.0.30001751", @@ -3964,21 +3946,18 @@ }, "node_modules/change-case": { "version": "5.4.4", - "dev": true, "license": "MIT" }, "node_modules/chardet": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/chardet/-/chardet-2.1.1.tgz", "integrity": "sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ==", - "dev": true, "license": "MIT" }, "node_modules/chownr": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==", - "dev": true, "license": "BlueOak-1.0.0", "engines": { "node": ">=18" @@ -4033,7 +4012,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", - "dev": true, "license": "ISC", "engines": { "node": ">= 12" @@ -4228,9 +4206,9 @@ } }, "node_modules/diff": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.2.tgz", - "integrity": "sha512-sSuxWU5j5SR9QQji/o2qMvqRNYRDOcBTgsJ/DeCf4iSN4gW+gNMXM7wFIP+fdXZxoNiAnHUTGjCr+TSWXdRDKg==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.3.tgz", + "integrity": "sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ==", "dev": true, "license": "BSD-3-Clause", "engines": { @@ -4312,7 +4290,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz", "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==", - "dev": true, "license": "MIT", "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" @@ -4523,7 +4500,6 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", - "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -4545,6 +4521,7 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -5144,14 +5121,12 @@ }, "node_modules/fast-deep-equal": { "version": "3.1.3", - "dev": true, "license": "MIT" }, "node_modules/fast-glob": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", - "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -5166,7 +5141,6 @@ }, "node_modules/fast-glob/node_modules/glob-parent": { "version": "5.1.2", - "dev": true, "license": "ISC", "dependencies": { "is-glob": "^4.0.1" @@ -5192,12 +5166,10 @@ "node_modules/fast-uri": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", - "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==", - "dev": true + "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==" }, "node_modules/fastq": { "version": "1.15.0", - "dev": true, "license": "ISC", "dependencies": { "reusify": "^1.0.4" @@ -5225,7 +5197,6 @@ }, "node_modules/fill-range": { "version": "7.1.1", - "dev": true, "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" @@ -5389,7 +5360,6 @@ }, "node_modules/get-caller-file": { "version": "2.0.5", - "dev": true, "license": "ISC", "engines": { "node": "6.* || 8.* || >= 10.*" @@ -5399,7 +5369,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.3.0.tgz", "integrity": "sha512-vpeMIQKxczTD/0s2CdEWHcb0eeJe6TFjxb+J5xgX7hScxqrGuyjmv4c1D4A/gelKfyox0gJJwIHF+fLjeaM8kQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -5712,7 +5681,6 @@ "version": "0.7.1", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.1.tgz", "integrity": "sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw==", - "dev": true, "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" @@ -5951,7 +5919,6 @@ }, "node_modules/is-extglob": { "version": "2.1.1", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -6002,7 +5969,6 @@ }, "node_modules/is-glob": { "version": "4.0.3", - "dev": true, "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" @@ -6039,7 +6005,6 @@ }, "node_modules/is-number": { "version": "7.0.0", - "dev": true, "license": "MIT", "engines": { "node": ">=0.12.0" @@ -6066,7 +6031,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -6178,7 +6142,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -6291,7 +6254,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true, "license": "MIT" }, "node_modules/js-yaml": { @@ -6329,8 +6291,7 @@ "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -6524,7 +6485,6 @@ }, "node_modules/merge2": { "version": "1.4.1", - "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -6534,7 +6494,6 @@ "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", - "dev": true, "license": "MIT", "dependencies": { "braces": "^3.0.3", @@ -6572,7 +6531,6 @@ }, "node_modules/minipass": { "version": "7.1.2", - "dev": true, "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" @@ -6582,7 +6540,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz", "integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==", - "dev": true, "license": "MIT", "dependencies": { "minipass": "^7.1.2" @@ -6609,7 +6566,6 @@ }, "node_modules/mustache": { "version": "4.2.0", - "dev": true, "license": "MIT", "bin": { "mustache": "bin/mustache" @@ -6619,7 +6575,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-3.0.0.tgz", "integrity": "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==", - "dev": true, "license": "ISC", "engines": { "node": "^20.17.0 || >=22.9.0" @@ -6920,12 +6875,10 @@ "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" }, "node_modules/picomatch": { "version": "2.3.1", - "dev": true, "license": "MIT", "engines": { "node": ">=8.6" @@ -7042,7 +6995,6 @@ }, "node_modules/queue-microtask": { "version": "1.2.3", - "dev": true, "funding": [ { "type": "github", @@ -7138,7 +7090,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -7185,7 +7136,6 @@ }, "node_modules/reusify": { "version": "1.0.4", - "dev": true, "license": "MIT", "engines": { "iojs": ">=1.0.0", @@ -7293,7 +7243,6 @@ }, "node_modules/run-parallel": { "version": "1.2.0", - "dev": true, "funding": [ { "type": "github", @@ -7372,7 +7321,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true, "license": "MIT" }, "node_modules/semver": { @@ -7540,7 +7488,6 @@ }, "node_modules/signal-exit": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -7814,7 +7761,6 @@ "version": "7.5.2", "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.2.tgz", "integrity": "sha512-7NyxrTE4Anh8km8iEy7o0QYPs+0JKBTj5ZaqHg6B39erLg0qYXN3BijtShwbsNSvQ+LN75+KV+C4QR/f6Gwnpg==", - "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/fs-minipass": "^4.0.0", @@ -7831,7 +7777,6 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.3.0.tgz", "integrity": "sha512-qNsTkX9K8hi+FHDfHmf22e/OGuXmfBm9RqNismxBrnSmZVJKegQ+HYYXT+R7Ha8F/YSm2Y34vmzD4cxMu2u95g==", - "dev": true, "license": "MIT", "dependencies": { "temporal-spec": "0.3.0" @@ -7841,7 +7786,6 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-0.3.0.tgz", "integrity": "sha512-n+noVpIqz4hYgFSMOSiINNOUOMFtV5cZQNCmmszA6GiVFVRt3G7AqVyhXjhCSmowvQn+NsGn+jMDMKJYHd3bSQ==", - "dev": true, "license": "ISC" }, "node_modules/test-exclude": { @@ -7915,6 +7859,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -7934,7 +7879,6 @@ }, "node_modules/to-regex-range": { "version": "5.0.1", - "dev": true, "license": "MIT", "dependencies": { "is-number": "^7.0.0" @@ -8083,6 +8027,7 @@ "integrity": "sha512-aw45vwtwOl3QkUAmWCnLV9QW1xY+FSX2zzlit4MAfE99wX+Jij4ycnpbAWgBXsRrxmfs9LaYktg/eX5Bpthd3g==", "dev": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@gerrit0/mini-shiki": "^3.9.0", "lunr": "^2.3.9", @@ -8120,6 +8065,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -8182,14 +8128,13 @@ "version": "7.16.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/unicorn-magic": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.4.0.tgz", "integrity": "sha512-wH590V9VNgYH9g3lH9wWjTrUoKsjLF6sGLjhR4sH1LWpLmCOH0Zf7PukhDA8BiS7KHe4oPNkcTHqYkj7SOGUOw==", - "dev": true, "license": "MIT", "engines": { "node": ">=20" @@ -8268,6 +8213,7 @@ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -8361,6 +8307,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -8374,6 +8321,7 @@ "integrity": "sha512-FQMeF0DJdWY0iOnbv466n/0BudNdKj1l5jYgl5JVTwjSsZSlqyXFt/9+1sEyhR6CLowbZpV7O1sCHrzBhucKKg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@vitest/expect": "4.0.17", "@vitest/mocker": "4.0.17", @@ -8461,7 +8409,6 @@ }, "node_modules/vscode-jsonrpc": { "version": "8.2.0", - "dev": true, "license": "MIT", "engines": { "node": ">=14.0.0" @@ -8469,7 +8416,6 @@ }, "node_modules/vscode-languageserver": { "version": "9.0.1", - "dev": true, "license": "MIT", "dependencies": { "vscode-languageserver-protocol": "3.17.5" @@ -8480,7 +8426,6 @@ }, "node_modules/vscode-languageserver-protocol": { "version": "3.17.5", - "dev": true, "license": "MIT", "dependencies": { "vscode-jsonrpc": "8.2.0", @@ -8490,12 +8435,10 @@ "node_modules/vscode-languageserver-textdocument": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", - "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==", - "dev": true + "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==" }, "node_modules/vscode-languageserver-types": { "version": "3.17.5", - "dev": true, "license": "MIT" }, "node_modules/which": { @@ -8663,7 +8606,6 @@ }, "node_modules/y18n": { "version": "5.0.8", - "dev": true, "license": "ISC", "engines": { "node": ">=10" @@ -8673,7 +8615,6 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", - "dev": true, "license": "BlueOak-1.0.0", "engines": { "node": ">=18" @@ -8683,7 +8624,6 @@ "version": "2.8.2", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", - "dev": true, "license": "ISC", "bin": { "yaml": "bin.mjs" diff --git a/typespec-extension/package.json b/typespec-extension/package.json index 71e944158b..96bc1621d0 100644 --- a/typespec-extension/package.json +++ b/typespec-extension/package.json @@ -62,6 +62,7 @@ }, "dependencies": { "@autorest/codemodel": "~4.20.1", + "@azure-tools/openai-typespec": "^1.6.1", "js-yaml": "~4.1.1", "lodash": "~4.17.21" }, From 151d64abb817d6f06b89c21e2c95f9140ae16dbd Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 16 Jan 2026 09:18:22 +0800 Subject: [PATCH 09/17] try ai libs --- eng/sdk/sync_sdk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/sdk/sync_sdk.py b/eng/sdk/sync_sdk.py index 7346e11598..c7b13a0c68 100644 --- a/eng/sdk/sync_sdk.py +++ b/eng/sdk/sync_sdk.py @@ -20,8 +20,8 @@ skip_artifacts: List[str] = [ "azure-ai-anomalydetector", # deprecated # expect failure on below - "azure-ai-projects", # wait for service dev update tsp-location.yaml - "azure-ai-agents-persistent", # tspconfig does not have java + # "azure-ai-projects", # wait for service dev update tsp-location.yaml + # "azure-ai-agents-persistent", # tspconfig does not have java # "azure-developer-devcenter", # 2 breaks introduced into stable api-version # "azure-ai-vision-face", # SDK in development ] From 1f2118c6a08d3be24b41cd8a028984d40400d2d1 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 16 Jan 2026 10:37:12 +0800 Subject: [PATCH 10/17] remove 2 libs --- eng/sdk/sync_sdk.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/eng/sdk/sync_sdk.py b/eng/sdk/sync_sdk.py index c7b13a0c68..7030f0cae7 100644 --- a/eng/sdk/sync_sdk.py +++ b/eng/sdk/sync_sdk.py @@ -20,8 +20,6 @@ skip_artifacts: List[str] = [ "azure-ai-anomalydetector", # deprecated # expect failure on below - # "azure-ai-projects", # wait for service dev update tsp-location.yaml - # "azure-ai-agents-persistent", # tspconfig does not have java # "azure-developer-devcenter", # 2 breaks introduced into stable api-version # "azure-ai-vision-face", # SDK in development ] From 3c5b31d0b640dfebffd4b46e34336e27321ec15c Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Fri, 16 Jan 2026 10:56:28 +0800 Subject: [PATCH 11/17] should be in devDep --- typespec-extension/package-lock.json | 114 +++++++++++++++++++++++++-- typespec-extension/package.json | 3 +- 2 files changed, 108 insertions(+), 9 deletions(-) diff --git a/typespec-extension/package-lock.json b/typespec-extension/package-lock.json index 35618c681e..32a88624f3 100644 --- a/typespec-extension/package-lock.json +++ b/typespec-extension/package-lock.json @@ -10,11 +10,11 @@ "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.1", - "@azure-tools/openai-typespec": "^1.6.1", "js-yaml": "~4.1.1", "lodash": "~4.17.21" }, "devDependencies": { + "@azure-tools/openai-typespec": "^1.6.1", "@azure-tools/typespec-autorest": "0.64.0", "@azure-tools/typespec-azure-core": "0.64.0", "@azure-tools/typespec-azure-resource-manager": "0.64.0", @@ -54,6 +54,7 @@ "node": ">=20.0.0" }, "peerDependencies": { + "@azure-tools/openai-typespec": "^1.6.1", "@azure-tools/typespec-autorest": ">=0.64.0 <1.0.0", "@azure-tools/typespec-azure-core": ">=0.64.0 <1.0.0", "@azure-tools/typespec-azure-resource-manager": ">=0.64.0 <1.0.0", @@ -149,6 +150,7 @@ "version": "1.6.1", "resolved": "https://registry.npmjs.org/@azure-tools/openai-typespec/-/openai-typespec-1.6.1.tgz", "integrity": "sha512-K9AhZYV3yQymgTBkGAguprHTgXwfojbZu4QnyHy1u0aDpMZmfWbYzex41a8blBTcLDc4wslfHpocIU2bAl7OTQ==", + "dev": true, "license": "MIT", "peerDependencies": { "@typespec/http": "*", @@ -283,6 +285,7 @@ "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "dev": true, "license": "MIT", "dependencies": { "@babel/helper-validator-identifier": "^7.27.1", @@ -307,6 +310,7 @@ "version": "7.28.5", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -1078,6 +1082,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.2.tgz", "integrity": "sha512-SYLX05PwJVnW+WVegZt1T4Ip1qba1ik+pNJPDiqvk6zS5Y/i8PhRzLpGEtVd7sW0G8cMtkD8t4AZYhQwm8vnww==", + "dev": true, "license": "MIT", "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1087,6 +1092,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/checkbox/-/checkbox-5.0.2.tgz", "integrity": "sha512-iTPV4tMMct7iOpwer5qmTP7gjnk1VQJjsNfAaC2b8Q3qiuHM3K2yjjDr5u1MKfkrvp2JD4Flf8sIPpF21pmZmw==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^2.0.2", @@ -1110,6 +1116,7 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/@inquirer/confirm/-/confirm-6.0.2.tgz", "integrity": "sha512-A0/13Wyi+8iFeNDX6D4zZYKPoBLIEbE4K/219qHcnpXMer2weWvaTo63+2c7mQPPA206DEMSYVOPnEw3meOlCw==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1131,6 +1138,7 @@ "version": "11.0.2", "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-11.0.2.tgz", "integrity": "sha512-lgMRx/n02ciiNELBvFLHtmcjbV5tf5D/I0UYfCg2YbTZWmBZ10/niLd3IjWBxz8LtM27xP+4oLEa06Slmb7p7A==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^2.0.2", @@ -1157,6 +1165,7 @@ "version": "6.2.2", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -1169,6 +1178,7 @@ "version": "6.2.3", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -1181,12 +1191,14 @@ "version": "10.6.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", + "dev": true, "license": "MIT" }, "node_modules/@inquirer/core/node_modules/string-width": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^10.3.0", @@ -1204,6 +1216,7 @@ "version": "7.1.2", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", + "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^6.0.1" @@ -1219,6 +1232,7 @@ "version": "9.0.2", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^6.2.1", @@ -1236,6 +1250,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/editor/-/editor-5.0.2.tgz", "integrity": "sha512-pXQ4Nf0qmFcJuYB6NlcIIxH6l6zKOwNg1Jh/ZRdKd2dTqBB4OXKUFbFwR2K4LVXVtq15ZFFatBVT+rerYR8hWQ==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1258,6 +1273,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/expand/-/expand-5.0.2.tgz", "integrity": "sha512-siFG1swxfjFIOxIcehtZkh+KUNB/YCpyfHNEGu+nC/SBXIbgUWibvThLn/WesSxLRGOeSKdNKoTm+GQCKFm6Ww==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1279,6 +1295,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/@inquirer/external-editor/-/external-editor-2.0.2.tgz", "integrity": "sha512-X/fMXK7vXomRWEex1j8mnj7s1mpnTeP4CO/h2gysJhHLT2WjBnLv4ZQEGpm/kcYI8QfLZ2fgW+9kTKD+jeopLg==", + "dev": true, "license": "MIT", "dependencies": { "chardet": "^2.1.1", @@ -1300,6 +1317,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/@inquirer/figures/-/figures-2.0.2.tgz", "integrity": "sha512-qXm6EVvQx/FmnSrCWCIGtMHwqeLgxABP8XgcaAoywsL0NFga9gD5kfG0gXiv80GjK9Hsoz4pgGwF/+CjygyV9A==", + "dev": true, "license": "MIT", "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1309,6 +1327,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/input/-/input-5.0.2.tgz", "integrity": "sha512-hN2YRo1QiEc9lD3mK+CPnTS4TK2RhCMmMmP4nCWwTkmQL2vx9jPJWYk+rbUZpwR1D583ZJk1FI3i9JZXIpi/qg==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1330,6 +1349,7 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/@inquirer/number/-/number-4.0.2.tgz", "integrity": "sha512-4McnjTSYrlthNW1ojkkmP75WLRYhQs7GXm6pDDoIrHqJuV5uUYwfdbB0geHdaKMarAqJQgoOVjzIT0jdWCsKew==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1351,6 +1371,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/password/-/password-5.0.2.tgz", "integrity": "sha512-oSDziMKiw4G2e4zS+0JRfxuPFFGh6N/9yUaluMgEHp2/Yyj2JGwfDO7XbwtOrxVrz+XsP/iaGyWXdQb9d8A0+g==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^2.0.2", @@ -1373,6 +1394,7 @@ "version": "8.0.2", "resolved": "https://registry.npmjs.org/@inquirer/prompts/-/prompts-8.0.2.tgz", "integrity": "sha512-2zK5zY48fZcl6+gG4eqOC/UzZsJckHCRvjXoLuW4D8LKOCVGdcJiSKkLnumSZjR/6PXPINDGOrGHqNxb+sxJDg==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/checkbox": "^5.0.2", @@ -1402,6 +1424,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/rawlist/-/rawlist-5.0.2.tgz", "integrity": "sha512-AcNALEdQKUQDeJcpC1a3YC53m1MLv+sMUS+vRZ8Qigs1Yg3Dcdtmi82rscJplogKOY8CXkKW4wvVwHS2ZjCIBQ==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1423,6 +1446,7 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/@inquirer/search/-/search-4.0.2.tgz", "integrity": "sha512-hg63w5toohdzE65S3LiGhdfIL0kT+yisbZARf7zw65PvyMUTutTN3eMAvD/B6y/25z88vTrB7kSB45Vz5CbrXg==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^11.0.2", @@ -1445,6 +1469,7 @@ "version": "5.0.2", "resolved": "https://registry.npmjs.org/@inquirer/select/-/select-5.0.2.tgz", "integrity": "sha512-JygTohvQxSNnvt7IKANVlg/eds+yN5sLRilYeGc4ri/9Aqi/2QPoXBMV5Cz/L1VtQv63SnTbPXJZeCK2pSwsOA==", + "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^2.0.2", @@ -1468,6 +1493,7 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-4.0.2.tgz", "integrity": "sha512-cae7mzluplsjSdgFA6ACLygb5jC8alO0UUnFPyu0E7tNRPrL+q/f8VcSXp+cjZQ7l5CMpDpi2G1+IQvkOiL1Lw==", + "dev": true, "license": "MIT", "engines": { "node": ">=23.5.0 || ^22.13.0 || ^21.7.0 || ^20.12.0" @@ -1597,6 +1623,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz", "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==", + "dev": true, "license": "ISC", "dependencies": { "minipass": "^7.0.4" @@ -1762,6 +1789,7 @@ }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.stat": "2.0.5", @@ -1773,6 +1801,7 @@ }, "node_modules/@nodelib/fs.stat": { "version": "2.0.5", + "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -1780,6 +1809,7 @@ }, "node_modules/@nodelib/fs.walk": { "version": "1.2.8", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.scandir": "2.1.5", @@ -2358,6 +2388,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz", "integrity": "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -2450,7 +2481,7 @@ "version": "25.0.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.8.tgz", "integrity": "sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg==", - "devOptional": true, + "dev": true, "license": "MIT", "peer": true, "dependencies": { @@ -2751,6 +2782,7 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.8.0.tgz", "integrity": "sha512-FeLb7Q0z6Bh5dDpqtnU2RlWiIWWWF7rujx2xGMta5dcTuIOZ4jbdyz1hVdxk4iM4qadvaSV4ey/qrSuffNoh3w==", + "dev": true, "license": "MIT", "peer": true, "dependencies": { @@ -2784,6 +2816,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -2796,6 +2829,7 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -2808,6 +2842,7 @@ "version": "9.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", + "dev": true, "license": "ISC", "dependencies": { "string-width": "^7.2.0", @@ -2822,12 +2857,14 @@ "version": "10.4.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", + "dev": true, "license": "MIT" }, "node_modules/@typespec/compiler/node_modules/globby": { "version": "16.0.0", "resolved": "https://registry.npmjs.org/globby/-/globby-16.0.0.tgz", "integrity": "sha512-ejy4TJFga99yW6Q0uhM3pFawKWZmtZzZD/v/GwI5+9bCV5Ew+D2pSND6W7fUes5UykqSsJkUfxFVdRh7Q1+P3Q==", + "dev": true, "license": "MIT", "dependencies": { "@sindresorhus/merge-streams": "^4.0.0", @@ -2848,6 +2885,7 @@ "version": "7.0.5", "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 4" @@ -2857,6 +2895,7 @@ "version": "3.7.4", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz", "integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==", + "dev": true, "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" @@ -2872,6 +2911,7 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", + "dev": true, "license": "MIT", "engines": { "node": ">=14.16" @@ -2884,6 +2924,7 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, "license": "MIT", "dependencies": { "emoji-regex": "^10.3.0", @@ -2901,6 +2942,7 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^6.0.1" @@ -2916,6 +2958,7 @@ "version": "9.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz", "integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^6.2.1", @@ -2933,6 +2976,7 @@ "version": "18.0.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.0.0.tgz", "integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==", + "dev": true, "license": "MIT", "dependencies": { "cliui": "^9.0.1", @@ -2950,6 +2994,7 @@ "version": "22.0.0", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", + "dev": true, "license": "ISC", "engines": { "node": "^20.19.0 || ^22.12.0 || >=23" @@ -2973,6 +3018,7 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.8.0.tgz", "integrity": "sha512-ZKa4RISabwL8cUAmE3BkoNmtCYRjerO0+1Ba6XdDJKG+vJC5EGM2hkDf+ZmYsYZgrX0cvbhPXUKKh28zBV60hw==", + "dev": true, "license": "MIT", "peer": true, "engines": { @@ -2992,6 +3038,7 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.8.0.tgz", "integrity": "sha512-v+RIJpx7vALBSGQmnUWemvXjnrk50HAVqJeg0RbaF3VUnh66Z4itsoNJJmIIc+HmBJng8Ie0V7xv3l02ek6HWA==", + "dev": true, "license": "MIT", "peer": true, "engines": { @@ -3038,7 +3085,7 @@ "version": "0.78.0", "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.78.0.tgz", "integrity": "sha512-wzh5bVdzh+K+pFQFs/EZkVsTH5TQGi12XwhjxJS0UKRwaW2UwSZeY1HqX07oMMPdYESTbjgMrXcxtn89AlzjvQ==", - "devOptional": true, + "dev": true, "license": "MIT", "peer": true, "engines": { @@ -3459,6 +3506,7 @@ "version": "8.17.1", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "dev": true, "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", @@ -3746,6 +3794,7 @@ }, "node_modules/braces": { "version": "3.0.3", + "dev": true, "license": "MIT", "dependencies": { "fill-range": "^7.1.1" @@ -3946,18 +3995,21 @@ }, "node_modules/change-case": { "version": "5.4.4", + "dev": true, "license": "MIT" }, "node_modules/chardet": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/chardet/-/chardet-2.1.1.tgz", "integrity": "sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ==", + "dev": true, "license": "MIT" }, "node_modules/chownr": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==", + "dev": true, "license": "BlueOak-1.0.0", "engines": { "node": ">=18" @@ -4012,6 +4064,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "dev": true, "license": "ISC", "engines": { "node": ">= 12" @@ -4290,6 +4343,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz", "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==", + "dev": true, "license": "MIT", "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" @@ -4500,6 +4554,7 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -5121,12 +5176,14 @@ }, "node_modules/fast-deep-equal": { "version": "3.1.3", + "dev": true, "license": "MIT" }, "node_modules/fast-glob": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -5141,6 +5198,7 @@ }, "node_modules/fast-glob/node_modules/glob-parent": { "version": "5.1.2", + "dev": true, "license": "ISC", "dependencies": { "is-glob": "^4.0.1" @@ -5166,10 +5224,12 @@ "node_modules/fast-uri": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", - "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==" + "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==", + "dev": true }, "node_modules/fastq": { "version": "1.15.0", + "dev": true, "license": "ISC", "dependencies": { "reusify": "^1.0.4" @@ -5197,6 +5257,7 @@ }, "node_modules/fill-range": { "version": "7.1.1", + "dev": true, "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" @@ -5360,6 +5421,7 @@ }, "node_modules/get-caller-file": { "version": "2.0.5", + "dev": true, "license": "ISC", "engines": { "node": "6.* || 8.* || >= 10.*" @@ -5369,6 +5431,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.3.0.tgz", "integrity": "sha512-vpeMIQKxczTD/0s2CdEWHcb0eeJe6TFjxb+J5xgX7hScxqrGuyjmv4c1D4A/gelKfyox0gJJwIHF+fLjeaM8kQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -5681,6 +5744,7 @@ "version": "0.7.1", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.1.tgz", "integrity": "sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw==", + "dev": true, "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" @@ -5919,6 +5983,7 @@ }, "node_modules/is-extglob": { "version": "2.1.1", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -5969,6 +6034,7 @@ }, "node_modules/is-glob": { "version": "4.0.3", + "dev": true, "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" @@ -6005,6 +6071,7 @@ }, "node_modules/is-number": { "version": "7.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=0.12.0" @@ -6031,6 +6098,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -6142,6 +6210,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -6254,6 +6323,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, "license": "MIT" }, "node_modules/js-yaml": { @@ -6291,7 +6361,8 @@ "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -6485,6 +6556,7 @@ }, "node_modules/merge2": { "version": "1.4.1", + "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -6494,6 +6566,7 @@ "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, "license": "MIT", "dependencies": { "braces": "^3.0.3", @@ -6531,6 +6604,7 @@ }, "node_modules/minipass": { "version": "7.1.2", + "dev": true, "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" @@ -6540,6 +6614,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz", "integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==", + "dev": true, "license": "MIT", "dependencies": { "minipass": "^7.1.2" @@ -6566,6 +6641,7 @@ }, "node_modules/mustache": { "version": "4.2.0", + "dev": true, "license": "MIT", "bin": { "mustache": "bin/mustache" @@ -6575,6 +6651,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-3.0.0.tgz", "integrity": "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==", + "dev": true, "license": "ISC", "engines": { "node": "^20.17.0 || >=22.9.0" @@ -6875,10 +6952,12 @@ "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true }, "node_modules/picomatch": { "version": "2.3.1", + "dev": true, "license": "MIT", "engines": { "node": ">=8.6" @@ -6995,6 +7074,7 @@ }, "node_modules/queue-microtask": { "version": "1.2.3", + "dev": true, "funding": [ { "type": "github", @@ -7090,6 +7170,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -7136,6 +7217,7 @@ }, "node_modules/reusify": { "version": "1.0.4", + "dev": true, "license": "MIT", "engines": { "iojs": ">=1.0.0", @@ -7243,6 +7325,7 @@ }, "node_modules/run-parallel": { "version": "1.2.0", + "dev": true, "funding": [ { "type": "github", @@ -7321,6 +7404,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, "license": "MIT" }, "node_modules/semver": { @@ -7488,6 +7572,7 @@ }, "node_modules/signal-exit": { "version": "4.1.0", + "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -7761,6 +7846,7 @@ "version": "7.5.2", "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.2.tgz", "integrity": "sha512-7NyxrTE4Anh8km8iEy7o0QYPs+0JKBTj5ZaqHg6B39erLg0qYXN3BijtShwbsNSvQ+LN75+KV+C4QR/f6Gwnpg==", + "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/fs-minipass": "^4.0.0", @@ -7777,6 +7863,7 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.3.0.tgz", "integrity": "sha512-qNsTkX9K8hi+FHDfHmf22e/OGuXmfBm9RqNismxBrnSmZVJKegQ+HYYXT+R7Ha8F/YSm2Y34vmzD4cxMu2u95g==", + "dev": true, "license": "MIT", "dependencies": { "temporal-spec": "0.3.0" @@ -7786,6 +7873,7 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-0.3.0.tgz", "integrity": "sha512-n+noVpIqz4hYgFSMOSiINNOUOMFtV5cZQNCmmszA6GiVFVRt3G7AqVyhXjhCSmowvQn+NsGn+jMDMKJYHd3bSQ==", + "dev": true, "license": "ISC" }, "node_modules/test-exclude": { @@ -7879,6 +7967,7 @@ }, "node_modules/to-regex-range": { "version": "5.0.1", + "dev": true, "license": "MIT", "dependencies": { "is-number": "^7.0.0" @@ -8128,13 +8217,14 @@ "version": "7.16.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/unicorn-magic": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.4.0.tgz", "integrity": "sha512-wH590V9VNgYH9g3lH9wWjTrUoKsjLF6sGLjhR4sH1LWpLmCOH0Zf7PukhDA8BiS7KHe4oPNkcTHqYkj7SOGUOw==", + "dev": true, "license": "MIT", "engines": { "node": ">=20" @@ -8409,6 +8499,7 @@ }, "node_modules/vscode-jsonrpc": { "version": "8.2.0", + "dev": true, "license": "MIT", "engines": { "node": ">=14.0.0" @@ -8416,6 +8507,7 @@ }, "node_modules/vscode-languageserver": { "version": "9.0.1", + "dev": true, "license": "MIT", "dependencies": { "vscode-languageserver-protocol": "3.17.5" @@ -8426,6 +8518,7 @@ }, "node_modules/vscode-languageserver-protocol": { "version": "3.17.5", + "dev": true, "license": "MIT", "dependencies": { "vscode-jsonrpc": "8.2.0", @@ -8435,10 +8528,12 @@ "node_modules/vscode-languageserver-textdocument": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", - "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==" + "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==", + "dev": true }, "node_modules/vscode-languageserver-types": { "version": "3.17.5", + "dev": true, "license": "MIT" }, "node_modules/which": { @@ -8606,6 +8701,7 @@ }, "node_modules/y18n": { "version": "5.0.8", + "dev": true, "license": "ISC", "engines": { "node": ">=10" @@ -8615,6 +8711,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "dev": true, "license": "BlueOak-1.0.0", "engines": { "node": ">=18" @@ -8624,6 +8721,7 @@ "version": "2.8.2", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", + "dev": true, "license": "ISC", "bin": { "yaml": "bin.mjs" diff --git a/typespec-extension/package.json b/typespec-extension/package.json index 96bc1621d0..d2a7db8957 100644 --- a/typespec-extension/package.json +++ b/typespec-extension/package.json @@ -53,6 +53,7 @@ "@azure-tools/typespec-azure-rulesets": ">=0.64.0 <1.0.0", "@azure-tools/typespec-client-generator-core": ">=0.64.1 <1.0.0", "@azure-tools/typespec-liftr-base": ">=0.11.0 <1.0.0", + "@azure-tools/openai-typespec": "^1.6.1", "@typespec/compiler": "^1.8.0", "@typespec/http": "^1.8.0", "@typespec/openapi": "^1.8.0", @@ -62,7 +63,6 @@ }, "dependencies": { "@autorest/codemodel": "~4.20.1", - "@azure-tools/openai-typespec": "^1.6.1", "js-yaml": "~4.1.1", "lodash": "~4.17.21" }, @@ -73,6 +73,7 @@ "@azure-tools/typespec-azure-rulesets": "0.64.0", "@azure-tools/typespec-client-generator-core": "0.64.1", "@azure-tools/typespec-liftr-base": "0.11.0", + "@azure-tools/openai-typespec": "^1.6.1", "@microsoft/api-extractor": "^7.55.2", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.23", From fde03620b5b90dc853678d50da4d0fb9845f84e7 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 19 Jan 2026 13:06:51 +0800 Subject: [PATCH 12/17] chore(typespec): update deps and version --- typespec-extension/changelog.md | 7 ++++++ typespec-extension/package-lock.json | 37 +++++++++++++++++++++++----- typespec-extension/package.json | 4 +-- typespec-tests/Generate.ps1 | 25 ++++++++++++++++--- typespec-tests/package.json | 2 +- 5 files changed, 62 insertions(+), 13 deletions(-) diff --git a/typespec-extension/changelog.md b/typespec-extension/changelog.md index e36789d730..494293313c 100644 --- a/typespec-extension/changelog.md +++ b/typespec-extension/changelog.md @@ -1,5 +1,12 @@ # Release History +## 0.38.4 (2026-01-19) + +Compatible with compiler 1.8.0. + +- Updated package dependencies to the latest versions. +- Synced generator test harness to include multi-service client metadata updates. + ## 0.38.3 (2026-01-15) Compatible with compiler 1.8.0. diff --git a/typespec-extension/package-lock.json b/typespec-extension/package-lock.json index 4598ef2bab..7e0f97a702 100644 --- a/typespec-extension/package-lock.json +++ b/typespec-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "@azure-tools/typespec-java", - "version": "0.38.3", + "version": "0.38.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@azure-tools/typespec-java", - "version": "0.38.3", + "version": "0.38.4", "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.1", @@ -23,7 +23,7 @@ "@microsoft/api-extractor": "^7.55.2", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.23", - "@types/node": "~25.0.8", + "@types/node": "~25.0.9", "@typescript-eslint/eslint-plugin": "~8.53.0", "@typescript-eslint/parser": "~8.53.0", "@typespec/compiler": "1.8.0", @@ -185,6 +185,7 @@ "integrity": "sha512-BXiHc5oayhMsG1dHFU1aFK/ZQX2Gl0dKB0FAFceapaFV9093J2obbsdhIDR3Tl0qei9g3Ha+iWKZ4KgnLdhv4w==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -200,6 +201,7 @@ "integrity": "sha512-1HwGo3Nt8ksafoPp1rFOopSzgh68SFsyVNCauzjO8ftf0fEqhRXo70OaGwP6wmTZJsLnW7u1DbrBNu6b0z2sOQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "change-case": "~5.4.4", "pluralize": "^8.0.0" @@ -238,6 +240,7 @@ "integrity": "sha512-u1iWLergQmNG/0Wk3wVjCj/Q9cxUlxLGnLhd0hr3H1Wy1xvg7mLRaH+a62J//wvUZYBQsz1XGnm2QnksAzAdzg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "change-case": "~5.4.4", "pluralize": "^8.0.0", @@ -2462,11 +2465,12 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "25.0.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.8.tgz", - "integrity": "sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg==", + "version": "25.0.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.9.tgz", + "integrity": "sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -2536,6 +2540,7 @@ "integrity": "sha512-npiaib8XzbjtzS2N4HlqPvlpxpmZ14FjSJrteZpPxGUaYPlvhzlzUZ4mZyABo0EFrOWnvyd0Xxroq//hKhtAWg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.53.0", "@typescript-eslint/types": "8.53.0", @@ -2766,6 +2771,7 @@ "integrity": "sha512-FeLb7Q0z6Bh5dDpqtnU2RlWiIWWWF7rujx2xGMta5dcTuIOZ4jbdyz1hVdxk4iM4qadvaSV4ey/qrSuffNoh3w==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "~7.27.1", "@inquirer/prompts": "^8.0.1", @@ -2987,6 +2993,7 @@ "integrity": "sha512-gSI4rAexxfYyZX0ZqYNRWQyuMb1UeakjAjOeh/2ntmxWCdYc+wSbJjxrxIArsZC+LwzTxq5WpdtD7+7OWzG4yw==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3000,6 +3007,7 @@ "integrity": "sha512-ZKa4RISabwL8cUAmE3BkoNmtCYRjerO0+1Ba6XdDJKG+vJC5EGM2hkDf+ZmYsYZgrX0cvbhPXUKKh28zBV60hw==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3019,6 +3027,7 @@ "integrity": "sha512-v+RIJpx7vALBSGQmnUWemvXjnrk50HAVqJeg0RbaF3VUnh66Z4itsoNJJmIIc+HmBJng8Ie0V7xv3l02ek6HWA==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3033,6 +3042,7 @@ "integrity": "sha512-1clnDw1JbBvjLcfFvEvHdIrnsQuQI5/Cl6mRIrzWWX0pKJ+R89rCdZD1KpidEXw4B4qscD48LsssyrEIFLtuPg==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3047,6 +3057,7 @@ "integrity": "sha512-jPARl+e1e/nsDW/1uVsGTzvKmjqezVMyUa13igXxk5nV2ScMdFpH1HhBwTmAhUeaZgY3J81dFHNUnIY67HCrmw==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3063,6 +3074,7 @@ "integrity": "sha512-wzh5bVdzh+K+pFQFs/EZkVsTH5TQGi12XwhjxJS0UKRwaW2UwSZeY1HqX07oMMPdYESTbjgMrXcxtn89AlzjvQ==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3249,6 +3261,7 @@ "integrity": "sha512-I14X6+IMd0wFMNI8oMFSeFBi2nD4idub+geSO34vuCs4rwuEj3FNzy+rkNkDDvf0+gIUGxeyg7s+YDUcNyiqOA==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3262,6 +3275,7 @@ "integrity": "sha512-KSDhJX6A/Onsu9FKVZtR/xSy5va3k0y9/U4eiZUn91V/LQyMZNwmResPDHEVYk6JqaIH8bbd6ANWPu3nMd7mmw==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=20.0.0" }, @@ -3403,6 +3417,7 @@ "integrity": "sha512-hRDjg6dlDz7JlZAvjbiCdAJ3SDG+NH8tjZe21vjxfvT2ssYAn72SRXMge3dKKABm3bIJ3C+3wdunIdur8PHEAw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@vitest/utils": "4.0.17", "fflate": "^0.8.2", @@ -3456,6 +3471,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -3478,6 +3494,7 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -3793,6 +3810,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.19", "caniuse-lite": "^1.0.30001751", @@ -4545,6 +4563,7 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -7915,6 +7934,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -8083,6 +8103,7 @@ "integrity": "sha512-aw45vwtwOl3QkUAmWCnLV9QW1xY+FSX2zzlit4MAfE99wX+Jij4ycnpbAWgBXsRrxmfs9LaYktg/eX5Bpthd3g==", "dev": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@gerrit0/mini-shiki": "^3.9.0", "lunr": "^2.3.9", @@ -8120,6 +8141,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -8268,6 +8290,7 @@ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -8361,6 +8384,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -8374,6 +8398,7 @@ "integrity": "sha512-FQMeF0DJdWY0iOnbv466n/0BudNdKj1l5jYgl5JVTwjSsZSlqyXFt/9+1sEyhR6CLowbZpV7O1sCHrzBhucKKg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@vitest/expect": "4.0.17", "@vitest/mocker": "4.0.17", diff --git a/typespec-extension/package.json b/typespec-extension/package.json index 71e944158b..8240331db2 100644 --- a/typespec-extension/package.json +++ b/typespec-extension/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/typespec-java", - "version": "0.38.3", + "version": "0.38.4", "description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding", "keywords": [ "TypeSpec" @@ -75,7 +75,7 @@ "@microsoft/api-extractor": "^7.55.2", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.23", - "@types/node": "~25.0.8", + "@types/node": "~25.0.9", "@typescript-eslint/eslint-plugin": "~8.53.0", "@typescript-eslint/parser": "~8.53.0", "@typespec/compiler": "1.8.0", diff --git a/typespec-tests/Generate.ps1 b/typespec-tests/Generate.ps1 index f056594536..70105be8ac 100644 --- a/typespec-tests/Generate.ps1 +++ b/typespec-tests/Generate.ps1 @@ -62,6 +62,10 @@ $generateScript = { } elseif ($tspFile -match "azure[\\/]resource-manager[\\/].*[\\/]main\.tsp") { # for mgmt, do not generate tests due to random mock values $tspOptions += " --option ""@azure-tools/typespec-java.generate-tests=false""" + } elseif ($tspFile -match "azure[\\/]resource-manager[\\/]multi-service-older-versions[\\/]") { + $tspOptions += " --option ""@azure-tools/typespec-java.metadata-suffix=older-versions""" + } elseif ($tspFile -match "azure[\\/]resource-manager[\\/]multi-service-shared-models[\\/]") { + $tspOptions += " --option ""@azure-tools/typespec-java.metadata-suffix=shared-models""" } elseif ($tspFile -match "tsp[\\/]versioning.tsp") { # test generating from specific api-version $tspOptions += " --option ""@azure-tools/typespec-java.api-version=2022-09-01""" @@ -194,10 +198,17 @@ try { Remove-Item ./specs/payload/xml -Recurse -Force $specFiles = Get-ChildItem ./specs -Include "main.tsp","old.tsp" -File -Recurse - $multiServiceSpec = Join-Path ./specs "azure/resource-manager/multi-service/client.tsp" - if (Test-Path $multiServiceSpec) { - # ensure multi-service client specs are processed even though they do not match the default filter - $specFiles += Get-Item $multiServiceSpec + $multiServiceSpecs = @( + "azure/resource-manager/multi-service/client.tsp", + "azure/resource-manager/multi-service-older-versions/client.tsp", + "azure/resource-manager/multi-service-shared-models/client.tsp" + ) + foreach ($multiServiceSpec in $multiServiceSpecs) { + $multiServicePath = Join-Path ./specs $multiServiceSpec + if (Test-Path $multiServicePath) { + # ensure multi-service client specs are processed even though they do not match the default filter + $specFiles += Get-Item $multiServicePath + } } $job = $specFiles | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob @@ -211,6 +222,12 @@ try { Remove-Item ./tsp-output -Recurse -Force + $clientStructureMetadataPath = Join-Path ./src/main/resources/META-INF "client-structure-service_metadata.json" + if (Test-Path $clientStructureMetadataPath) { + # avoid nondeterminism when multiple client.tsp files contribute metadata + Remove-Item $clientStructureMetadataPath -Force + } + if ($ExitCode -ne 0) { throw "Failed to generate from tsp" } diff --git a/typespec-tests/package.json b/typespec-tests/package.json index f9b350dcef..1b98451c00 100644 --- a/typespec-tests/package.json +++ b/typespec-tests/package.json @@ -13,7 +13,7 @@ "@typespec/spector": "0.1.0-alpha.22", "@typespec/http-specs": "0.1.0-alpha.31", "@azure-tools/azure-http-specs": "0.1.0-alpha.36", - "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.38.3.tgz" + "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.38.4.tgz" }, "devDependencies": { "@typespec/prettier-plugin-typespec": "^1.8.0", From 485fbc5c6ec0353f282a6bf1c4b4bda03ed8876b Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 19 Jan 2026 13:07:57 +0800 Subject: [PATCH 13/17] nit on Generate.ps1 --- typespec-tests/Generate.ps1 | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/typespec-tests/Generate.ps1 b/typespec-tests/Generate.ps1 index 70105be8ac..0fa9fb23d0 100644 --- a/typespec-tests/Generate.ps1 +++ b/typespec-tests/Generate.ps1 @@ -198,18 +198,10 @@ try { Remove-Item ./specs/payload/xml -Recurse -Force $specFiles = Get-ChildItem ./specs -Include "main.tsp","old.tsp" -File -Recurse - $multiServiceSpecs = @( - "azure/resource-manager/multi-service/client.tsp", - "azure/resource-manager/multi-service-older-versions/client.tsp", - "azure/resource-manager/multi-service-shared-models/client.tsp" - ) - foreach ($multiServiceSpec in $multiServiceSpecs) { - $multiServicePath = Join-Path ./specs $multiServiceSpec - if (Test-Path $multiServicePath) { - # ensure multi-service client specs are processed even though they do not match the default filter - $specFiles += Get-Item $multiServicePath - } - } + # ensure multi-service client specs are processed even though they do not match the default filter + $specFiles += Get-Item (Join-Path ./specs "azure/resource-manager/multi-service/client.tsp") + $specFiles += Get-Item (Join-Path ./specs "azure/resource-manager/multi-service-older-versions/client.tsp") + $specFiles += Get-Item (Join-Path ./specs "azure/resource-manager/multi-service-shared-models/client.tsp") $job = $specFiles | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob From f1dab107e95c8d925c195404781c708a3fdffd3f Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 19 Jan 2026 13:10:41 +0800 Subject: [PATCH 14/17] sync test --- .../combined/CombinedManager.java | 298 +++++++++++++++ .../combined/fluent/Combined.java | 55 +++ .../combined/fluent/DisksClient.java | 105 +++++ .../fluent/VirtualMachinesClient.java | 111 ++++++ .../combined/fluent/models/DiskInner.java | 181 +++++++++ .../fluent/models/VirtualMachineInner.java | 181 +++++++++ .../combined/fluent/models/package-info.java | 9 + .../combined/fluent/package-info.java | 9 + .../implementation/CombinedBuilder.java | 138 +++++++ .../combined/implementation/CombinedImpl.java | 309 +++++++++++++++ .../combined/implementation/DiskImpl.java | 164 ++++++++ .../implementation/DisksClientImpl.java | 345 +++++++++++++++++ .../combined/implementation/DisksImpl.java | 88 +++++ .../implementation/ResourceManagerUtils.java | 195 ++++++++++ .../implementation/VirtualMachineImpl.java | 165 ++++++++ .../VirtualMachinesClientImpl.java | 361 ++++++++++++++++++ .../implementation/VirtualMachinesImpl.java | 89 +++++ .../combined/implementation/package-info.java | 9 + .../combined/models/Disk.java | 265 +++++++++++++ .../combined/models/DiskProperties.java | 102 +++++ .../combined/models/Disks.java | 69 ++++ .../models/ResourceProvisioningState.java | 56 +++ .../combined/models/VirtualMachine.java | 265 +++++++++++++ .../models/VirtualMachineProperties.java | 102 +++++ .../combined/models/VirtualMachines.java | 69 ++++ .../combined/models/package-info.java | 9 + .../combined/package-info.java | 9 + .../combined/CombinedManager.java | 298 +++++++++++++++ .../combined/fluent/Combined.java | 55 +++ .../fluent/StorageAccountsClient.java | 107 ++++++ .../fluent/VirtualMachinesClient.java | 111 ++++++ .../fluent/models/StorageAccountInner.java | 181 +++++++++ .../fluent/models/VirtualMachineInner.java | 181 +++++++++ .../combined/fluent/models/package-info.java | 9 + .../combined/fluent/package-info.java | 9 + .../implementation/CombinedBuilder.java | 138 +++++++ .../combined/implementation/CombinedImpl.java | 309 +++++++++++++++ .../implementation/ResourceManagerUtils.java | 195 ++++++++++ .../implementation/StorageAccountImpl.java | 165 ++++++++ .../StorageAccountsClientImpl.java | 353 +++++++++++++++++ .../implementation/StorageAccountsImpl.java | 89 +++++ .../implementation/VirtualMachineImpl.java | 165 ++++++++ .../VirtualMachinesClientImpl.java | 361 ++++++++++++++++++ .../implementation/VirtualMachinesImpl.java | 89 +++++ .../combined/implementation/package-info.java | 9 + .../models/ResourceProvisioningState.java | 56 +++ .../combined/models/SharedMetadata.java | 148 +++++++ .../combined/models/StorageAccount.java | 265 +++++++++++++ .../models/StorageAccountProperties.java | 102 +++++ .../combined/models/StorageAccounts.java | 70 ++++ .../combined/models/VirtualMachine.java | 265 +++++++++++++ .../models/VirtualMachineProperties.java | 102 +++++ .../combined/models/VirtualMachines.java | 69 ++++ .../combined/models/package-info.java | 9 + .../combined/package-info.java | 9 + ...ted_apiview_properties_older-versions.json | 22 ++ ...ated_apiview_properties_shared-models.json | 23 ++ ...ned-generated_metadata_older-versions.json | 1 + ...ined-generated_metadata_shared-models.json | 1 + .../proxy-config.json | 1 + .../reflect-config.json | 1 + .../proxy-config.json | 1 + .../reflect-config.json | 1 + .../ArmMultiServiceOlderVersionsTests.java | 39 ++ .../combined/generated/DiskInnerTests.java | 47 +++ .../generated/DiskPropertiesTests.java | 25 ++ .../generated/VirtualMachineInnerTests.java | 47 +++ .../VirtualMachinePropertiesTests.java | 26 ++ .../ArmMultiServiceSharedModelsTests.java | 53 +++ .../generated/SharedMetadataTests.java | 47 +++ .../generated/StorageAccountInnerTests.java | 58 +++ .../StorageAccountPropertiesTests.java | 49 +++ .../generated/VirtualMachineInnerTests.java | 60 +++ .../VirtualMachinePropertiesTests.java | 49 +++ 74 files changed, 8228 insertions(+) create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/CombinedManager.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/Combined.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/DisksClient.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/VirtualMachinesClient.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/DiskInner.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/VirtualMachineInner.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/package-info.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/package-info.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedBuilder.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DiskImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksClientImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/ResourceManagerUtils.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachineImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesClientImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/package-info.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disk.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/DiskProperties.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disks.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/ResourceProvisioningState.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachine.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachineProperties.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachines.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/package-info.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/package-info.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/CombinedManager.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/Combined.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/StorageAccountsClient.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/VirtualMachinesClient.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/StorageAccountInner.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/VirtualMachineInner.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/package-info.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/package-info.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedBuilder.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/ResourceManagerUtils.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsClientImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachineImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesClientImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesImpl.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/package-info.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/ResourceProvisioningState.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/SharedMetadata.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccount.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccountProperties.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccounts.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachine.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachineProperties.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachines.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/package-info.java create mode 100644 typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/package-info.java create mode 100644 typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_apiview_properties_older-versions.json create mode 100644 typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_apiview_properties_shared-models.json create mode 100644 typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_metadata_older-versions.json create mode 100644 typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_metadata_shared-models.json create mode 100644 typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_older-versions/proxy-config.json create mode 100644 typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_older-versions/reflect-config.json create mode 100644 typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_shared-models/proxy-config.json create mode 100644 typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_shared-models/reflect-config.json create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/ArmMultiServiceOlderVersionsTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/DiskInnerTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/DiskPropertiesTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/VirtualMachineInnerTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/VirtualMachinePropertiesTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/ArmMultiServiceSharedModelsTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/SharedMetadataTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/StorageAccountInnerTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/StorageAccountPropertiesTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/VirtualMachineInnerTests.java create mode 100644 typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/VirtualMachinePropertiesTests.java diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/CombinedManager.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/CombinedManager.java new file mode 100644 index 0000000000..d24968bd14 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/CombinedManager.java @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.Combined; +import azure.resourcemanager.multiserviceolderversions.combined.implementation.CombinedBuilder; +import azure.resourcemanager.multiserviceolderversions.combined.implementation.DisksImpl; +import azure.resourcemanager.multiserviceolderversions.combined.implementation.VirtualMachinesImpl; +import azure.resourcemanager.multiserviceolderversions.combined.models.Disks; +import azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachines; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to CombinedManager. + * Compute Client. + */ +public final class CombinedManager { + private VirtualMachines virtualMachines; + + private Disks disks; + + private final Combined clientObject; + + private CombinedManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new CombinedBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of combined service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the combined service API instance. + */ + public static CombinedManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of combined service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the combined service API instance. + */ + public static CombinedManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new CombinedManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create CombinedManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new CombinedManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-combined-generated.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of combined service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the combined service API instance. + */ + public CombinedManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("azure.resourcemanager.multiserviceolderversions.combined") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new CombinedManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of VirtualMachines. It manages VirtualMachine. + * + * @return Resource collection API of VirtualMachines. + */ + public VirtualMachines virtualMachines() { + if (this.virtualMachines == null) { + this.virtualMachines = new VirtualMachinesImpl(clientObject.getVirtualMachines(), this); + } + return virtualMachines; + } + + /** + * Gets the resource collection API of Disks. It manages Disk. + * + * @return Resource collection API of Disks. + */ + public Disks disks() { + if (this.disks == null) { + this.disks = new DisksImpl(clientObject.getDisks(), this); + } + return disks; + } + + /** + * Gets wrapped service client Combined providing direct access to the underlying auto-generated API implementation, + * based on Azure REST API. + * + * @return Wrapped service client Combined. + */ + public Combined serviceClient() { + return this.clientObject; + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/Combined.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/Combined.java new file mode 100644 index 0000000000..c14cf89263 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/Combined.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for Combined class. + */ +public interface Combined { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the VirtualMachinesClient object to access its operations. + * + * @return the VirtualMachinesClient object. + */ + VirtualMachinesClient getVirtualMachines(); + + /** + * Gets the DisksClient object to access its operations. + * + * @return the DisksClient object. + */ + DisksClient getDisks(); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/DisksClient.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/DisksClient.java new file mode 100644 index 0000000000..53d3f79daf --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/DisksClient.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.fluent; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.DiskInner; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; + +/** + * An instance of this class provides access to all the operations defined in DisksClient. + */ +public interface DisksClient { + /** + * Gets information about a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String diskName, Context context); + + /** + * Gets information about a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DiskInner getByResourceGroup(String resourceGroupName, String diskName); + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of disk resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, DiskInner> beginCreateOrUpdate(String resourceGroupName, String diskName, + DiskInner resource); + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of disk resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, DiskInner> beginCreateOrUpdate(String resourceGroupName, String diskName, + DiskInner resource, Context context); + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return disk resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DiskInner createOrUpdate(String resourceGroupName, String diskName, DiskInner resource); + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return disk resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DiskInner createOrUpdate(String resourceGroupName, String diskName, DiskInner resource, Context context); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/VirtualMachinesClient.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/VirtualMachinesClient.java new file mode 100644 index 0000000000..ae8ed67197 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/VirtualMachinesClient.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.fluent; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.VirtualMachineInner; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; + +/** + * An instance of this class provides access to all the operations defined in VirtualMachinesClient. + */ +public interface VirtualMachinesClient { + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String vmName, + Context context); + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + VirtualMachineInner getByResourceGroup(String resourceGroupName, String vmName); + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, VirtualMachineInner> beginCreateOrUpdate(String resourceGroupName, + String vmName, VirtualMachineInner resource); + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, VirtualMachineInner> beginCreateOrUpdate(String resourceGroupName, + String vmName, VirtualMachineInner resource, Context context); + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource); + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource, + Context context); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/DiskInner.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/DiskInner.java new file mode 100644 index 0000000000..920c05c5c2 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/DiskInner.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.fluent.models; + +import azure.resourcemanager.multiserviceolderversions.combined.models.DiskProperties; +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Disk resource. + */ +@Fluent +public final class DiskInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private DiskProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of DiskInner class. + */ + public DiskInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public DiskProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the DiskInner object itself. + */ + public DiskInner withProperties(DiskProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public DiskInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public DiskInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DiskInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DiskInner 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 DiskInner. + */ + public static DiskInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DiskInner deserializedDiskInner = new DiskInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedDiskInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedDiskInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedDiskInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedDiskInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedDiskInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedDiskInner.properties = DiskProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedDiskInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedDiskInner; + }); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/VirtualMachineInner.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/VirtualMachineInner.java new file mode 100644 index 0000000000..fbf8b1af82 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/VirtualMachineInner.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.fluent.models; + +import azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachineProperties; +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Describes a Virtual Machine. + */ +@Fluent +public final class VirtualMachineInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private VirtualMachineProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of VirtualMachineInner class. + */ + public VirtualMachineInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public VirtualMachineProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the VirtualMachineInner object itself. + */ + public VirtualMachineInner withProperties(VirtualMachineProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public VirtualMachineInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public VirtualMachineInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VirtualMachineInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VirtualMachineInner 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 VirtualMachineInner. + */ + public static VirtualMachineInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VirtualMachineInner deserializedVirtualMachineInner = new VirtualMachineInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedVirtualMachineInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedVirtualMachineInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedVirtualMachineInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedVirtualMachineInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedVirtualMachineInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedVirtualMachineInner.properties = VirtualMachineProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedVirtualMachineInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedVirtualMachineInner; + }); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/package-info.java new file mode 100644 index 0000000000..b6f7366cf9 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiserviceolderversions.combined.fluent.models; diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/package-info.java new file mode 100644 index 0000000000..f26ba06965 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiserviceolderversions.combined.fluent; diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedBuilder.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedBuilder.java new file mode 100644 index 0000000000..3178471ba1 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the CombinedImpl type. + */ +@ServiceClientBuilder(serviceClients = { CombinedImpl.class }) +public final class CombinedBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the CombinedBuilder. + */ + public CombinedBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the CombinedBuilder. + */ + public CombinedBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the CombinedBuilder. + */ + public CombinedBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the CombinedBuilder. + */ + public CombinedBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the CombinedBuilder. + */ + public CombinedBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the CombinedBuilder. + */ + public CombinedBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of CombinedImpl with the provided parameters. + * + * @return an instance of CombinedImpl. + */ + public CombinedImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + CombinedImpl client = new CombinedImpl(localPipeline, localSerializerAdapter, localDefaultPollInterval, + localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedImpl.java new file mode 100644 index 0000000000..75986505a2 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedImpl.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.implementation; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.Combined; +import azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient; +import azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the CombinedImpl type. + */ +@ServiceClient(builder = CombinedBuilder.class) +public final class CombinedImpl implements Combined { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The VirtualMachinesClient object to access its operations. + */ + private final VirtualMachinesClient virtualMachines; + + /** + * Gets the VirtualMachinesClient object to access its operations. + * + * @return the VirtualMachinesClient object. + */ + public VirtualMachinesClient getVirtualMachines() { + return this.virtualMachines; + } + + /** + * The DisksClient object to access its operations. + */ + private final DisksClient disks; + + /** + * Gets the DisksClient object to access its operations. + * + * @return the DisksClient object. + */ + public DisksClient getDisks() { + return this.disks; + } + + /** + * Initializes an instance of Combined client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + CombinedImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.virtualMachines = new VirtualMachinesClientImpl(this); + this.disks = new DisksClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, () -> activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CombinedImpl.class); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DiskImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DiskImpl.java new file mode 100644 index 0000000000..4c8b72cd4c --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DiskImpl.java @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.implementation; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.DiskInner; +import azure.resourcemanager.multiserviceolderversions.combined.models.Disk; +import azure.resourcemanager.multiserviceolderversions.combined.models.DiskProperties; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Collections; +import java.util.Map; + +public final class DiskImpl implements Disk, Disk.Definition, Disk.Update { + private DiskInner innerObject; + + private final azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public DiskProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public DiskInner innerModel() { + return this.innerObject; + } + + private azure.resourcemanager.multiserviceolderversions.combined.CombinedManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String diskName; + + public DiskImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public Disk create() { + this.innerObject = serviceManager.serviceClient() + .getDisks() + .createOrUpdate(resourceGroupName, diskName, this.innerModel(), Context.NONE); + return this; + } + + public Disk create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getDisks() + .createOrUpdate(resourceGroupName, diskName, this.innerModel(), context); + return this; + } + + DiskImpl(String name, azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager) { + this.innerObject = new DiskInner(); + this.serviceManager = serviceManager; + this.diskName = name; + } + + public DiskImpl update() { + return this; + } + + public Disk apply() { + this.innerObject = serviceManager.serviceClient() + .getDisks() + .createOrUpdate(resourceGroupName, diskName, this.innerModel(), Context.NONE); + return this; + } + + public Disk apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getDisks() + .createOrUpdate(resourceGroupName, diskName, this.innerModel(), context); + return this; + } + + DiskImpl(DiskInner innerObject, + azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.diskName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "disksOld"); + } + + public Disk refresh() { + this.innerObject = serviceManager.serviceClient() + .getDisks() + .getByResourceGroupWithResponse(resourceGroupName, diskName, Context.NONE) + .getValue(); + return this; + } + + public Disk refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getDisks() + .getByResourceGroupWithResponse(resourceGroupName, diskName, context) + .getValue(); + return this; + } + + public DiskImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public DiskImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public DiskImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public DiskImpl withProperties(DiskProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksClientImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksClientImpl.java new file mode 100644 index 0000000000..c81a1b1835 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksClientImpl.java @@ -0,0 +1,345 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.implementation; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient; +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.DiskInner; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in DisksClient. + */ +public final class DisksClientImpl implements DisksClient { + /** + * The proxy service used to perform REST calls. + */ + private final DisksService service; + + /** + * The service client containing this operation class. + */ + private final CombinedImpl client; + + /** + * Initializes an instance of DisksClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DisksClientImpl(CombinedImpl client) { + this.service = RestProxy.create(DisksService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CombinedDisks to be used by the proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CombinedDisks") + public interface DisksService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disksOld/{diskName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("diskName") String diskName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disksOld/{diskName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("diskName") String diskName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disksOld/{diskName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("diskName") String diskName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") DiskInner resource, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disksOld/{diskName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("diskName") String diskName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") DiskInner resource, Context context); + } + + /** + * Gets information about a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, String diskName) { + final String apiVersion = "2024-03-02"; + final String accept = "application/json"; + return FluxUtil + .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())); + } + + /** + * Gets information about a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String diskName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, diskName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Gets information about a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, String diskName, + Context context) { + final String apiVersion = "2024-03-02"; + final String accept = "application/json"; + return service.getByResourceGroupSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, diskName, accept, context); + } + + /** + * Gets information about a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DiskInner getByResourceGroup(String resourceGroupName, String diskName) { + return getByResourceGroupWithResponse(resourceGroupName, diskName, Context.NONE).getValue(); + } + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return disk resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String diskName, + DiskInner resource) { + final String apiVersion = "2024-03-02"; + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .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())); + } + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return disk resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, String diskName, + DiskInner resource) { + final String apiVersion = "2024-03-02"; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, diskName, contentType, accept, resource, Context.NONE); + } + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return disk resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, String diskName, + DiskInner resource, Context context) { + final String apiVersion = "2024-03-02"; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, diskName, contentType, accept, resource, context); + } + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of disk resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, DiskInner> beginCreateOrUpdateAsync(String resourceGroupName, + String diskName, DiskInner resource) { + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, diskName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), DiskInner.class, + DiskInner.class, this.client.getContext()); + } + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of disk resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, DiskInner> beginCreateOrUpdate(String resourceGroupName, String diskName, + DiskInner resource) { + Response response = createOrUpdateWithResponse(resourceGroupName, diskName, resource); + return this.client.getLroResult(response, DiskInner.class, DiskInner.class, Context.NONE); + } + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of disk resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, DiskInner> beginCreateOrUpdate(String resourceGroupName, String diskName, + DiskInner resource, Context context) { + Response response = createOrUpdateWithResponse(resourceGroupName, diskName, resource, context); + return this.client.getLroResult(response, DiskInner.class, DiskInner.class, context); + } + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return disk resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String diskName, DiskInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, diskName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return disk resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DiskInner createOrUpdate(String resourceGroupName, String diskName, DiskInner resource) { + return beginCreateOrUpdate(resourceGroupName, diskName, resource).getFinalResult(); + } + + /** + * Creates or updates a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return disk resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DiskInner createOrUpdate(String resourceGroupName, String diskName, DiskInner resource, Context context) { + return beginCreateOrUpdate(resourceGroupName, diskName, resource, context).getFinalResult(); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksImpl.java new file mode 100644 index 0000000000..82dc82cdd5 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksImpl.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.implementation; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient; +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.DiskInner; +import azure.resourcemanager.multiserviceolderversions.combined.models.Disk; +import azure.resourcemanager.multiserviceolderversions.combined.models.Disks; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; + +public final class DisksImpl implements Disks { + private static final ClientLogger LOGGER = new ClientLogger(DisksImpl.class); + + private final DisksClient innerClient; + + private final azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager; + + public DisksImpl(DisksClient innerClient, + azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, String diskName, Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, diskName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new DiskImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Disk getByResourceGroup(String resourceGroupName, String diskName) { + DiskInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, diskName); + if (inner != null) { + return new DiskImpl(inner, this.manager()); + } else { + return null; + } + } + + public Disk getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String diskName = ResourceManagerUtils.getValueFromIdByName(id, "disksOld"); + if (diskName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'disksOld'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, diskName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String diskName = ResourceManagerUtils.getValueFromIdByName(id, "disksOld"); + if (diskName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'disksOld'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, diskName, context); + } + + private DisksClient serviceClient() { + return this.innerClient; + } + + private azure.resourcemanager.multiserviceolderversions.combined.CombinedManager manager() { + return this.serviceManager; + } + + public DiskImpl define(String name) { + return new DiskImpl(name, this.manager()); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/ResourceManagerUtils.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/ResourceManagerUtils.java new file mode 100644 index 0000000000..e2a37af0be --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachineImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachineImpl.java new file mode 100644 index 0000000000..5b3de7436c --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachineImpl.java @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.implementation; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.VirtualMachineInner; +import azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachine; +import azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachineProperties; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Collections; +import java.util.Map; + +public final class VirtualMachineImpl implements VirtualMachine, VirtualMachine.Definition, VirtualMachine.Update { + private VirtualMachineInner innerObject; + + private final azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public VirtualMachineProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public VirtualMachineInner innerModel() { + return this.innerObject; + } + + private azure.resourcemanager.multiserviceolderversions.combined.CombinedManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String vmName; + + public VirtualMachineImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public VirtualMachine create() { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .createOrUpdate(resourceGroupName, vmName, this.innerModel(), Context.NONE); + return this; + } + + public VirtualMachine create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .createOrUpdate(resourceGroupName, vmName, this.innerModel(), context); + return this; + } + + VirtualMachineImpl(String name, + azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager) { + this.innerObject = new VirtualMachineInner(); + this.serviceManager = serviceManager; + this.vmName = name; + } + + public VirtualMachineImpl update() { + return this; + } + + public VirtualMachine apply() { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .createOrUpdate(resourceGroupName, vmName, this.innerModel(), Context.NONE); + return this; + } + + public VirtualMachine apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .createOrUpdate(resourceGroupName, vmName, this.innerModel(), context); + return this; + } + + VirtualMachineImpl(VirtualMachineInner innerObject, + azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.vmName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "virtualMachinesOld"); + } + + public VirtualMachine refresh() { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .getByResourceGroupWithResponse(resourceGroupName, vmName, Context.NONE) + .getValue(); + return this; + } + + public VirtualMachine refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .getByResourceGroupWithResponse(resourceGroupName, vmName, context) + .getValue(); + return this; + } + + public VirtualMachineImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public VirtualMachineImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public VirtualMachineImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public VirtualMachineImpl withProperties(VirtualMachineProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesClientImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesClientImpl.java new file mode 100644 index 0000000000..eafb898b30 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesClientImpl.java @@ -0,0 +1,361 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.implementation; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient; +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.VirtualMachineInner; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in VirtualMachinesClient. + */ +public final class VirtualMachinesClientImpl implements VirtualMachinesClient { + /** + * The proxy service used to perform REST calls. + */ + private final VirtualMachinesService service; + + /** + * The service client containing this operation class. + */ + private final CombinedImpl client; + + /** + * Initializes an instance of VirtualMachinesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + VirtualMachinesClientImpl(CombinedImpl client) { + this.service + = RestProxy.create(VirtualMachinesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CombinedVirtualMachines to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CombinedVirtualMachines") + public interface VirtualMachinesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachinesOld/{vmName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("vmName") String vmName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachinesOld/{vmName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("vmName") String vmName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachinesOld/{vmName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("vmName") String vmName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") VirtualMachineInner resource, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachinesOld/{vmName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("vmName") String vmName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") VirtualMachineInner resource, Context context); + } + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String vmName) { + final String apiVersion = "2024-11-01"; + final String accept = "application/json"; + return FluxUtil + .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())); + } + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String vmName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, vmName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, String vmName, + Context context) { + final String apiVersion = "2024-11-01"; + final String accept = "application/json"; + return service.getByResourceGroupSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, vmName, accept, context); + } + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public VirtualMachineInner getByResourceGroup(String resourceGroupName, String vmName) { + return getByResourceGroupWithResponse(resourceGroupName, vmName, Context.NONE).getValue(); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String vmName, + VirtualMachineInner resource) { + final String apiVersion = "2024-11-01"; + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .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())); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, String vmName, + VirtualMachineInner resource) { + final String apiVersion = "2024-11-01"; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, vmName, contentType, accept, resource, Context.NONE); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, String vmName, + VirtualMachineInner resource, Context context) { + final String apiVersion = "2024-11-01"; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, vmName, contentType, accept, resource, context); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, VirtualMachineInner> + beginCreateOrUpdateAsync(String resourceGroupName, String vmName, VirtualMachineInner resource) { + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, vmName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + VirtualMachineInner.class, VirtualMachineInner.class, this.client.getContext()); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, VirtualMachineInner> + beginCreateOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource) { + Response response = createOrUpdateWithResponse(resourceGroupName, vmName, resource); + return this.client.getLroResult(response, VirtualMachineInner.class, + VirtualMachineInner.class, Context.NONE); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, VirtualMachineInner> + beginCreateOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource, Context context) { + Response response = createOrUpdateWithResponse(resourceGroupName, vmName, resource, context); + return this.client.getLroResult(response, VirtualMachineInner.class, + VirtualMachineInner.class, context); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String vmName, + VirtualMachineInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, vmName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource) { + return beginCreateOrUpdate(resourceGroupName, vmName, resource).getFinalResult(); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource, + Context context) { + return beginCreateOrUpdate(resourceGroupName, vmName, resource, context).getFinalResult(); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesImpl.java new file mode 100644 index 0000000000..f72d70052e --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesImpl.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.implementation; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient; +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.VirtualMachineInner; +import azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachine; +import azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachines; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; + +public final class VirtualMachinesImpl implements VirtualMachines { + private static final ClientLogger LOGGER = new ClientLogger(VirtualMachinesImpl.class); + + private final VirtualMachinesClient innerClient; + + private final azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager; + + public VirtualMachinesImpl(VirtualMachinesClient innerClient, + azure.resourcemanager.multiserviceolderversions.combined.CombinedManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, String vmName, + Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, vmName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new VirtualMachineImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public VirtualMachine getByResourceGroup(String resourceGroupName, String vmName) { + VirtualMachineInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, vmName); + if (inner != null) { + return new VirtualMachineImpl(inner, this.manager()); + } else { + return null; + } + } + + public VirtualMachine getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String vmName = ResourceManagerUtils.getValueFromIdByName(id, "virtualMachinesOld"); + if (vmName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'virtualMachinesOld'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, vmName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String vmName = ResourceManagerUtils.getValueFromIdByName(id, "virtualMachinesOld"); + if (vmName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'virtualMachinesOld'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, vmName, context); + } + + private VirtualMachinesClient serviceClient() { + return this.innerClient; + } + + private azure.resourcemanager.multiserviceolderversions.combined.CombinedManager manager() { + return this.serviceManager; + } + + public VirtualMachineImpl define(String name) { + return new VirtualMachineImpl(name, this.manager()); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/package-info.java new file mode 100644 index 0000000000..0fe238e297 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiserviceolderversions.combined.implementation; diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disk.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disk.java new file mode 100644 index 0000000000..29add8d7ce --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disk.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.models; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.DiskInner; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Map; + +/** + * An immutable client-side representation of Disk. + */ +public interface Disk { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + DiskProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner azure.resourcemanager.multiserviceolderversions.combined.fluent.models.DiskInner object. + * + * @return the inner object. + */ + DiskInner innerModel(); + + /** + * The entirety of the Disk definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The Disk definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the Disk definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the Disk definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the Disk definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the Disk definition which contains all the minimum required properties for the resource to be + * created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + Disk create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + Disk create(Context context); + } + + /** + * The stage of the Disk definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the Disk definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(DiskProperties properties); + } + } + + /** + * Begins update for the Disk resource. + * + * @return the stage of resource update. + */ + Disk.Update update(); + + /** + * The template for Disk update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + Disk apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + Disk apply(Context context); + } + + /** + * The Disk update stages. + */ + interface UpdateStages { + /** + * The stage of the Disk update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the Disk update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(DiskProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + Disk refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + Disk refresh(Context context); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/DiskProperties.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/DiskProperties.java new file mode 100644 index 0000000000..f3fa7ddcc0 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/DiskProperties.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Disk resource properties. + */ +@Fluent +public final class DiskProperties implements JsonSerializable { + /* + * The provisioningState property. + */ + private ResourceProvisioningState provisioningState; + + /* + * Size of the disk in GB. Only available in version 2024-03-02. + */ + private Integer diskSizeGB; + + /** + * Creates an instance of DiskProperties class. + */ + public DiskProperties() { + } + + /** + * Get the provisioningState property: The provisioningState property. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the diskSizeGB property: Size of the disk in GB. Only available in version 2024-03-02. + * + * @return the diskSizeGB value. + */ + public Integer diskSizeGB() { + return this.diskSizeGB; + } + + /** + * Set the diskSizeGB property: Size of the disk in GB. Only available in version 2024-03-02. + * + * @param diskSizeGB the diskSizeGB value to set. + * @return the DiskProperties object itself. + */ + public DiskProperties withDiskSizeGB(Integer diskSizeGB) { + this.diskSizeGB = diskSizeGB; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("diskSizeGB", this.diskSizeGB); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DiskProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DiskProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the DiskProperties. + */ + public static DiskProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DiskProperties deserializedDiskProperties = new DiskProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedDiskProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("diskSizeGB".equals(fieldName)) { + deserializedDiskProperties.diskSizeGB = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + + return deserializedDiskProperties; + }); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disks.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disks.java new file mode 100644 index 0000000000..8f025c9db8 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disks.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of Disks. + */ +public interface Disks { + /** + * Gets information about a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String diskName, Context context); + + /** + * Gets information about a disk. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param diskName The name of the Disk. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk. + */ + Disk getByResourceGroup(String resourceGroupName, String diskName); + + /** + * Gets information about a disk. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk along with {@link Response}. + */ + Disk getById(String id); + + /** + * Gets information about a disk. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a disk along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new Disk resource. + * + * @param name resource name. + * @return the first stage of the new Disk definition. + */ + Disk.DefinitionStages.Blank define(String name); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/ResourceProvisioningState.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/ResourceProvisioningState.java new file mode 100644 index 0000000000..cbd8e8c691 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/ResourceProvisioningState.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The provisioning state of a resource type. + */ +public final class ResourceProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ResourceProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ResourceProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ResourceProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ResourceProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ResourceProvisioningState() { + } + + /** + * Creates or finds a ResourceProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResourceProvisioningState. + */ + public static ResourceProvisioningState fromString(String name) { + return fromString(name, ResourceProvisioningState.class); + } + + /** + * Gets known ResourceProvisioningState values. + * + * @return known ResourceProvisioningState values. + */ + public static Collection values() { + return values(ResourceProvisioningState.class); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachine.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachine.java new file mode 100644 index 0000000000..e082f9f560 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachine.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.models; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.VirtualMachineInner; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Map; + +/** + * An immutable client-side representation of VirtualMachine. + */ +public interface VirtualMachine { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + VirtualMachineProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner azure.resourcemanager.multiserviceolderversions.combined.fluent.models.VirtualMachineInner object. + * + * @return the inner object. + */ + VirtualMachineInner innerModel(); + + /** + * The entirety of the VirtualMachine definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The VirtualMachine definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the VirtualMachine definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the VirtualMachine definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the VirtualMachine definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the VirtualMachine definition which contains all the minimum required properties for the + * resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + VirtualMachine create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + VirtualMachine create(Context context); + } + + /** + * The stage of the VirtualMachine definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the VirtualMachine definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(VirtualMachineProperties properties); + } + } + + /** + * Begins update for the VirtualMachine resource. + * + * @return the stage of resource update. + */ + VirtualMachine.Update update(); + + /** + * The template for VirtualMachine update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + VirtualMachine apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + VirtualMachine apply(Context context); + } + + /** + * The VirtualMachine update stages. + */ + interface UpdateStages { + /** + * The stage of the VirtualMachine update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the VirtualMachine update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(VirtualMachineProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + VirtualMachine refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + VirtualMachine refresh(Context context); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachineProperties.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachineProperties.java new file mode 100644 index 0000000000..0a5e9296e9 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachineProperties.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.models; + +import com.azure.core.annotation.Fluent; +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 VirtualMachineProperties model. + */ +@Fluent +public final class VirtualMachineProperties implements JsonSerializable { + /* + * The provisioningState property. + */ + private ResourceProvisioningState provisioningState; + + /* + * Size of the virtual machine. Only available in version 2024-11-01. + */ + private String size; + + /** + * Creates an instance of VirtualMachineProperties class. + */ + public VirtualMachineProperties() { + } + + /** + * Get the provisioningState property: The provisioningState property. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the size property: Size of the virtual machine. Only available in version 2024-11-01. + * + * @return the size value. + */ + public String size() { + return this.size; + } + + /** + * Set the size property: Size of the virtual machine. Only available in version 2024-11-01. + * + * @param size the size value to set. + * @return the VirtualMachineProperties object itself. + */ + public VirtualMachineProperties withSize(String size) { + this.size = size; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("size", this.size); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VirtualMachineProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VirtualMachineProperties if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the VirtualMachineProperties. + */ + public static VirtualMachineProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VirtualMachineProperties deserializedVirtualMachineProperties = new VirtualMachineProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedVirtualMachineProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("size".equals(fieldName)) { + deserializedVirtualMachineProperties.size = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedVirtualMachineProperties; + }); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachines.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachines.java new file mode 100644 index 0000000000..085e55909f --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachines.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of VirtualMachines. + */ +public interface VirtualMachines { + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String vmName, Context context); + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + VirtualMachine getByResourceGroup(String resourceGroupName, String vmName); + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + VirtualMachine getById(String id); + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new VirtualMachine resource. + * + * @param name resource name. + * @return the first stage of the new VirtualMachine definition. + */ + VirtualMachine.DefinitionStages.Blank define(String name); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/package-info.java new file mode 100644 index 0000000000..221f269dbf --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiserviceolderversions.combined.models; diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/package-info.java new file mode 100644 index 0000000000..af6d0a0983 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiserviceolderversions/combined/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiserviceolderversions.combined; diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/CombinedManager.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/CombinedManager.java new file mode 100644 index 0000000000..eec6bad9ba --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/CombinedManager.java @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.Combined; +import azure.resourcemanager.multiservicesharedmodels.combined.implementation.CombinedBuilder; +import azure.resourcemanager.multiservicesharedmodels.combined.implementation.StorageAccountsImpl; +import azure.resourcemanager.multiservicesharedmodels.combined.implementation.VirtualMachinesImpl; +import azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccounts; +import azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachines; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to CombinedManager. + * Compute Client. + */ +public final class CombinedManager { + private VirtualMachines virtualMachines; + + private StorageAccounts storageAccounts; + + private final Combined clientObject; + + private CombinedManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new CombinedBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of combined service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the combined service API instance. + */ + public static CombinedManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of combined service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the combined service API instance. + */ + public static CombinedManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new CombinedManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create CombinedManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new CombinedManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-combined-generated.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of combined service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the combined service API instance. + */ + public CombinedManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("azure.resourcemanager.multiservicesharedmodels.combined") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new CombinedManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of VirtualMachines. It manages VirtualMachine. + * + * @return Resource collection API of VirtualMachines. + */ + public VirtualMachines virtualMachines() { + if (this.virtualMachines == null) { + this.virtualMachines = new VirtualMachinesImpl(clientObject.getVirtualMachines(), this); + } + return virtualMachines; + } + + /** + * Gets the resource collection API of StorageAccounts. It manages StorageAccount. + * + * @return Resource collection API of StorageAccounts. + */ + public StorageAccounts storageAccounts() { + if (this.storageAccounts == null) { + this.storageAccounts = new StorageAccountsImpl(clientObject.getStorageAccounts(), this); + } + return storageAccounts; + } + + /** + * Gets wrapped service client Combined providing direct access to the underlying auto-generated API implementation, + * based on Azure REST API. + * + * @return Wrapped service client Combined. + */ + public Combined serviceClient() { + return this.clientObject; + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/Combined.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/Combined.java new file mode 100644 index 0000000000..987aba4313 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/Combined.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for Combined class. + */ +public interface Combined { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the VirtualMachinesClient object to access its operations. + * + * @return the VirtualMachinesClient object. + */ + VirtualMachinesClient getVirtualMachines(); + + /** + * Gets the StorageAccountsClient object to access its operations. + * + * @return the StorageAccountsClient object. + */ + StorageAccountsClient getStorageAccounts(); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/StorageAccountsClient.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/StorageAccountsClient.java new file mode 100644 index 0000000000..61e63e280a --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/StorageAccountsClient.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.fluent; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.StorageAccountInner; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; + +/** + * An instance of this class provides access to all the operations defined in StorageAccountsClient. + */ +public interface StorageAccountsClient { + /** + * Gets information about a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String accountName, + Context context); + + /** + * Gets information about a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + StorageAccountInner getByResourceGroup(String resourceGroupName, String accountName); + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of storage account resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, StorageAccountInner> beginCreateOrUpdate(String resourceGroupName, + String accountName, StorageAccountInner resource); + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of storage account resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, StorageAccountInner> beginCreateOrUpdate(String resourceGroupName, + String accountName, StorageAccountInner resource, Context context); + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return storage account resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + StorageAccountInner createOrUpdate(String resourceGroupName, String accountName, StorageAccountInner resource); + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return storage account resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + StorageAccountInner createOrUpdate(String resourceGroupName, String accountName, StorageAccountInner resource, + Context context); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/VirtualMachinesClient.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/VirtualMachinesClient.java new file mode 100644 index 0000000000..78e3bfeb3b --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/VirtualMachinesClient.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.fluent; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.VirtualMachineInner; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; + +/** + * An instance of this class provides access to all the operations defined in VirtualMachinesClient. + */ +public interface VirtualMachinesClient { + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String vmName, + Context context); + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + VirtualMachineInner getByResourceGroup(String resourceGroupName, String vmName); + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, VirtualMachineInner> beginCreateOrUpdate(String resourceGroupName, + String vmName, VirtualMachineInner resource); + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, VirtualMachineInner> beginCreateOrUpdate(String resourceGroupName, + String vmName, VirtualMachineInner resource, Context context); + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource); + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource, + Context context); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/StorageAccountInner.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/StorageAccountInner.java new file mode 100644 index 0000000000..1a102b173d --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/StorageAccountInner.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.fluent.models; + +import azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccountProperties; +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Storage account resource. + */ +@Fluent +public final class StorageAccountInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private StorageAccountProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of StorageAccountInner class. + */ + public StorageAccountInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public StorageAccountProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withProperties(StorageAccountProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public StorageAccountInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public StorageAccountInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountInner 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 StorageAccountInner. + */ + public static StorageAccountInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountInner deserializedStorageAccountInner = new StorageAccountInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedStorageAccountInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedStorageAccountInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedStorageAccountInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedStorageAccountInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedStorageAccountInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedStorageAccountInner.properties = StorageAccountProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedStorageAccountInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountInner; + }); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/VirtualMachineInner.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/VirtualMachineInner.java new file mode 100644 index 0000000000..276a871981 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/VirtualMachineInner.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.fluent.models; + +import azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachineProperties; +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Describes a Virtual Machine. + */ +@Fluent +public final class VirtualMachineInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private VirtualMachineProperties properties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of VirtualMachineInner class. + */ + public VirtualMachineInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public VirtualMachineProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the VirtualMachineInner object itself. + */ + public VirtualMachineInner withProperties(VirtualMachineProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public VirtualMachineInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public VirtualMachineInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VirtualMachineInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VirtualMachineInner 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 VirtualMachineInner. + */ + public static VirtualMachineInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VirtualMachineInner deserializedVirtualMachineInner = new VirtualMachineInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedVirtualMachineInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedVirtualMachineInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedVirtualMachineInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedVirtualMachineInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedVirtualMachineInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedVirtualMachineInner.properties = VirtualMachineProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedVirtualMachineInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedVirtualMachineInner; + }); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/package-info.java new file mode 100644 index 0000000000..be6e63603e --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiservicesharedmodels.combined.fluent.models; diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/package-info.java new file mode 100644 index 0000000000..a46908efc1 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiservicesharedmodels.combined.fluent; diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedBuilder.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedBuilder.java new file mode 100644 index 0000000000..2519e00c15 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the CombinedImpl type. + */ +@ServiceClientBuilder(serviceClients = { CombinedImpl.class }) +public final class CombinedBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the CombinedBuilder. + */ + public CombinedBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the CombinedBuilder. + */ + public CombinedBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the CombinedBuilder. + */ + public CombinedBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the CombinedBuilder. + */ + public CombinedBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the CombinedBuilder. + */ + public CombinedBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the CombinedBuilder. + */ + public CombinedBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of CombinedImpl with the provided parameters. + * + * @return an instance of CombinedImpl. + */ + public CombinedImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + CombinedImpl client = new CombinedImpl(localPipeline, localSerializerAdapter, localDefaultPollInterval, + localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedImpl.java new file mode 100644 index 0000000000..124fe1779c --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedImpl.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.Combined; +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient; +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the CombinedImpl type. + */ +@ServiceClient(builder = CombinedBuilder.class) +public final class CombinedImpl implements Combined { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The VirtualMachinesClient object to access its operations. + */ + private final VirtualMachinesClient virtualMachines; + + /** + * Gets the VirtualMachinesClient object to access its operations. + * + * @return the VirtualMachinesClient object. + */ + public VirtualMachinesClient getVirtualMachines() { + return this.virtualMachines; + } + + /** + * The StorageAccountsClient object to access its operations. + */ + private final StorageAccountsClient storageAccounts; + + /** + * Gets the StorageAccountsClient object to access its operations. + * + * @return the StorageAccountsClient object. + */ + public StorageAccountsClient getStorageAccounts() { + return this.storageAccounts; + } + + /** + * Initializes an instance of Combined client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + CombinedImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.virtualMachines = new VirtualMachinesClientImpl(this); + this.storageAccounts = new StorageAccountsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, () -> activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CombinedImpl.class); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/ResourceManagerUtils.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/ResourceManagerUtils.java new file mode 100644 index 0000000000..070bf10b11 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountImpl.java new file mode 100644 index 0000000000..23ec341363 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountImpl.java @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.StorageAccountInner; +import azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccount; +import azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccountProperties; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Collections; +import java.util.Map; + +public final class StorageAccountImpl implements StorageAccount, StorageAccount.Definition, StorageAccount.Update { + private StorageAccountInner innerObject; + + private final azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public StorageAccountProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public StorageAccountInner innerModel() { + return this.innerObject; + } + + private azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String accountName; + + public StorageAccountImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public StorageAccount create() { + this.innerObject = serviceManager.serviceClient() + .getStorageAccounts() + .createOrUpdate(resourceGroupName, accountName, this.innerModel(), Context.NONE); + return this; + } + + public StorageAccount create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getStorageAccounts() + .createOrUpdate(resourceGroupName, accountName, this.innerModel(), context); + return this; + } + + StorageAccountImpl(String name, + azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager) { + this.innerObject = new StorageAccountInner(); + this.serviceManager = serviceManager; + this.accountName = name; + } + + public StorageAccountImpl update() { + return this; + } + + public StorageAccount apply() { + this.innerObject = serviceManager.serviceClient() + .getStorageAccounts() + .createOrUpdate(resourceGroupName, accountName, this.innerModel(), Context.NONE); + return this; + } + + public StorageAccount apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getStorageAccounts() + .createOrUpdate(resourceGroupName, accountName, this.innerModel(), context); + return this; + } + + StorageAccountImpl(StorageAccountInner innerObject, + azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.accountName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "storageAccounts"); + } + + public StorageAccount refresh() { + this.innerObject = serviceManager.serviceClient() + .getStorageAccounts() + .getByResourceGroupWithResponse(resourceGroupName, accountName, Context.NONE) + .getValue(); + return this; + } + + public StorageAccount refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getStorageAccounts() + .getByResourceGroupWithResponse(resourceGroupName, accountName, context) + .getValue(); + return this; + } + + public StorageAccountImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public StorageAccountImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public StorageAccountImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public StorageAccountImpl withProperties(StorageAccountProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsClientImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsClientImpl.java new file mode 100644 index 0000000000..50cba1bf45 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsClientImpl.java @@ -0,0 +1,353 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient; +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.StorageAccountInner; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in StorageAccountsClient. + */ +public final class StorageAccountsClientImpl implements StorageAccountsClient { + /** + * The proxy service used to perform REST calls. + */ + private final StorageAccountsService service; + + /** + * The service client containing this operation class. + */ + private final CombinedImpl client; + + /** + * Initializes an instance of StorageAccountsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StorageAccountsClientImpl(CombinedImpl client) { + this.service + = RestProxy.create(StorageAccountsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CombinedStorageAccounts to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CombinedStorageAccounts") + public interface StorageAccountsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/storageAccounts/{accountName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("accountName") String accountName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/storageAccounts/{accountName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("accountName") String accountName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/storageAccounts/{accountName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("accountName") String accountName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") StorageAccountInner resource, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/storageAccounts/{accountName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("accountName") String accountName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") StorageAccountInner resource, Context context); + } + + /** + * Gets information about a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String accountName) { + final String apiVersion = "2025-02-01"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), apiVersion, + this.client.getSubscriptionId(), resourceGroupName, accountName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Gets information about a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String accountName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, accountName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Gets information about a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, String accountName, + Context context) { + final String apiVersion = "2025-02-01"; + final String accept = "application/json"; + return service.getByResourceGroupSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, accountName, accept, context); + } + + /** + * Gets information about a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public StorageAccountInner getByResourceGroup(String resourceGroupName, String accountName) { + return getByResourceGroupWithResponse(resourceGroupName, accountName, Context.NONE).getValue(); + } + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return storage account resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, + String accountName, StorageAccountInner resource) { + final String apiVersion = "2025-02-01"; + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.createOrUpdate(this.client.getEndpoint(), apiVersion, + this.client.getSubscriptionId(), resourceGroupName, accountName, contentType, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return storage account resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, String accountName, + StorageAccountInner resource) { + final String apiVersion = "2025-02-01"; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, accountName, contentType, accept, resource, Context.NONE); + } + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return storage account resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, String accountName, + StorageAccountInner resource, Context context) { + final String apiVersion = "2025-02-01"; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, accountName, contentType, accept, resource, context); + } + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of storage account resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, StorageAccountInner> + beginCreateOrUpdateAsync(String resourceGroupName, String accountName, StorageAccountInner resource) { + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, accountName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + StorageAccountInner.class, StorageAccountInner.class, this.client.getContext()); + } + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of storage account resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, StorageAccountInner> + beginCreateOrUpdate(String resourceGroupName, String accountName, StorageAccountInner resource) { + Response response = createOrUpdateWithResponse(resourceGroupName, accountName, resource); + return this.client.getLroResult(response, StorageAccountInner.class, + StorageAccountInner.class, Context.NONE); + } + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of storage account resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, StorageAccountInner> beginCreateOrUpdate( + String resourceGroupName, String accountName, StorageAccountInner resource, Context context) { + Response response = createOrUpdateWithResponse(resourceGroupName, accountName, resource, context); + return this.client.getLroResult(response, StorageAccountInner.class, + StorageAccountInner.class, context); + } + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return storage account resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String accountName, + StorageAccountInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, accountName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return storage account resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public StorageAccountInner createOrUpdate(String resourceGroupName, String accountName, + StorageAccountInner resource) { + return beginCreateOrUpdate(resourceGroupName, accountName, resource).getFinalResult(); + } + + /** + * Creates or updates a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return storage account resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public StorageAccountInner createOrUpdate(String resourceGroupName, String accountName, + StorageAccountInner resource, Context context) { + return beginCreateOrUpdate(resourceGroupName, accountName, resource, context).getFinalResult(); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsImpl.java new file mode 100644 index 0000000000..bbf7e7bf70 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsImpl.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient; +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.StorageAccountInner; +import azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccount; +import azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccounts; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; + +public final class StorageAccountsImpl implements StorageAccounts { + private static final ClientLogger LOGGER = new ClientLogger(StorageAccountsImpl.class); + + private final StorageAccountsClient innerClient; + + private final azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager; + + public StorageAccountsImpl(StorageAccountsClient innerClient, + azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, String accountName, + Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, accountName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new StorageAccountImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public StorageAccount getByResourceGroup(String resourceGroupName, String accountName) { + StorageAccountInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, accountName); + if (inner != null) { + return new StorageAccountImpl(inner, this.manager()); + } else { + return null; + } + } + + public StorageAccount getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String accountName = ResourceManagerUtils.getValueFromIdByName(id, "storageAccounts"); + if (accountName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'storageAccounts'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, accountName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String accountName = ResourceManagerUtils.getValueFromIdByName(id, "storageAccounts"); + if (accountName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'storageAccounts'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, accountName, context); + } + + private StorageAccountsClient serviceClient() { + return this.innerClient; + } + + private azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager manager() { + return this.serviceManager; + } + + public StorageAccountImpl define(String name) { + return new StorageAccountImpl(name, this.manager()); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachineImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachineImpl.java new file mode 100644 index 0000000000..7c016abac5 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachineImpl.java @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.VirtualMachineInner; +import azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachine; +import azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachineProperties; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Collections; +import java.util.Map; + +public final class VirtualMachineImpl implements VirtualMachine, VirtualMachine.Definition, VirtualMachine.Update { + private VirtualMachineInner innerObject; + + private final azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public VirtualMachineProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public VirtualMachineInner innerModel() { + return this.innerObject; + } + + private azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String vmName; + + public VirtualMachineImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public VirtualMachine create() { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .createOrUpdate(resourceGroupName, vmName, this.innerModel(), Context.NONE); + return this; + } + + public VirtualMachine create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .createOrUpdate(resourceGroupName, vmName, this.innerModel(), context); + return this; + } + + VirtualMachineImpl(String name, + azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager) { + this.innerObject = new VirtualMachineInner(); + this.serviceManager = serviceManager; + this.vmName = name; + } + + public VirtualMachineImpl update() { + return this; + } + + public VirtualMachine apply() { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .createOrUpdate(resourceGroupName, vmName, this.innerModel(), Context.NONE); + return this; + } + + public VirtualMachine apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .createOrUpdate(resourceGroupName, vmName, this.innerModel(), context); + return this; + } + + VirtualMachineImpl(VirtualMachineInner innerObject, + azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.vmName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "virtualMachinesShared"); + } + + public VirtualMachine refresh() { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .getByResourceGroupWithResponse(resourceGroupName, vmName, Context.NONE) + .getValue(); + return this; + } + + public VirtualMachine refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getVirtualMachines() + .getByResourceGroupWithResponse(resourceGroupName, vmName, context) + .getValue(); + return this; + } + + public VirtualMachineImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public VirtualMachineImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public VirtualMachineImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public VirtualMachineImpl withProperties(VirtualMachineProperties properties) { + this.innerModel().withProperties(properties); + return this; + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesClientImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesClientImpl.java new file mode 100644 index 0000000000..5b974be3c0 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesClientImpl.java @@ -0,0 +1,361 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient; +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.VirtualMachineInner; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in VirtualMachinesClient. + */ +public final class VirtualMachinesClientImpl implements VirtualMachinesClient { + /** + * The proxy service used to perform REST calls. + */ + private final VirtualMachinesService service; + + /** + * The service client containing this operation class. + */ + private final CombinedImpl client; + + /** + * Initializes an instance of VirtualMachinesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + VirtualMachinesClientImpl(CombinedImpl client) { + this.service + = RestProxy.create(VirtualMachinesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for CombinedVirtualMachines to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "CombinedVirtualMachines") + public interface VirtualMachinesService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachinesShared/{vmName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("vmName") String vmName, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachinesShared/{vmName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("vmName") String vmName, + @HeaderParam("Accept") String accept, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachinesShared/{vmName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("vmName") String vmName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") VirtualMachineInner resource, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachinesShared/{vmName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("vmName") String vmName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") VirtualMachineInner resource, Context context); + } + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, + String vmName) { + final String apiVersion = "2025-05-01"; + final String accept = "application/json"; + return FluxUtil + .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())); + } + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String vmName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, vmName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, String vmName, + Context context) { + final String apiVersion = "2025-05-01"; + final String accept = "application/json"; + return service.getByResourceGroupSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, vmName, accept, context); + } + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public VirtualMachineInner getByResourceGroup(String resourceGroupName, String vmName) { + return getByResourceGroupWithResponse(resourceGroupName, vmName, Context.NONE).getValue(); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String vmName, + VirtualMachineInner resource) { + final String apiVersion = "2025-05-01"; + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .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())); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, String vmName, + VirtualMachineInner resource) { + final String apiVersion = "2025-05-01"; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, vmName, contentType, accept, resource, Context.NONE); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response createOrUpdateWithResponse(String resourceGroupName, String vmName, + VirtualMachineInner resource, Context context) { + final String apiVersion = "2025-05-01"; + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), apiVersion, this.client.getSubscriptionId(), + resourceGroupName, vmName, contentType, accept, resource, context); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, VirtualMachineInner> + beginCreateOrUpdateAsync(String resourceGroupName, String vmName, VirtualMachineInner resource) { + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, vmName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + VirtualMachineInner.class, VirtualMachineInner.class, this.client.getContext()); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, VirtualMachineInner> + beginCreateOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource) { + Response response = createOrUpdateWithResponse(resourceGroupName, vmName, resource); + return this.client.getLroResult(response, VirtualMachineInner.class, + VirtualMachineInner.class, Context.NONE); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, VirtualMachineInner> + beginCreateOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource, Context context) { + Response response = createOrUpdateWithResponse(resourceGroupName, vmName, resource, context); + return this.client.getLroResult(response, VirtualMachineInner.class, + VirtualMachineInner.class, context); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String vmName, + VirtualMachineInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, vmName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource) { + return beginCreateOrUpdate(resourceGroupName, vmName, resource).getFinalResult(); + } + + /** + * The operation to create or update a virtual machine. Please note some properties can be set only during virtual + * machine creation. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public VirtualMachineInner createOrUpdate(String resourceGroupName, String vmName, VirtualMachineInner resource, + Context context) { + return beginCreateOrUpdate(resourceGroupName, vmName, resource, context).getFinalResult(); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesImpl.java new file mode 100644 index 0000000000..617de063fc --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesImpl.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient; +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.VirtualMachineInner; +import azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachine; +import azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachines; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; + +public final class VirtualMachinesImpl implements VirtualMachines { + private static final ClientLogger LOGGER = new ClientLogger(VirtualMachinesImpl.class); + + private final VirtualMachinesClient innerClient; + + private final azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager; + + public VirtualMachinesImpl(VirtualMachinesClient innerClient, + azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, String vmName, + Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, vmName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new VirtualMachineImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public VirtualMachine getByResourceGroup(String resourceGroupName, String vmName) { + VirtualMachineInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, vmName); + if (inner != null) { + return new VirtualMachineImpl(inner, this.manager()); + } else { + return null; + } + } + + public VirtualMachine getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String vmName = ResourceManagerUtils.getValueFromIdByName(id, "virtualMachinesShared"); + if (vmName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'virtualMachinesShared'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, vmName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String vmName = ResourceManagerUtils.getValueFromIdByName(id, "virtualMachinesShared"); + if (vmName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'virtualMachinesShared'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, vmName, context); + } + + private VirtualMachinesClient serviceClient() { + return this.innerClient; + } + + private azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager manager() { + return this.serviceManager; + } + + public VirtualMachineImpl define(String name) { + return new VirtualMachineImpl(name, this.manager()); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/package-info.java new file mode 100644 index 0000000000..df86a335ec --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiservicesharedmodels.combined.implementation; diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/ResourceProvisioningState.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/ResourceProvisioningState.java new file mode 100644 index 0000000000..b50a53727b --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/ResourceProvisioningState.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The provisioning state of a resource type. + */ +public final class ResourceProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ResourceProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ResourceProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ResourceProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ResourceProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ResourceProvisioningState() { + } + + /** + * Creates or finds a ResourceProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResourceProvisioningState. + */ + public static ResourceProvisioningState fromString(String name) { + return fromString(name, ResourceProvisioningState.class); + } + + /** + * Gets known ResourceProvisioningState values. + * + * @return known ResourceProvisioningState values. + */ + public static Collection values() { + return values(ResourceProvisioningState.class); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/SharedMetadata.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/SharedMetadata.java new file mode 100644 index 0000000000..ebaaac5882 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/SharedMetadata.java @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Map; + +/** + * Common metadata shared across multiple services. + */ +@Fluent +public final class SharedMetadata implements JsonSerializable { + /* + * Creation timestamp of the resource. + */ + private OffsetDateTime createdAt; + + /* + * Creator of the resource. + */ + private String createdBy; + + /* + * Tags associated with the resource. + */ + private Map tags; + + /** + * Creates an instance of SharedMetadata class. + */ + public SharedMetadata() { + } + + /** + * Get the createdAt property: Creation timestamp of the resource. + * + * @return the createdAt value. + */ + public OffsetDateTime createdAt() { + return this.createdAt; + } + + /** + * Set the createdAt property: Creation timestamp of the resource. + * + * @param createdAt the createdAt value to set. + * @return the SharedMetadata object itself. + */ + public SharedMetadata withCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get the createdBy property: Creator of the resource. + * + * @return the createdBy value. + */ + public String createdBy() { + return this.createdBy; + } + + /** + * Set the createdBy property: Creator of the resource. + * + * @param createdBy the createdBy value to set. + * @return the SharedMetadata object itself. + */ + public SharedMetadata withCreatedBy(String createdBy) { + this.createdBy = createdBy; + return this; + } + + /** + * Get the tags property: Tags associated with the resource. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Tags associated with the resource. + * + * @param tags the tags value to set. + * @return the SharedMetadata object itself. + */ + public SharedMetadata withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("createdAt", + this.createdAt == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdAt)); + jsonWriter.writeStringField("createdBy", this.createdBy); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SharedMetadata from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SharedMetadata if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the SharedMetadata. + */ + public static SharedMetadata fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SharedMetadata deserializedSharedMetadata = new SharedMetadata(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("createdAt".equals(fieldName)) { + deserializedSharedMetadata.createdAt = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("createdBy".equals(fieldName)) { + deserializedSharedMetadata.createdBy = reader.getString(); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedSharedMetadata.tags = tags; + } else { + reader.skipChildren(); + } + } + + return deserializedSharedMetadata; + }); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccount.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccount.java new file mode 100644 index 0000000000..b3456c74a4 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccount.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.models; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.StorageAccountInner; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Map; + +/** + * An immutable client-side representation of StorageAccount. + */ +public interface StorageAccount { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + StorageAccountProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.StorageAccountInner object. + * + * @return the inner object. + */ + StorageAccountInner innerModel(); + + /** + * The entirety of the StorageAccount definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The StorageAccount definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the StorageAccount definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the StorageAccount definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the StorageAccount definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the StorageAccount definition which contains all the minimum required properties for the + * resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + StorageAccount create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + StorageAccount create(Context context); + } + + /** + * The stage of the StorageAccount definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the StorageAccount definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(StorageAccountProperties properties); + } + } + + /** + * Begins update for the StorageAccount resource. + * + * @return the stage of resource update. + */ + StorageAccount.Update update(); + + /** + * The template for StorageAccount update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + StorageAccount apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + StorageAccount apply(Context context); + } + + /** + * The StorageAccount update stages. + */ + interface UpdateStages { + /** + * The stage of the StorageAccount update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the StorageAccount update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(StorageAccountProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + StorageAccount refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + StorageAccount refresh(Context context); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccountProperties.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccountProperties.java new file mode 100644 index 0000000000..737ccd00f6 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccountProperties.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Storage account properties. + */ +@Fluent +public final class StorageAccountProperties implements JsonSerializable { + /* + * The provisioningState property. + */ + private ResourceProvisioningState provisioningState; + + /* + * Shared metadata for the storage account. + */ + private SharedMetadata metadata; + + /** + * Creates an instance of StorageAccountProperties class. + */ + public StorageAccountProperties() { + } + + /** + * Get the provisioningState property: The provisioningState property. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the metadata property: Shared metadata for the storage account. + * + * @return the metadata value. + */ + public SharedMetadata metadata() { + return this.metadata; + } + + /** + * Set the metadata property: Shared metadata for the storage account. + * + * @param metadata the metadata value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withMetadata(SharedMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("metadata", this.metadata); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountProperties if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageAccountProperties. + */ + public static StorageAccountProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountProperties deserializedStorageAccountProperties = new StorageAccountProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedStorageAccountProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("metadata".equals(fieldName)) { + deserializedStorageAccountProperties.metadata = SharedMetadata.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountProperties; + }); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccounts.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccounts.java new file mode 100644 index 0000000000..e2cfe55474 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccounts.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of StorageAccounts. + */ +public interface StorageAccounts { + /** + * Gets information about a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String accountName, + Context context); + + /** + * Gets information about a storage account. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the StorageAccount. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account. + */ + StorageAccount getByResourceGroup(String resourceGroupName, String accountName); + + /** + * Gets information about a storage account. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account along with {@link Response}. + */ + StorageAccount getById(String id); + + /** + * Gets information about a storage account. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return information about a storage account along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new StorageAccount resource. + * + * @param name resource name. + * @return the first stage of the new StorageAccount definition. + */ + StorageAccount.DefinitionStages.Blank define(String name); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachine.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachine.java new file mode 100644 index 0000000000..e0b4cfc980 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachine.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.models; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.VirtualMachineInner; +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import java.util.Map; + +/** + * An immutable client-side representation of VirtualMachine. + */ +public interface VirtualMachine { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + VirtualMachineProperties properties(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.VirtualMachineInner object. + * + * @return the inner object. + */ + VirtualMachineInner innerModel(); + + /** + * The entirety of the VirtualMachine definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The VirtualMachine definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the VirtualMachine definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the VirtualMachine definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the VirtualMachine definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the VirtualMachine definition which contains all the minimum required properties for the + * resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + VirtualMachine create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + VirtualMachine create(Context context); + } + + /** + * The stage of the VirtualMachine definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the VirtualMachine definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(VirtualMachineProperties properties); + } + } + + /** + * Begins update for the VirtualMachine resource. + * + * @return the stage of resource update. + */ + VirtualMachine.Update update(); + + /** + * The template for VirtualMachine update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + VirtualMachine apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + VirtualMachine apply(Context context); + } + + /** + * The VirtualMachine update stages. + */ + interface UpdateStages { + /** + * The stage of the VirtualMachine update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the VirtualMachine update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + Update withProperties(VirtualMachineProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + VirtualMachine refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + VirtualMachine refresh(Context context); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachineProperties.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachineProperties.java new file mode 100644 index 0000000000..d37723f731 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachineProperties.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.models; + +import com.azure.core.annotation.Fluent; +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 VirtualMachineProperties model. + */ +@Fluent +public final class VirtualMachineProperties implements JsonSerializable { + /* + * The provisioningState property. + */ + private ResourceProvisioningState provisioningState; + + /* + * Shared metadata for the virtual machine. + */ + private SharedMetadata metadata; + + /** + * Creates an instance of VirtualMachineProperties class. + */ + public VirtualMachineProperties() { + } + + /** + * Get the provisioningState property: The provisioningState property. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the metadata property: Shared metadata for the virtual machine. + * + * @return the metadata value. + */ + public SharedMetadata metadata() { + return this.metadata; + } + + /** + * Set the metadata property: Shared metadata for the virtual machine. + * + * @param metadata the metadata value to set. + * @return the VirtualMachineProperties object itself. + */ + public VirtualMachineProperties withMetadata(SharedMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("metadata", this.metadata); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VirtualMachineProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VirtualMachineProperties if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the VirtualMachineProperties. + */ + public static VirtualMachineProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VirtualMachineProperties deserializedVirtualMachineProperties = new VirtualMachineProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedVirtualMachineProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("metadata".equals(fieldName)) { + deserializedVirtualMachineProperties.metadata = SharedMetadata.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedVirtualMachineProperties; + }); + } +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachines.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachines.java new file mode 100644 index 0000000000..4b91173eb9 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachines.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of VirtualMachines. + */ +public interface VirtualMachines { + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String vmName, Context context); + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param vmName The name of the VirtualMachine. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine. + */ + VirtualMachine getByResourceGroup(String resourceGroupName, String vmName); + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + VirtualMachine getById(String id); + + /** + * Retrieves information about the model view or the instance view of a virtual machine. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return describes a Virtual Machine along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new VirtualMachine resource. + * + * @param name resource name. + * @return the first stage of the new VirtualMachine definition. + */ + VirtualMachine.DefinitionStages.Blank define(String name); +} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/package-info.java new file mode 100644 index 0000000000..539bb429d0 --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiservicesharedmodels.combined.models; diff --git a/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/package-info.java b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/package-info.java new file mode 100644 index 0000000000..018dd4f5ee --- /dev/null +++ b/typespec-tests/src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Compute. + * Compute Client. + */ +package azure.resourcemanager.multiservicesharedmodels.combined; diff --git a/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_apiview_properties_older-versions.json b/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_apiview_properties_older-versions.json new file mode 100644 index 0000000000..002ec4e400 --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_apiview_properties_older-versions.json @@ -0,0 +1,22 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "azure.resourcemanager.multiserviceolderversions.combined.fluent.Combined": "Azure.ResourceManager.MultiServiceOlderVersions.Combined", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient": "Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient.beginCreateOrUpdate": "Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks.createOrUpdate", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient.createOrUpdate": "Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks.createOrUpdate", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient.getByResourceGroup": "Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks.get", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient.getByResourceGroupWithResponse": "Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks.get", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient": "Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient.beginCreateOrUpdate": "Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines.createOrUpdate", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient.createOrUpdate": "Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines.createOrUpdate", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient.getByResourceGroup": "Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines.get", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient.getByResourceGroupWithResponse": "Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines.get", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.models.DiskInner": "Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disk", + "azure.resourcemanager.multiserviceolderversions.combined.fluent.models.VirtualMachineInner": "Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachine", + "azure.resourcemanager.multiserviceolderversions.combined.implementation.CombinedBuilder": "Azure.ResourceManager.MultiServiceOlderVersions.Combined", + "azure.resourcemanager.multiserviceolderversions.combined.models.DiskProperties": "Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.DiskProperties", + "azure.resourcemanager.multiserviceolderversions.combined.models.ResourceProvisioningState": "Azure.ResourceManager.ResourceProvisioningState", + "azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachineProperties": "Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachineProperties" + } +} diff --git a/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_apiview_properties_shared-models.json b/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_apiview_properties_shared-models.json new file mode 100644 index 0000000000..306ae1cb8b --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_apiview_properties_shared-models.json @@ -0,0 +1,23 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.Combined": "Azure.ResourceManager.MultiServiceSharedModels.Combined", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient": "Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient.beginCreateOrUpdate": "Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts.createOrUpdate", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient.createOrUpdate": "Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts.createOrUpdate", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient.getByResourceGroup": "Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts.get", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient.getByResourceGroupWithResponse": "Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts.get", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient": "Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient.beginCreateOrUpdate": "Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines.createOrUpdate", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient.createOrUpdate": "Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines.createOrUpdate", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient.getByResourceGroup": "Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines.get", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient.getByResourceGroupWithResponse": "Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines.get", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.StorageAccountInner": "Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccount", + "azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.VirtualMachineInner": "Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachine", + "azure.resourcemanager.multiservicesharedmodels.combined.implementation.CombinedBuilder": "Azure.ResourceManager.MultiServiceSharedModels.Combined", + "azure.resourcemanager.multiservicesharedmodels.combined.models.ResourceProvisioningState": "Azure.ResourceManager.ResourceProvisioningState", + "azure.resourcemanager.multiservicesharedmodels.combined.models.SharedMetadata": "Azure.ResourceManager.MultiServiceSharedModels.Shared.SharedMetadata", + "azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccountProperties": "Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccountProperties", + "azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachineProperties": "Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachineProperties" + } +} diff --git a/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_metadata_older-versions.json b/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_metadata_older-versions.json new file mode 100644 index 0000000000..37b992ffa8 --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_metadata_older-versions.json @@ -0,0 +1 @@ +{"flavor":"Azure","crossLanguageDefinitions":{"azure.resourcemanager.multiserviceolderversions.combined.fluent.Combined":"Azure.ResourceManager.MultiServiceOlderVersions.Combined","azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient":"Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks","azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient.beginCreateOrUpdate":"Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks.createOrUpdate","azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient.createOrUpdate":"Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks.createOrUpdate","azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient.getByResourceGroup":"Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks.get","azure.resourcemanager.multiserviceolderversions.combined.fluent.DisksClient.getByResourceGroupWithResponse":"Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disks.get","azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient":"Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines","azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient.beginCreateOrUpdate":"Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines.createOrUpdate","azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient.createOrUpdate":"Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines.createOrUpdate","azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient.getByResourceGroup":"Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines.get","azure.resourcemanager.multiserviceolderversions.combined.fluent.VirtualMachinesClient.getByResourceGroupWithResponse":"Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachines.get","azure.resourcemanager.multiserviceolderversions.combined.fluent.models.DiskInner":"Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.Disk","azure.resourcemanager.multiserviceolderversions.combined.fluent.models.VirtualMachineInner":"Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachine","azure.resourcemanager.multiserviceolderversions.combined.implementation.CombinedBuilder":"Azure.ResourceManager.MultiServiceOlderVersions.Combined","azure.resourcemanager.multiserviceolderversions.combined.models.DiskProperties":"Azure.ResourceManager.MultiServiceOlderVersions.ComputeDisk.DiskProperties","azure.resourcemanager.multiserviceolderversions.combined.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachineProperties":"Azure.ResourceManager.MultiServiceOlderVersions.Compute.VirtualMachineProperties"},"generatedFiles":["src/main/java/azure/resourcemanager/multiserviceolderversions/combined/CombinedManager.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/Combined.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/DisksClient.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/VirtualMachinesClient.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/DiskInner.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/VirtualMachineInner.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/models/package-info.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/fluent/package-info.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedBuilder.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/CombinedImpl.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DiskImpl.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksClientImpl.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/DisksImpl.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/ResourceManagerUtils.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachineImpl.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesClientImpl.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/VirtualMachinesImpl.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/implementation/package-info.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disk.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/DiskProperties.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/Disks.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/ResourceProvisioningState.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachine.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachineProperties.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/VirtualMachines.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/models/package-info.java","src/main/java/azure/resourcemanager/multiserviceolderversions/combined/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_metadata_shared-models.json b/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_metadata_shared-models.json new file mode 100644 index 0000000000..3e3303bc35 --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/azure-resourcemanager-combined-generated_metadata_shared-models.json @@ -0,0 +1 @@ +{"flavor":"Azure","crossLanguageDefinitions":{"azure.resourcemanager.multiservicesharedmodels.combined.fluent.Combined":"Azure.ResourceManager.MultiServiceSharedModels.Combined","azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient":"Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts","azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient.beginCreateOrUpdate":"Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts.createOrUpdate","azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient.createOrUpdate":"Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts.createOrUpdate","azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient.getByResourceGroup":"Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts.get","azure.resourcemanager.multiservicesharedmodels.combined.fluent.StorageAccountsClient.getByResourceGroupWithResponse":"Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccounts.get","azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient":"Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines","azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient.beginCreateOrUpdate":"Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines.createOrUpdate","azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient.createOrUpdate":"Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines.createOrUpdate","azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient.getByResourceGroup":"Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines.get","azure.resourcemanager.multiservicesharedmodels.combined.fluent.VirtualMachinesClient.getByResourceGroupWithResponse":"Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachines.get","azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.StorageAccountInner":"Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccount","azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.VirtualMachineInner":"Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachine","azure.resourcemanager.multiservicesharedmodels.combined.implementation.CombinedBuilder":"Azure.ResourceManager.MultiServiceSharedModels.Combined","azure.resourcemanager.multiservicesharedmodels.combined.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","azure.resourcemanager.multiservicesharedmodels.combined.models.SharedMetadata":"Azure.ResourceManager.MultiServiceSharedModels.Shared.SharedMetadata","azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccountProperties":"Azure.ResourceManager.MultiServiceSharedModels.Storage.StorageAccountProperties","azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachineProperties":"Azure.ResourceManager.MultiServiceSharedModels.Compute.VirtualMachineProperties"},"generatedFiles":["src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/CombinedManager.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/Combined.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/StorageAccountsClient.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/VirtualMachinesClient.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/StorageAccountInner.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/VirtualMachineInner.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/models/package-info.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/fluent/package-info.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedBuilder.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/CombinedImpl.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/ResourceManagerUtils.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountImpl.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsClientImpl.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/StorageAccountsImpl.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachineImpl.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesClientImpl.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/VirtualMachinesImpl.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/implementation/package-info.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/ResourceProvisioningState.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/SharedMetadata.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccount.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccountProperties.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/StorageAccounts.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachine.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachineProperties.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/VirtualMachines.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/models/package-info.java","src/main/java/azure/resourcemanager/multiservicesharedmodels/combined/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_older-versions/proxy-config.json b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_older-versions/proxy-config.json new file mode 100644 index 0000000000..05dc52000a --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_older-versions/proxy-config.json @@ -0,0 +1 @@ +[["azure.resourcemanager.multiserviceolderversions.combined.implementation.DisksClientImpl$DisksService"],["azure.resourcemanager.multiserviceolderversions.combined.implementation.VirtualMachinesClientImpl$VirtualMachinesService"]] \ No newline at end of file diff --git a/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_older-versions/reflect-config.json b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_older-versions/reflect-config.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_older-versions/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_shared-models/proxy-config.json b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_shared-models/proxy-config.json new file mode 100644 index 0000000000..8b395b0e6f --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_shared-models/proxy-config.json @@ -0,0 +1 @@ +[["azure.resourcemanager.multiservicesharedmodels.combined.implementation.StorageAccountsClientImpl$StorageAccountsService"],["azure.resourcemanager.multiservicesharedmodels.combined.implementation.VirtualMachinesClientImpl$VirtualMachinesService"]] \ No newline at end of file diff --git a/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_shared-models/reflect-config.json b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_shared-models/reflect-config.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/typespec-tests/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-combined-generated_shared-models/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/ArmMultiServiceOlderVersionsTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/ArmMultiServiceOlderVersionsTests.java new file mode 100644 index 0000000000..1a704aa3a3 --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/ArmMultiServiceOlderVersionsTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azure.resourcemanager.multiserviceolderversions; + +import azure.resourcemanager.multiserviceolderversions.combined.CombinedManager; +import azure.resourcemanager.multiserviceolderversions.combined.models.DiskProperties; +import azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachineProperties; +import com.azure.core.management.Region; +import org.junit.jupiter.api.Test; +import org.utils.ArmUtils; + +public final class ArmMultiServiceOlderVersionsTests { + + 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("disk-old1") + .withRegion(REGION) + .withExistingResourceGroup(RESOURCE_GROUP_NAME) + .withProperties(new DiskProperties().withDiskSizeGB(128)) + .create(); + manager.disks().getByResourceGroup(RESOURCE_GROUP_NAME, "disk-old1"); + + manager.virtualMachines() + .define("vm-old1") + .withRegion(REGION) + .withExistingResourceGroup(RESOURCE_GROUP_NAME) + .withProperties(new VirtualMachineProperties().withSize("Standard_D2s_v3")) + .create(); + manager.virtualMachines().getByResourceGroup(RESOURCE_GROUP_NAME, "vm-old1"); + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/DiskInnerTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/DiskInnerTests.java new file mode 100644 index 0000000000..0d799efc91 --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/DiskInnerTests.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.generated; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.DiskInner; +import azure.resourcemanager.multiserviceolderversions.combined.models.DiskProperties; +import com.azure.core.util.BinaryData; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class DiskInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + DiskInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Canceled\",\"diskSizeGB\":1911349374},\"location\":\"ufpo\",\"tags\":{\"qsoqijgkd\":\"izhwlrxy\"},\"id\":\"bpazlobcufpdzn\",\"name\":\"btcqq\",\"type\":\"nq\"}") + .toObject(DiskInner.class); + Assertions.assertEquals("ufpo", model.location()); + Assertions.assertEquals("izhwlrxy", model.tags().get("qsoqijgkd")); + Assertions.assertEquals(1911349374, model.properties().diskSizeGB()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + DiskInner model = new DiskInner().withLocation("ufpo") + .withTags(mapOf("qsoqijgkd", "izhwlrxy")) + .withProperties(new DiskProperties().withDiskSizeGB(1911349374)); + model = BinaryData.fromObject(model).toObject(DiskInner.class); + Assertions.assertEquals("ufpo", model.location()); + Assertions.assertEquals("izhwlrxy", model.tags().get("qsoqijgkd")); + Assertions.assertEquals(1911349374, model.properties().diskSizeGB()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/DiskPropertiesTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/DiskPropertiesTests.java new file mode 100644 index 0000000000..c09cf61fb9 --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/DiskPropertiesTests.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.generated; + +import azure.resourcemanager.multiserviceolderversions.combined.models.DiskProperties; +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.Assertions; + +public final class DiskPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + DiskProperties model = BinaryData.fromString("{\"provisioningState\":\"Succeeded\",\"diskSizeGB\":2127527772}") + .toObject(DiskProperties.class); + Assertions.assertEquals(2127527772, model.diskSizeGB()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + DiskProperties model = new DiskProperties().withDiskSizeGB(2127527772); + model = BinaryData.fromObject(model).toObject(DiskProperties.class); + Assertions.assertEquals(2127527772, model.diskSizeGB()); + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/VirtualMachineInnerTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/VirtualMachineInnerTests.java new file mode 100644 index 0000000000..6a4592562a --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/VirtualMachineInnerTests.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.generated; + +import azure.resourcemanager.multiserviceolderversions.combined.fluent.models.VirtualMachineInner; +import azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachineProperties; +import com.azure.core.util.BinaryData; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class VirtualMachineInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + VirtualMachineInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Succeeded\",\"size\":\"uv\"},\"location\":\"xpyb\",\"tags\":{\"sphrupidgs\":\"ehmtzop\"},\"id\":\"bb\",\"name\":\"jhphoyc\",\"type\":\"sx\"}") + .toObject(VirtualMachineInner.class); + Assertions.assertEquals("xpyb", model.location()); + Assertions.assertEquals("ehmtzop", model.tags().get("sphrupidgs")); + Assertions.assertEquals("uv", model.properties().size()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + VirtualMachineInner model = new VirtualMachineInner().withLocation("xpyb") + .withTags(mapOf("sphrupidgs", "ehmtzop")) + .withProperties(new VirtualMachineProperties().withSize("uv")); + model = BinaryData.fromObject(model).toObject(VirtualMachineInner.class); + Assertions.assertEquals("xpyb", model.location()); + Assertions.assertEquals("ehmtzop", model.tags().get("sphrupidgs")); + Assertions.assertEquals("uv", model.properties().size()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/VirtualMachinePropertiesTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/VirtualMachinePropertiesTests.java new file mode 100644 index 0000000000..696397674e --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiserviceolderversions/combined/generated/VirtualMachinePropertiesTests.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiserviceolderversions.combined.generated; + +import azure.resourcemanager.multiserviceolderversions.combined.models.VirtualMachineProperties; +import com.azure.core.util.BinaryData; +import org.junit.jupiter.api.Assertions; + +public final class VirtualMachinePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + VirtualMachineProperties model + = BinaryData.fromString("{\"provisioningState\":\"Canceled\",\"size\":\"dxbmtqioq\"}") + .toObject(VirtualMachineProperties.class); + Assertions.assertEquals("dxbmtqioq", model.size()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + VirtualMachineProperties model = new VirtualMachineProperties().withSize("dxbmtqioq"); + model = BinaryData.fromObject(model).toObject(VirtualMachineProperties.class); + Assertions.assertEquals("dxbmtqioq", model.size()); + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/ArmMultiServiceSharedModelsTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/ArmMultiServiceSharedModelsTests.java new file mode 100644 index 0000000000..7dd7e97fb3 --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/ArmMultiServiceSharedModelsTests.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package azure.resourcemanager.multiservicesharedmodels; + +import azure.resourcemanager.multiservicesharedmodels.combined.CombinedManager; +import azure.resourcemanager.multiservicesharedmodels.combined.models.SharedMetadata; +import azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccountProperties; +import azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachineProperties; +import com.azure.core.management.Region; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.utils.ArmUtils; + +public final class ArmMultiServiceSharedModelsTests { + + private final CombinedManager manager + = CombinedManager.authenticate(ArmUtils.createTestHttpPipeline(), ArmUtils.getAzureProfile()); + + private static final String RESOURCE_GROUP_NAME = "test-rg"; + private static final Region REGION_STORAGE = Region.US_WEST; + private static final Region REGION_VM = Region.US_EAST; + + @Test + @Disabled("route in code is wrong: /Microsoft.Compute/storageAccounts/account1") + public void testCombinedClient() { + Map storageTags = new HashMap<>(); + storageTags.put("department", "engineering"); + SharedMetadata storageMetadata = new SharedMetadata().withCreatedBy("admin@example.com").withTags(storageTags); + + manager.storageAccounts() + .define("account1") + .withRegion(REGION_STORAGE) + .withExistingResourceGroup(RESOURCE_GROUP_NAME) + .withProperties(new StorageAccountProperties().withMetadata(storageMetadata)) + .create(); + manager.storageAccounts().getByResourceGroup(RESOURCE_GROUP_NAME, "account1"); + + Map vmTags = new HashMap<>(); + vmTags.put("environment", "production"); + SharedMetadata vmMetadata = new SharedMetadata().withCreatedBy("user@example.com").withTags(vmTags); + + manager.virtualMachines() + .define("vm-shared1") + .withRegion(REGION_VM) + .withExistingResourceGroup(RESOURCE_GROUP_NAME) + .withProperties(new VirtualMachineProperties().withMetadata(vmMetadata)) + .create(); + manager.virtualMachines().getByResourceGroup(RESOURCE_GROUP_NAME, "vm-shared1"); + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/SharedMetadataTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/SharedMetadataTests.java new file mode 100644 index 0000000000..9032d3f2fc --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/SharedMetadataTests.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.generated; + +import azure.resourcemanager.multiservicesharedmodels.combined.models.SharedMetadata; +import com.azure.core.util.BinaryData; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class SharedMetadataTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SharedMetadata model = BinaryData.fromString( + "{\"createdAt\":\"2021-04-06T23:33:47Z\",\"createdBy\":\"arhmofcqhsmy\",\"tags\":{\"ukcdmparcryuanzw\":\"dtmlxhekuksjt\",\"pmrqobm\":\"xzdxtayrlhmwh\",\"knryrtihfxtij\":\"u\"}}") + .toObject(SharedMetadata.class); + Assertions.assertEquals(OffsetDateTime.parse("2021-04-06T23:33:47Z"), model.createdAt()); + Assertions.assertEquals("arhmofcqhsmy", model.createdBy()); + Assertions.assertEquals("dtmlxhekuksjt", model.tags().get("ukcdmparcryuanzw")); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SharedMetadata model = new SharedMetadata().withCreatedAt(OffsetDateTime.parse("2021-04-06T23:33:47Z")) + .withCreatedBy("arhmofcqhsmy") + .withTags(mapOf("ukcdmparcryuanzw", "dtmlxhekuksjt", "pmrqobm", "xzdxtayrlhmwh", "knryrtihfxtij", "u")); + model = BinaryData.fromObject(model).toObject(SharedMetadata.class); + Assertions.assertEquals(OffsetDateTime.parse("2021-04-06T23:33:47Z"), model.createdAt()); + Assertions.assertEquals("arhmofcqhsmy", model.createdBy()); + Assertions.assertEquals("dtmlxhekuksjt", model.tags().get("ukcdmparcryuanzw")); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/StorageAccountInnerTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/StorageAccountInnerTests.java new file mode 100644 index 0000000000..20c316abb2 --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/StorageAccountInnerTests.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.generated; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.StorageAccountInner; +import azure.resourcemanager.multiservicesharedmodels.combined.models.SharedMetadata; +import azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccountProperties; +import com.azure.core.util.BinaryData; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class StorageAccountInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + StorageAccountInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Canceled\",\"metadata\":{\"createdAt\":\"2021-10-14T13:51:33Z\",\"createdBy\":\"symglzufcyz\",\"tags\":{\"s\":\"dbihanufhfcbj\",\"xqhabi\":\"git\"}}},\"location\":\"ikxwc\",\"tags\":{\"n\":\"scnpqxuhivy\",\"rkxvdum\":\"wby\"},\"id\":\"grtfwvu\",\"name\":\"xgaudccs\",\"type\":\"h\"}") + .toObject(StorageAccountInner.class); + Assertions.assertEquals("ikxwc", model.location()); + Assertions.assertEquals("scnpqxuhivy", model.tags().get("n")); + Assertions.assertEquals(OffsetDateTime.parse("2021-10-14T13:51:33Z"), + model.properties().metadata().createdAt()); + Assertions.assertEquals("symglzufcyz", model.properties().metadata().createdBy()); + Assertions.assertEquals("dbihanufhfcbj", model.properties().metadata().tags().get("s")); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + StorageAccountInner model = new StorageAccountInner().withLocation("ikxwc") + .withTags(mapOf("n", "scnpqxuhivy", "rkxvdum", "wby")) + .withProperties(new StorageAccountProperties() + .withMetadata(new SharedMetadata().withCreatedAt(OffsetDateTime.parse("2021-10-14T13:51:33Z")) + .withCreatedBy("symglzufcyz") + .withTags(mapOf("s", "dbihanufhfcbj", "xqhabi", "git")))); + model = BinaryData.fromObject(model).toObject(StorageAccountInner.class); + Assertions.assertEquals("ikxwc", model.location()); + Assertions.assertEquals("scnpqxuhivy", model.tags().get("n")); + Assertions.assertEquals(OffsetDateTime.parse("2021-10-14T13:51:33Z"), + model.properties().metadata().createdAt()); + Assertions.assertEquals("symglzufcyz", model.properties().metadata().createdBy()); + Assertions.assertEquals("dbihanufhfcbj", model.properties().metadata().tags().get("s")); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/StorageAccountPropertiesTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/StorageAccountPropertiesTests.java new file mode 100644 index 0000000000..78f8a9c2c2 --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/StorageAccountPropertiesTests.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.generated; + +import azure.resourcemanager.multiservicesharedmodels.combined.models.SharedMetadata; +import azure.resourcemanager.multiservicesharedmodels.combined.models.StorageAccountProperties; +import com.azure.core.util.BinaryData; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class StorageAccountPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + StorageAccountProperties model = BinaryData.fromString( + "{\"provisioningState\":\"Canceled\",\"metadata\":{\"createdAt\":\"2021-08-18T11:52:54Z\",\"createdBy\":\"hkryhtn\",\"tags\":{\"okjye\":\"zw\",\"jnchgej\":\"kkvnipjox\",\"huxinpmqnj\":\"podmailzydehojwy\"}}}") + .toObject(StorageAccountProperties.class); + Assertions.assertEquals(OffsetDateTime.parse("2021-08-18T11:52:54Z"), model.metadata().createdAt()); + Assertions.assertEquals("hkryhtn", model.metadata().createdBy()); + Assertions.assertEquals("zw", model.metadata().tags().get("okjye")); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + StorageAccountProperties model = new StorageAccountProperties() + .withMetadata(new SharedMetadata().withCreatedAt(OffsetDateTime.parse("2021-08-18T11:52:54Z")) + .withCreatedBy("hkryhtn") + .withTags(mapOf("okjye", "zw", "jnchgej", "kkvnipjox", "huxinpmqnj", "podmailzydehojwy"))); + model = BinaryData.fromObject(model).toObject(StorageAccountProperties.class); + Assertions.assertEquals(OffsetDateTime.parse("2021-08-18T11:52:54Z"), model.metadata().createdAt()); + Assertions.assertEquals("hkryhtn", model.metadata().createdBy()); + Assertions.assertEquals("zw", model.metadata().tags().get("okjye")); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/VirtualMachineInnerTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/VirtualMachineInnerTests.java new file mode 100644 index 0000000000..b848baf9f8 --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/VirtualMachineInnerTests.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.generated; + +import azure.resourcemanager.multiservicesharedmodels.combined.fluent.models.VirtualMachineInner; +import azure.resourcemanager.multiservicesharedmodels.combined.models.SharedMetadata; +import azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachineProperties; +import com.azure.core.util.BinaryData; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class VirtualMachineInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + VirtualMachineInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Succeeded\",\"metadata\":{\"createdAt\":\"2021-07-30T08:26:42Z\",\"createdBy\":\"jxpybczmeh\",\"tags\":{\"phrupidgsybbejhp\":\"opb\",\"ioq\":\"oycmsxaobhdxbmt\",\"p\":\"zehtbmu\",\"hwlrx\":\"wnoi\"}}},\"location\":\"qsoqijgkd\",\"tags\":{\"qqjnqgl\":\"azlobcufpdznrbt\",\"foooj\":\"qgn\",\"saagdf\":\"wifsq\"},\"id\":\"glzlhjxrifkwmrv\",\"name\":\"tsizntocipaoua\",\"type\":\"psqucmpoyf\"}") + .toObject(VirtualMachineInner.class); + Assertions.assertEquals("qsoqijgkd", model.location()); + Assertions.assertEquals("azlobcufpdznrbt", model.tags().get("qqjnqgl")); + Assertions.assertEquals(OffsetDateTime.parse("2021-07-30T08:26:42Z"), + model.properties().metadata().createdAt()); + Assertions.assertEquals("jxpybczmeh", model.properties().metadata().createdBy()); + Assertions.assertEquals("opb", model.properties().metadata().tags().get("phrupidgsybbejhp")); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + VirtualMachineInner model + = new VirtualMachineInner().withLocation("qsoqijgkd") + .withTags(mapOf("qqjnqgl", "azlobcufpdznrbt", "foooj", "qgn", "saagdf", "wifsq")) + .withProperties(new VirtualMachineProperties().withMetadata(new SharedMetadata() + .withCreatedAt(OffsetDateTime.parse("2021-07-30T08:26:42Z")) + .withCreatedBy("jxpybczmeh") + .withTags( + mapOf("phrupidgsybbejhp", "opb", "ioq", "oycmsxaobhdxbmt", "p", "zehtbmu", "hwlrx", "wnoi")))); + model = BinaryData.fromObject(model).toObject(VirtualMachineInner.class); + Assertions.assertEquals("qsoqijgkd", model.location()); + Assertions.assertEquals("azlobcufpdznrbt", model.tags().get("qqjnqgl")); + Assertions.assertEquals(OffsetDateTime.parse("2021-07-30T08:26:42Z"), + model.properties().metadata().createdAt()); + Assertions.assertEquals("jxpybczmeh", model.properties().metadata().createdBy()); + Assertions.assertEquals("opb", model.properties().metadata().tags().get("phrupidgsybbejhp")); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/VirtualMachinePropertiesTests.java b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/VirtualMachinePropertiesTests.java new file mode 100644 index 0000000000..81302f836b --- /dev/null +++ b/typespec-tests/src/test/java/azure/resourcemanager/multiservicesharedmodels/combined/generated/VirtualMachinePropertiesTests.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package azure.resourcemanager.multiservicesharedmodels.combined.generated; + +import azure.resourcemanager.multiservicesharedmodels.combined.models.SharedMetadata; +import azure.resourcemanager.multiservicesharedmodels.combined.models.VirtualMachineProperties; +import com.azure.core.util.BinaryData; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class VirtualMachinePropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + VirtualMachineProperties model = BinaryData.fromString( + "{\"provisioningState\":\"Failed\",\"metadata\":{\"createdAt\":\"2021-01-23T06:12:50Z\",\"createdBy\":\"ygjofjdd\",\"tags\":{\"upewnwreitjzy\":\"rd\"}}}") + .toObject(VirtualMachineProperties.class); + Assertions.assertEquals(OffsetDateTime.parse("2021-01-23T06:12:50Z"), model.metadata().createdAt()); + Assertions.assertEquals("ygjofjdd", model.metadata().createdBy()); + Assertions.assertEquals("rd", model.metadata().tags().get("upewnwreitjzy")); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + VirtualMachineProperties model = new VirtualMachineProperties() + .withMetadata(new SharedMetadata().withCreatedAt(OffsetDateTime.parse("2021-01-23T06:12:50Z")) + .withCreatedBy("ygjofjdd") + .withTags(mapOf("upewnwreitjzy", "rd"))); + model = BinaryData.fromObject(model).toObject(VirtualMachineProperties.class); + Assertions.assertEquals(OffsetDateTime.parse("2021-01-23T06:12:50Z"), model.metadata().createdAt()); + Assertions.assertEquals("ygjofjdd", model.metadata().createdBy()); + Assertions.assertEquals("rd", model.metadata().tags().get("upewnwreitjzy")); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} From 73db9143d9ef3b806d4ec45782f015c8e8356529 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 19 Jan 2026 13:14:30 +0800 Subject: [PATCH 15/17] Update changelog.md --- typespec-extension/changelog.md | 1 - 1 file changed, 1 deletion(-) diff --git a/typespec-extension/changelog.md b/typespec-extension/changelog.md index 494293313c..ef411a6ca7 100644 --- a/typespec-extension/changelog.md +++ b/typespec-extension/changelog.md @@ -5,7 +5,6 @@ Compatible with compiler 1.8.0. - Updated package dependencies to the latest versions. -- Synced generator test harness to include multi-service client metadata updates. ## 0.38.3 (2026-01-15) From d06904360bb448eee4a624695218eb6c17c1bdac Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 19 Jan 2026 13:15:54 +0800 Subject: [PATCH 16/17] bump openai-typespec --- typespec-extension/package-lock.json | 8 ++++---- typespec-extension/package.json | 2 +- typespec-tests/Generate.ps1 | 6 ------ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/typespec-extension/package-lock.json b/typespec-extension/package-lock.json index b37717af52..39d0c9bb53 100644 --- a/typespec-extension/package-lock.json +++ b/typespec-extension/package-lock.json @@ -14,7 +14,7 @@ "lodash": "~4.17.21" }, "devDependencies": { - "@azure-tools/openai-typespec": "^1.6.1", + "@azure-tools/openai-typespec": "^1.6.2", "@azure-tools/typespec-autorest": "0.64.0", "@azure-tools/typespec-azure-core": "0.64.0", "@azure-tools/typespec-azure-resource-manager": "0.64.0", @@ -147,9 +147,9 @@ } }, "node_modules/@azure-tools/openai-typespec": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/@azure-tools/openai-typespec/-/openai-typespec-1.6.1.tgz", - "integrity": "sha512-K9AhZYV3yQymgTBkGAguprHTgXwfojbZu4QnyHy1u0aDpMZmfWbYzex41a8blBTcLDc4wslfHpocIU2bAl7OTQ==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@azure-tools/openai-typespec/-/openai-typespec-1.6.2.tgz", + "integrity": "sha512-u2Y8ZS6OMO9lUbSyYgBiDuGQkF/ccv9qk6ipvDwu+vZmxRx2c9Zp2VOcC6dxWNOT62DWjlfmbJQy7E/fNaQVrw==", "dev": true, "license": "MIT", "peerDependencies": { diff --git a/typespec-extension/package.json b/typespec-extension/package.json index 05f4d02d8b..5c6a0f2943 100644 --- a/typespec-extension/package.json +++ b/typespec-extension/package.json @@ -73,7 +73,7 @@ "@azure-tools/typespec-azure-rulesets": "0.64.0", "@azure-tools/typespec-client-generator-core": "0.64.1", "@azure-tools/typespec-liftr-base": "0.11.0", - "@azure-tools/openai-typespec": "^1.6.1", + "@azure-tools/openai-typespec": "^1.6.2", "@microsoft/api-extractor": "^7.55.2", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.23", diff --git a/typespec-tests/Generate.ps1 b/typespec-tests/Generate.ps1 index 0fa9fb23d0..1049a9e38a 100644 --- a/typespec-tests/Generate.ps1 +++ b/typespec-tests/Generate.ps1 @@ -214,12 +214,6 @@ try { Remove-Item ./tsp-output -Recurse -Force - $clientStructureMetadataPath = Join-Path ./src/main/resources/META-INF "client-structure-service_metadata.json" - if (Test-Path $clientStructureMetadataPath) { - # avoid nondeterminism when multiple client.tsp files contribute metadata - Remove-Item $clientStructureMetadataPath -Force - } - if ($ExitCode -ne 0) { throw "Failed to generate from tsp" } From 747304854101f570a012e8f7a19e62fd05589622 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Mon, 19 Jan 2026 14:23:27 +0800 Subject: [PATCH 17/17] bump core --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index abff860be4..1e3aa033c5 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit abff860be431238f261dfd366b3a7b6976794686 +Subproject commit 1e3aa033c5e3bf783025d010ab7e841b2b7c27c9