diff --git a/core b/core index 9d36399467..b1176f532e 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 9d36399467552cabb0efae447ad9552bc4873acc +Subproject commit b1176f532e715bde413d3c61d8eb52ef8c7b5dfc diff --git a/fluent-tests/Initialize-Tests.ps1 b/fluent-tests/Initialize-Tests.ps1 index 68007f78f4..18fa3cef5c 100644 --- a/fluent-tests/Initialize-Tests.ps1 +++ b/fluent-tests/Initialize-Tests.ps1 @@ -75,7 +75,7 @@ SUCCEEDED $job = @( # fluent premium - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/resources/resource-manager/Microsoft.Resources/stable/2019-08-01/resources.json --namespace=com.azure.mgmttest.resources --enable-sync-stack=false", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/resources/resource-manager/Microsoft.Resources/stable/2019-08-01/resources.json --namespace=com.azure.mgmttest.resources --enable-sync-stack=false", "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS ./swagger/readme.storage.md --namespace=com.azure.mgmttest.storage --enable-sync-stack=false", "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS ./swagger/readme.network.md --namespace=com.azure.mgmttest.network --enable-sync-stack=false", @@ -83,34 +83,34 @@ $job = @( "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS ./swagger/readme.appservice.md --namespace=com.azure.mgmttest.appservice --enable-sync-stack=false", # multiple inheritance - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/DocumentDB/stable/2019-08-01/cosmos-db.json --namespace=com.azure.mgmttest.cosmos --enable-sync-stack=false", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/DocumentDB/stable/2019-08-01/cosmos-db.json --namespace=com.azure.mgmttest.cosmos --enable-sync-stack=false", # flatten payload - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2021-03-01/cloudService.json --namespace=com.azure.mgmttest.compute --enable-sync-stack=false", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2021-03-01/cloudService.json --namespace=com.azure.mgmttest.compute --enable-sync-stack=false", # error response that not conform to ARM "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/e3dcc10ab749ed6731255aebec7d3214eda10da0/specification/graphrbac/data-plane/GraphRbac/stable/1.6/graphrbac.json --namespace=com.azure.mgmttest.authorization --enable-sync-stack=false", # client model flatten at autorest.java - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2020-09-30/sharedGallery.json --namespace=com.azure.mgmttest.computegallery --enable-sync-stack=false", - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/network/resource-manager/Microsoft.Network/stable/2021-02-01/networkWatcher.json --namespace=com.azure.mgmttest.networkwatcher --enable-sync-stack=false", - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/cdn/resource-manager/Microsoft.Cdn/Cdn/stable/2020-09-01/afdx.json --namespace=com.azure.mgmttest.afdx --enable-sync-stack=false", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2020-09-30/sharedGallery.json --namespace=com.azure.mgmttest.computegallery --enable-sync-stack=false", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/network/resource-manager/Microsoft.Network/stable/2021-02-01/networkWatcher.json --namespace=com.azure.mgmttest.networkwatcher --enable-sync-stack=false", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/cdn/resource-manager/Microsoft.Cdn/Cdn/stable/2020-09-01/afdx.json --namespace=com.azure.mgmttest.afdx --enable-sync-stack=false", # nested x-ms-flatten from superclass in ExtendedProduct - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/azurestack/resource-manager/Microsoft.AzureStack/AzureStack/preview/2020-06-01-preview/Product.json --namespace=com.azure.mgmttest.azurestack --stream-style-serialization=false", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/azurestack/resource-manager/Microsoft.AzureStack/AzureStack/preview/2020-06-01-preview/Product.json --namespace=com.azure.mgmttest.azurestack --stream-style-serialization=false", # conflict property name from 2 x-ms-flatten in LabDetails and LabProperties - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/education/resource-manager/Microsoft.Education/Education/preview/2021-12-01-preview/education.json --namespace=com.azure.mgmttest.education", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/education/resource-manager/Microsoft.Education/Education/preview/2021-12-01-preview/education.json --namespace=com.azure.mgmttest.education", # do not flatten if polymorphic in DevicePropertiesFormat - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2021-05-01/device.json --namespace=com.azure.mgmttest.hybridnetwork", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2021-05-01/device.json --namespace=com.azure.mgmttest.hybridnetwork", # flatten the empty model which has non-empty parent model - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-09-01-preview/dataCollectionRules_API.json --namespace=com.azure.mgmttest.monitor --stream-style-serialization=false --enable-sync-stack=false", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/monitor/resource-manager/Microsoft.Insights/preview/2021-09-01-preview/dataCollectionRules_API.json --namespace=com.azure.mgmttest.monitor --stream-style-serialization=false --enable-sync-stack=false", # extract systemData from Resource "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/29f3116d3ce31f2125d1e2cfb92d6511fcb01c41/specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/postgresqlhsc.json --java.namespace=com.azure.mgmttest.postgresqlhsc", # swagger customized Resource and ProxyResource - "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/trafficmanager/resource-manager/Microsoft.Network/TrafficManager/stable/2018-08-01/trafficmanager.json --namespace=com.azure.mgmttest.trafficmanager --enable-sync-stack=false", + "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/trafficmanager/resource-manager/Microsoft.Network/TrafficManager/stable/2018-08-01/trafficmanager.json --namespace=com.azure.mgmttest.trafficmanager --enable-sync-stack=false", # ErrorDetails shared in exception and output "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/8fa9b5051129dd4808c9be1f5b753af226b044db/specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/iothub.json --namespace=com.azure.mgmttest.iothub", @@ -121,16 +121,16 @@ $job = @( "--version=$AUTOREST_CORE_VERSION $FLUENT_ARGUMENTS --regenerate-pom=false --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/926540515b9d8059904f023d38c45dda8ba87c9f/specification/monitor/resource-manager/Microsoft.Insights/stable/2023-12-01/scheduledQueryRule_API.json --java.namespace=com.azure.mgmttest.nonstringexpandableenum --enable-sync-stack=false" # fluent lite - "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --pom-file=pom_generated_resources.xml https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/resources/resource-manager/readme.md --tag=package-resources-2021-01 --java.namespace=com.azure.mgmtlitetest.resources", + "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --pom-file=pom_generated_resources.xml https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/resources/resource-manager/readme.md --tag=package-resources-2021-01 --java.namespace=com.azure.mgmtlitetest.resources", "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/da0cfefaa0e6c237e1e3819f1cb2e11d7606878d/specification/storage/resource-manager/readme.md --tag=package-2021-01 --java.namespace=com.azure.mgmtlitetest.storage", - "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/advisor/resource-manager/Microsoft.Advisor/Advisor/readme.md --tag=package-2020-01 --java.namespace=com.azure.mgmtlitetest.advisor", + "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/advisor/resource-manager/Microsoft.Advisor/Advisor/readme.md --tag=package-2020-01 --java.namespace=com.azure.mgmtlitetest.advisor", - "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/resources/resource-manager/readme.md --tag=package-policy-2020-09 --java.namespace=com.azure.mgmtlitetest.policy", + "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/resources/resource-manager/readme.md --tag=package-policy-2020-09 --java.namespace=com.azure.mgmtlitetest.policy", # UUID subscriptionId "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0a2eb0d14f5132fcfd30222d584acf67713332ea/specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/containerregistry.json --namespace=com.azure.mgmtlitetest.containerregistrylite", # multiple inheritance with conflict field - "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/botservice/resource-manager/Microsoft.BotService/BotService/readme.md --tag=package-preview-2021-05 --java.namespace=com.azure.mgmtlitetest.botservice", + "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/botservice/resource-manager/Microsoft.BotService/BotService/readme.md --tag=package-preview-2021-05 --java.namespace=com.azure.mgmtlitetest.botservice", # model inherit ErrorResponse "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/196886564583ff59186bd0ef44d923120aaf3f78/specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/NetworkFabrics.json --java.namespace=com.azure.mgmtlitetest.managednetworkfabric", @@ -158,8 +158,8 @@ $job = @( # special cases "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=./swagger/sync-stack.json --namespace=com.azure.mgmtlitetest.syncstack --enable-sync-stack=true" - # "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/network/resource-manager/readme.md --tag=package-2020-06 --java.namespace=com.azure.mgmtlitetest.network" - # "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/compute/resource-manager/readme.md --tag=package-2020-06-30 --java.namespace=com.azure.mgmtlitetest.compute" + # "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/network/resource-manager/readme.md --tag=package-2020-06 --java.namespace=com.azure.mgmtlitetest.network" + # "--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/113b466bf76cd86da547beee5300d2ef5210cfb3/specification/compute/resource-manager/readme.md --tag=package-2020-06-30 --java.namespace=com.azure.mgmtlitetest.compute" ) | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob $job | Wait-Job -Timeout 3600 diff --git a/protocol-sdk-integration-tests/data-specs.json b/protocol-sdk-integration-tests/data-specs.json index aaef5da585..167648d732 100644 --- a/protocol-sdk-integration-tests/data-specs.json +++ b/protocol-sdk-integration-tests/data-specs.json @@ -1,7 +1,7 @@ { "purview-account": { "input": [ - "https://github.com/Azure/azure-rest-api-specs/blob/main/specification/purview/data-plane/Azure.Analytics.Purview.Account/preview/2019-11-01-preview/account.json" + "https://github.com/Azure/azure-rest-api-specs/blob/main/specification/purview/data-plane/account/preview/2019-11-01-preview/account.json" ], "group": "purview", "module": "azure-analytics-purview-account", diff --git a/typespec-tests/src/main/java/tsptest/armresourceprovider/fluent/LroNoBodiesClient.java b/typespec-tests/src/main/java/tsptest/armresourceprovider/fluent/LroNoBodiesClient.java index 91a53f9061..2bdefd6ca4 100644 --- a/typespec-tests/src/main/java/tsptest/armresourceprovider/fluent/LroNoBodiesClient.java +++ b/typespec-tests/src/main/java/tsptest/armresourceprovider/fluent/LroNoBodiesClient.java @@ -14,6 +14,7 @@ import java.nio.ByteBuffer; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import tsptest.armresourceprovider.models.ActionFinalResult; import tsptest.armresourceprovider.models.ResourceLroNoBody; /** @@ -126,4 +127,100 @@ ResourceLroNoBody createOrUpdate(String resourceGroupName, String resourceLroNoB @ServiceMethod(returns = ReturnType.SINGLE) ResourceLroNoBody createOrUpdate(String resourceGroupName, String resourceLroNoBodyName, ResourceLroNoBody resource, Context context); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Mono>> actionWithResponseAsync(String resourceGroupName, String resourceLroNoBodyName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + PollerFlux, ActionFinalResult> beginActionAsync(String resourceGroupName, + String resourceLroNoBodyName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ActionFinalResult> beginAction(String resourceGroupName, + String resourceLroNoBodyName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, ActionFinalResult> beginAction(String resourceGroupName, + String resourceLroNoBodyName, Context context); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response body on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Mono actionAsync(String resourceGroupName, String resourceLroNoBodyName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName, Context context); } diff --git a/typespec-tests/src/main/java/tsptest/armresourceprovider/implementation/LroNoBodiesClientImpl.java b/typespec-tests/src/main/java/tsptest/armresourceprovider/implementation/LroNoBodiesClientImpl.java index c80c8191c6..4c9b682e39 100644 --- a/typespec-tests/src/main/java/tsptest/armresourceprovider/implementation/LroNoBodiesClientImpl.java +++ b/typespec-tests/src/main/java/tsptest/armresourceprovider/implementation/LroNoBodiesClientImpl.java @@ -11,6 +11,7 @@ import com.azure.core.annotation.Host; import com.azure.core.annotation.HostParam; import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; import com.azure.core.annotation.Put; import com.azure.core.annotation.QueryParam; import com.azure.core.annotation.ReturnType; @@ -30,6 +31,7 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import tsptest.armresourceprovider.fluent.LroNoBodiesClient; +import tsptest.armresourceprovider.models.ActionFinalResult; import tsptest.armresourceprovider.models.ResourceLroNoBody; /** @@ -85,6 +87,26 @@ Response createOrUpdateSync(@HostParam("endpoint") String endpoint, @PathParam("resourceLroNoBodyName") String resourceLroNoBodyName, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") ResourceLroNoBody resource, Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmResourceProvider/resourceLroNoBody/{resourceLroNoBodyName}/action") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> action(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("resourceLroNoBodyName") String resourceLroNoBodyName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Post("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/TspTest.ArmResourceProvider/resourceLroNoBody/{resourceLroNoBodyName}/action") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response actionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("resourceLroNoBodyName") String resourceLroNoBodyName, @HeaderParam("Accept") String accept, + Context context); } /** @@ -261,4 +283,162 @@ public ResourceLroNoBody createOrUpdate(String resourceGroupName, String resourc ResourceLroNoBody resource, Context context) { return beginCreateOrUpdate(resourceGroupName, resourceLroNoBodyName, resource, context).getFinalResult(); } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono>> actionWithResponseAsync(String resourceGroupName, + String resourceLroNoBodyName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.action(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, resourceLroNoBodyName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response actionWithResponse(String resourceGroupName, String resourceLroNoBodyName) { + final String accept = "application/json"; + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, resourceLroNoBodyName, accept, Context.NONE); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response actionWithResponse(String resourceGroupName, String resourceLroNoBodyName, + Context context) { + final String accept = "application/json"; + return service.actionSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, resourceLroNoBodyName, accept, context); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux, ActionFinalResult> beginActionAsync(String resourceGroupName, + String resourceLroNoBodyName) { + Mono>> mono = actionWithResponseAsync(resourceGroupName, resourceLroNoBodyName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + ActionFinalResult.class, ActionFinalResult.class, this.client.getContext()); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ActionFinalResult> beginAction(String resourceGroupName, + String resourceLroNoBodyName) { + Response response = actionWithResponse(resourceGroupName, resourceLroNoBodyName); + return this.client.getLroResult(response, ActionFinalResult.class, + ActionFinalResult.class, Context.NONE); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, ActionFinalResult> beginAction(String resourceGroupName, + String resourceLroNoBodyName, Context context) { + Response response = actionWithResponse(resourceGroupName, resourceLroNoBodyName, context); + return this.client.getLroResult(response, ActionFinalResult.class, + ActionFinalResult.class, context); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response body on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono actionAsync(String resourceGroupName, String resourceLroNoBodyName) { + return beginActionAsync(resourceGroupName, resourceLroNoBodyName).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName) { + return beginAction(resourceGroupName, resourceLroNoBodyName).getFinalResult(); + } + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName, Context context) { + return beginAction(resourceGroupName, resourceLroNoBodyName, context).getFinalResult(); + } } diff --git a/typespec-tests/src/main/java/tsptest/armresourceprovider/implementation/LroNoBodiesImpl.java b/typespec-tests/src/main/java/tsptest/armresourceprovider/implementation/LroNoBodiesImpl.java index 5945af22c1..7a5929e932 100644 --- a/typespec-tests/src/main/java/tsptest/armresourceprovider/implementation/LroNoBodiesImpl.java +++ b/typespec-tests/src/main/java/tsptest/armresourceprovider/implementation/LroNoBodiesImpl.java @@ -7,6 +7,7 @@ import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; import tsptest.armresourceprovider.fluent.LroNoBodiesClient; +import tsptest.armresourceprovider.models.ActionFinalResult; import tsptest.armresourceprovider.models.LroNoBodies; import tsptest.armresourceprovider.models.ResourceLroNoBody; @@ -33,6 +34,14 @@ public ResourceLroNoBody createOrUpdate(String resourceGroupName, String resourc return this.serviceClient().createOrUpdate(resourceGroupName, resourceLroNoBodyName, resource, context); } + public ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName) { + return this.serviceClient().action(resourceGroupName, resourceLroNoBodyName); + } + + public ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName, Context context) { + return this.serviceClient().action(resourceGroupName, resourceLroNoBodyName, context); + } + private LroNoBodiesClient serviceClient() { return this.innerClient; } diff --git a/typespec-tests/src/main/java/tsptest/armresourceprovider/models/ActionFinalResult.java b/typespec-tests/src/main/java/tsptest/armresourceprovider/models/ActionFinalResult.java new file mode 100644 index 0000000000..270046ccb1 --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/armresourceprovider/models/ActionFinalResult.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.armresourceprovider.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 ActionFinalResult model. + */ +@Immutable +public final class ActionFinalResult implements JsonSerializable { + /* + * The result property. + */ + private String result; + + /** + * Creates an instance of ActionFinalResult class. + */ + private ActionFinalResult() { + } + + /** + * Get the result property: The result property. + * + * @return the result value. + */ + public String result() { + return this.result; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("result", this.result); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActionFinalResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActionFinalResult 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 ActionFinalResult. + */ + public static ActionFinalResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ActionFinalResult deserializedActionFinalResult = new ActionFinalResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("result".equals(fieldName)) { + deserializedActionFinalResult.result = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedActionFinalResult; + }); + } +} diff --git a/typespec-tests/src/main/java/tsptest/armresourceprovider/models/LroNoBodies.java b/typespec-tests/src/main/java/tsptest/armresourceprovider/models/LroNoBodies.java index 975db880ef..68f73d0a5e 100644 --- a/typespec-tests/src/main/java/tsptest/armresourceprovider/models/LroNoBodies.java +++ b/typespec-tests/src/main/java/tsptest/armresourceprovider/models/LroNoBodies.java @@ -38,4 +38,29 @@ ResourceLroNoBody createOrUpdate(String resourceGroupName, String resourceLroNoB */ ResourceLroNoBody createOrUpdate(String resourceGroupName, String resourceLroNoBodyName, ResourceLroNoBody resource, Context context); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response. + */ + ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName); + + /** + * A long-running resource action. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceLroNoBodyName The name of the ResourceLroNoBody. + * @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 response. + */ + ActionFinalResult action(String resourceGroupName, String resourceLroNoBodyName, Context context); } diff --git a/typespec-tests/src/test/java/tsptest/arm/LroResponseTests.java b/typespec-tests/src/test/java/tsptest/arm/LroResponseTests.java new file mode 100644 index 0000000000..a8f9f19908 --- /dev/null +++ b/typespec-tests/src/test/java/tsptest/arm/LroResponseTests.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package tsptest.arm; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import tsptest.armresourceprovider.ArmResourceProviderManager; +import tsptest.armresourceprovider.models.ActionFinalResult; + +public class LroResponseTests { + + // compile pass + public void testLroActionFinalResponse() { + ArmResourceProviderManager manager = Mockito.mock(ArmResourceProviderManager.class); + ActionFinalResult actionFinalResult = manager.lroNoBodies().action("resourceGroup", "name"); + } + + @Test + public void testLroActionInitiateResponseNotGenerated() throws ClassNotFoundException { + // ActionFinalResult generated + this.getClass().getClassLoader().loadClass("tsptest.armresourceprovider.models.ActionFinalResult"); + // ActionInitiateResult not generated + Assertions.assertThrows(ClassNotFoundException.class, () -> { + this.getClass().getClassLoader().loadClass("tsptest.armresourceprovider.models.ActionInitiateResult"); + }); + } +} diff --git a/typespec-tests/src/test/java/tsptest/armstreamstyleserialization/StreamStyleSerializationTests.java b/typespec-tests/src/test/java/tsptest/armstreamstyleserialization/StreamStyleSerializationTests.java index a61869ea74..e60cde20dd 100644 --- a/typespec-tests/src/test/java/tsptest/armstreamstyleserialization/StreamStyleSerializationTests.java +++ b/typespec-tests/src/test/java/tsptest/armstreamstyleserialization/StreamStyleSerializationTests.java @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + package tsptest.armstreamstyleserialization; import com.azure.core.http.HttpClient; diff --git a/typespec-tests/tsp/arm.tsp b/typespec-tests/tsp/arm.tsp index a89ad2ff66..ba69491510 100644 --- a/typespec-tests/tsp/arm.tsp +++ b/typespec-tests/tsp/arm.tsp @@ -272,6 +272,16 @@ model ResourceLroNoBodyProperties { provisioningState?: ProvisioningState; } +// this model should not be generated +model ActionInitiateResult { + status: string; +} + +// this model should be generated +model ActionFinalResult { + result: string; +} + //----------------------- Paths ----------------------- @armResourceOperations interface ChildResourcesInterface @@ -390,6 +400,15 @@ interface LroNoBody { Response = ArmAcceptedLroResponse & Azure.Core.Foundations.RetryAfterHeader> >; + + @post + action is ArmResourceActionAsync< + ResourceLroNoBody, + void, + ActionInitiateResult, + LroHeaders = ArmCombinedLroHeaders & + Azure.Core.Foundations.RetryAfterHeader + >; } // client configure