diff --git a/eng/emitter-package-lock.json b/eng/emitter-package-lock.json index 541ed62fc846..dca3700b4289 100644 --- a/eng/emitter-package-lock.json +++ b/eng/emitter-package-lock.json @@ -5,11 +5,11 @@ "packages": { "": { "dependencies": { - "@azure-tools/typespec-java": "0.45.7" + "@azure-tools/typespec-java": "0.45.8" }, "devDependencies": { "@azure-tools/openai-typespec": "1.21.1", - "@azure-tools/typespec-autorest": "0.70.0", + "@azure-tools/typespec-autorest": "0.70.1", "@azure-tools/typespec-azure-core": "0.70.0", "@azure-tools/typespec-azure-portal-core": "0.70.0", "@azure-tools/typespec-azure-resource-manager": "0.70.0", @@ -89,9 +89,9 @@ } }, "node_modules/@azure-tools/typespec-autorest": { - "version": "0.70.0", - "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/@azure-tools/typespec-autorest/-/typespec-autorest-0.70.0.tgz", - "integrity": "sha1-hxXdmTz6UUqpPXEGLwyRUHHNt38=", + "version": "0.70.1", + "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/@azure-tools/typespec-autorest/-/typespec-autorest-0.70.1.tgz", + "integrity": "sha1-eR9lSN0ItD0NH+LL9BR4U9zyJWk=", "license": "MIT", "dependencies": { "yaml": "^2.8.3" @@ -204,9 +204,9 @@ } }, "node_modules/@azure-tools/typespec-java": { - "version": "0.45.7", - "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/@azure-tools/typespec-java/-/typespec-java-0.45.7.tgz", - "integrity": "sha1-2O1r1MPCSGMz5KxvSSg/smSVKA4=", + "version": "0.45.8", + "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/@azure-tools/typespec-java/-/typespec-java-0.45.8.tgz", + "integrity": "sha1-QIfFyMFS7OoqheZLzqy0ny8HFTM=", "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.1", @@ -217,7 +217,7 @@ "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-autorest": "^0.70.0", + "@azure-tools/typespec-autorest": "^0.70.1", "@azure-tools/typespec-azure-core": "^0.70.0", "@azure-tools/typespec-azure-resource-manager": "^0.70.0", "@azure-tools/typespec-azure-rulesets": "^0.70.0", diff --git a/eng/emitter-package.json b/eng/emitter-package.json index efbb77b17c34..0f5cda9b2927 100644 --- a/eng/emitter-package.json +++ b/eng/emitter-package.json @@ -1,10 +1,10 @@ { "main": "dist/src/index.js", "dependencies": { - "@azure-tools/typespec-java": "0.45.7" + "@azure-tools/typespec-java": "0.45.8" }, "devDependencies": { - "@azure-tools/typespec-autorest": "0.70.0", + "@azure-tools/typespec-autorest": "0.70.1", "@azure-tools/typespec-azure-core": "0.70.0", "@azure-tools/typespec-azure-resource-manager": "0.70.0", "@azure-tools/typespec-azure-rulesets": "0.70.0", diff --git a/eng/pipelines/post-publish-emitter.yaml b/eng/pipelines/post-publish-emitter.yaml new file mode 100644 index 000000000000..9c81efc3806b --- /dev/null +++ b/eng/pipelines/post-publish-emitter.yaml @@ -0,0 +1,163 @@ +# Regenerates all TypeSpec-based SDKs in azure-sdk-for-java using the typespec-java emitter, +# then opens an automated draft PR with the results. +# +# The typespec-java emitter lives in Azure/typespec-azure (packages/typespec-java). +# Published route (EmitterVersion set): pins eng/emitter-package.json to that published +# @azure-tools/typespec-java version, then regenerates. This is the post-publish path and does +# not touch typespec-azure sources. +# Dev route (EmitterVersion is 'none'): builds the emitter dev package from source instead +# - from the typespec-azure PR or branch given by PRIdOrBranch, or from the default branch (main) +# when PRIdOrBranch is 'none'. +trigger: none +pr: none + +parameters: +# Set EmitterVersion for the default (post-publish) route. Leave it as 'none' to build the +# emitter from source, in which case PRIdOrBranch selects the typespec-azure PR / branch (or main). +- name: EmitterVersion + displayName: 'Emitter Version (e.g. 0.45.4; none = build from source)' + type: string + default: 'none' +- name: PRIdOrBranch + displayName: 'typespec-azure PR ID or branch — used only when Emitter Version is none (e.g. 43321 or my-branch; none = main)' + type: string + default: 'none' + +jobs: +- job: Generate_SDK + + timeoutInMinutes: 120 + + variables: + - template: /eng/pipelines/templates/variables/globals.yml + - template: /eng/pipelines/templates/variables/image.yml + - name: NodeVersion + value: '24.x' + # Local clone target for the (public) Azure/typespec-azure emitter repo (dev route only). + - name: TypeSpecAzureDirectory + value: $(Agent.BuildDirectory)/typespec-azure + # For the published route this is the given version. For the dev route it is overwritten at + # runtime from the built emitter's package.json (see 'Get Package Version'). + - name: PackageVersion + ${{ if ne(parameters.EmitterVersion, 'none') }}: + value: ${{ parameters.EmitterVersion }} + ${{ else }}: + value: '' + - name: PullRequestTitleSuffix + ${{ if eq(parameters.EmitterVersion, 'none') }}: + ${{ if ne(parameters.PRIdOrBranch, 'none') }}: + value: " DEV (typespec-azure ${{ parameters.PRIdOrBranch }})" + ${{ else }}: + value: " DEV (typespec-azure main)" + ${{ else }}: + value: "" + + pool: + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) + os: linux + + steps: + # azure-sdk-for-java (self) is the only repo resource, so it is checked out to + # $(Build.SourcesDirectory). Azure/typespec-azure is public, so it is cloned directly + # (below) instead of via a repository resource + GitHub service connection. + - checkout: self + + - task: NodeTool@0 + displayName: 'Install Node.js $(NodeVersion)' + inputs: + versionSpec: '$(NodeVersion)' + + - template: /eng/pipelines/templates/steps/maven-authenticate.yml + parameters: + SourceDirectory: $(Build.SourcesDirectory) + + - template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml + parameters: + registryUrl: https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/ + + # Clone the public Azure/typespec-azure repo (dev route only; no service connection required). + # PRIdOrBranch selects what to build the emitter from: a bare PR number is expanded to + # refs/pull//merge; any other non-'none' value is treated as a branch name (or full ref) and + # fetched as-is. When PRIdOrBranch is 'none', the emitter is built from the default branch (main). + # Submodules are then initialized because typespec-azure vendors the TypeSpec compiler and the + # http-client-java generator via the 'core' submodule, which build:generator (Build-Generator.ps1) + # and tspd both require. + - task: PowerShell@2 + displayName: 'Clone typespec-azure' + condition: and(succeeded(), eq('${{ parameters.EmitterVersion }}', 'none')) + inputs: + pwsh: true + targetType: 'inline' + script: | + git clone https://github.com/Azure/typespec-azure.git "$(TypeSpecAzureDirectory)" + $prIdOrBranch = '${{ parameters.PRIdOrBranch }}' + if ($prIdOrBranch -and $prIdOrBranch -ne 'none') { + if ($prIdOrBranch -match '^\d+$') { + # bare number -> PR merge ref + $ref = "refs/pull/$prIdOrBranch/merge" + } else { + # branch name (or full ref) + $ref = $prIdOrBranch + } + Write-Host "Fetching typespec-azure ref $ref" + git -C "$(TypeSpecAzureDirectory)" fetch origin $ref + git -C "$(TypeSpecAzureDirectory)" checkout FETCH_HEAD + } + git -C "$(TypeSpecAzureDirectory)" submodule update --init --recursive + + # Build the emitter dev package (.tgz) from the typespec-azure PR. + # typespec-java depends on other workspace packages (workspace:^). First build only those + # upstream dependencies with turbo (the `^...` filter selects dependencies but excludes + # typespec-java itself). Then Build-TypeSpec.ps1 builds and packs typespec-java (its + # build:generator step runs Build-Generator.ps1, which needs JDK 11+ and Maven), producing + # the .tgz next to the package.json for sync_emitter.py to pick up. + - task: PowerShell@2 + retryCountOnTaskFailure: 1 + condition: and(succeeded(), eq('${{ parameters.EmitterVersion }}', 'none')) + displayName: 'Build typespec-java dev package' + inputs: + pwsh: true + targetType: 'inline' + script: | + corepack enable + pnpm install + pnpm turbo run build --filter "@azure-tools/typespec-java^..." + ./packages/typespec-java/Build-TypeSpec.ps1 + workingDirectory: $(TypeSpecAzureDirectory) + + - script: | + npm install -g @azure-tools/typespec-client-generator-cli + displayName: 'Install tsp-client' + + # Dev route only: the built emitter's version drives the PR title. For the published route + # PackageVersion is already the given EmitterVersion. + - task: PowerShell@2 + displayName: 'Get Package Version' + condition: and(succeeded(), eq('${{ parameters.EmitterVersion }}', 'none')) + inputs: + pwsh: true + targetType: 'inline' + script: | + $PACKAGE_VERSION = node -p -e "require('./packages/typespec-java/package.json').version" + Write-Host("##vso[task.setvariable variable=PackageVersion]$PACKAGE_VERSION") + workingDirectory: $(TypeSpecAzureDirectory) + + - script: | + python3 ./eng/pipelines/scripts/sync_emitter.py --sdk-root=$(Build.SourcesDirectory) --emitter-version='${{ parameters.EmitterVersion }}' --package-json-path=$(TypeSpecAzureDirectory)/packages/typespec-java/package.json + displayName: 'Generate SDK' + workingDirectory: $(Build.SourcesDirectory) + + - template: /eng/common/pipelines/templates/steps/create-pull-request.yml + parameters: + WorkingDirectory: $(Build.SourcesDirectory) + ScriptDirectory: $(Build.SourcesDirectory)/eng/common/scripts + RepoName: azure-sdk-for-java + # Push the automation branch directly to the Azure org (default PROwner is azure-sdk). + PROwner: Azure + BaseBranchName: 'refs/heads/main' + PRBranchName: typespec-java-generation-$(Build.BuildId) + CommitMsg: '[Automation] Generate SDK based on TypeSpec $(PackageVersion)$(PullRequestTitleSuffix)' + PRTitle: '[Automation] Generate SDK based on TypeSpec $(PackageVersion)$(PullRequestTitleSuffix)' + PRLabels: 'DPG' + OpenAsDraft: 'true' diff --git a/eng/pipelines/scripts/patches/0001-key-certificates-impl.patch b/eng/pipelines/scripts/patches/0001-key-certificates-impl.patch new file mode 100644 index 000000000000..ea3813e85588 --- /dev/null +++ b/eng/pipelines/scripts/patches/0001-key-certificates-impl.patch @@ -0,0 +1,239 @@ +From e2df7de3f5643ff2006a8244e28ed9aa3598ecf3 Mon Sep 17 00:00:00 2001 +From: Weidong Xu +Date: Thu, 11 Jun 2026 20:39:16 +0800 +Subject: [PATCH] Revert "regen" + +This reverts commit 7ccefe36941cc38f14a52ca796167a95f263ce3f. +--- + .../models/CertificatePolicy.java | 66 ++++++++++++++----- + 1 file changed, 51 insertions(+), 15 deletions(-) + +diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicy.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicy.java +index e16ea8f5900..33d11980151 100644 +--- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicy.java ++++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicy.java +@@ -1,6 +1,7 @@ + // Copyright (c) Microsoft Corporation. All rights reserved. + // Licensed under the MIT License. + // Code generated by Microsoft (R) TypeSpec Code Generator. ++ + package com.azure.security.keyvault.certificates.implementation.models; + + import com.azure.core.annotation.Fluent; +@@ -9,6 +10,7 @@ import com.azure.json.JsonReader; + import com.azure.json.JsonSerializable; + import com.azure.json.JsonToken; + import com.azure.json.JsonWriter; ++import com.azure.security.keyvault.certificates.models.PlatformManaged; + import java.io.IOException; + import java.util.List; + +@@ -17,7 +19,6 @@ import java.util.List; + */ + @Fluent + public final class CertificatePolicy implements JsonSerializable { +- + /* + * The certificate id. + */ +@@ -60,6 +61,12 @@ public final class CertificatePolicy implements JsonSerializable writer.writeJson(element)); + jsonWriter.writeJsonField("issuer", this.issuerParameters); + jsonWriter.writeJsonField("attributes", this.attributes); ++ jsonWriter.writeJsonField("platformManaged", this.platformManaged); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CertificatePolicy from the JsonReader. +- * ++ * + * @param jsonReader The JsonReader being read. + * @return An instance of CertificatePolicy if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. +@@ -241,6 +273,7 @@ public final class CertificatePolicy implements JsonSerializable +Date: Mon, 22 Sep 2025 15:32:34 +0800 +Subject: [PATCH] revert Impl for onlineexperimentation + +--- + .../OnlineExperimentationClientImpl.java | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/OnlineExperimentationClientImpl.java b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/OnlineExperimentationClientImpl.java +index 32e6622cbc6..ed26312e71d 100644 +--- a/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/OnlineExperimentationClientImpl.java ++++ b/sdk/onlineexperimentation/azure-analytics-onlineexperimentation/src/main/java/com/azure/analytics/onlineexperimentation/implementation/OnlineExperimentationClientImpl.java +@@ -233,7 +233,7 @@ public final class OnlineExperimentationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteMetric(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("experimentMetricId") String experimentMetricId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/experiment-metrics/{experimentMetricId}") + @ExpectedResponses({ 204 }) +@@ -243,7 +243,7 @@ public final class OnlineExperimentationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteMetricSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("experimentMetricId") String experimentMetricId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/experiment-metrics") + @ExpectedResponses({ 200 }) +@@ -698,8 +698,9 @@ public final class OnlineExperimentationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteMetricWithResponseAsync(String experimentMetricId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteMetric(this.getEndpoint(), +- this.getServiceVersion().getVersion(), experimentMetricId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), experimentMetricId, accept, requestOptions, context)); + } + + /** +@@ -730,8 +731,9 @@ public final class OnlineExperimentationClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteMetricWithResponse(String experimentMetricId, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return service.deleteMetricSync(this.getEndpoint(), this.getServiceVersion().getVersion(), experimentMetricId, +- requestOptions, Context.NONE); ++ accept, requestOptions, Context.NONE); + } + + /** +-- +2.51.0.windows.1 + diff --git a/eng/pipelines/scripts/patches/0001-revert-azure-ai-speech-transcription.patch b/eng/pipelines/scripts/patches/0001-revert-azure-ai-speech-transcription.patch new file mode 100644 index 000000000000..926230202d80 --- /dev/null +++ b/eng/pipelines/scripts/patches/0001-revert-azure-ai-speech-transcription.patch @@ -0,0 +1,113 @@ +From bc30c29232e16f5b29af07159d6f9bac6d3bf36c Mon Sep 17 00:00:00 2001 +From: Weidong Xu +Date: Thu, 21 May 2026 11:20:39 +0800 +Subject: [PATCH] revert azure-ai-speech-transcription + +--- + .../generated/TranscribeAudioFileTests.java | 10 +++++----- + .../generated/TranscribeAudioFromURLTests.java | 10 +++++----- + .../generated/TranscribeWithEnhancedModeTests.java | 10 +++++----- + 3 files changed, 15 insertions(+), 15 deletions(-) + +diff --git a/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeAudioFileTests.java b/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeAudioFileTests.java +index a6285e1cfe2..ac8c847552a 100644 +--- a/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeAudioFileTests.java ++++ b/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeAudioFileTests.java +@@ -24,7 +24,7 @@ public final class TranscribeAudioFileTests extends TranscriptionClientTestBase + // response assertion + Assertions.assertNotNull(response); + // verify property "duration" +- Assertions.assertEquals(2000, response.getDuration()); ++ Assertions.assertEquals(2000, response.getDuration().toMillis()); + // verify property "combinedPhrases" + List responseCombinedPhrases = response.getCombinedPhrases(); + ChannelCombinedPhrases responseCombinedPhrasesFirstItem = responseCombinedPhrases.iterator().next(); +@@ -34,15 +34,15 @@ public final class TranscribeAudioFileTests extends TranscriptionClientTestBase + List responsePhrases = response.getPhrases(); + TranscribedPhrase responsePhrasesFirstItem = responsePhrases.iterator().next(); + Assertions.assertNotNull(responsePhrasesFirstItem); +- Assertions.assertEquals(40, responsePhrasesFirstItem.getOffset()); +- Assertions.assertEquals(320, responsePhrasesFirstItem.getDuration()); ++ Assertions.assertEquals(40, responsePhrasesFirstItem.getOffset().toMillis()); ++ Assertions.assertEquals(320, responsePhrasesFirstItem.getDuration().toMillis()); + Assertions.assertEquals("Weather", responsePhrasesFirstItem.getText()); + List responsePhrasesFirstItemWords = responsePhrasesFirstItem.getWords(); + TranscribedWord responsePhrasesFirstItemWordsFirstItem = responsePhrasesFirstItemWords.iterator().next(); + Assertions.assertNotNull(responsePhrasesFirstItemWordsFirstItem); + Assertions.assertEquals("weather", responsePhrasesFirstItemWordsFirstItem.getText()); +- Assertions.assertEquals(40, responsePhrasesFirstItemWordsFirstItem.getOffset()); +- Assertions.assertEquals(320, responsePhrasesFirstItemWordsFirstItem.getDuration()); ++ Assertions.assertEquals(40, responsePhrasesFirstItemWordsFirstItem.getOffset().toMillis()); ++ Assertions.assertEquals(320, responsePhrasesFirstItemWordsFirstItem.getDuration().toMillis()); + Assertions.assertEquals("en-US", responsePhrasesFirstItem.getLocale()); + Assertions.assertEquals(0.78983736, responsePhrasesFirstItem.getConfidence()); + } +diff --git a/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeAudioFromURLTests.java b/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeAudioFromURLTests.java +index c904299bcab..e431b89cc08 100644 +--- a/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeAudioFromURLTests.java ++++ b/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeAudioFromURLTests.java +@@ -24,7 +24,7 @@ public final class TranscribeAudioFromURLTests extends TranscriptionClientTestBa + // response assertion + Assertions.assertNotNull(response); + // verify property "duration" +- Assertions.assertEquals(2000, response.getDuration()); ++ Assertions.assertEquals(2000, response.getDuration().toMillis()); + // verify property "combinedPhrases" + List responseCombinedPhrases = response.getCombinedPhrases(); + ChannelCombinedPhrases responseCombinedPhrasesFirstItem = responseCombinedPhrases.iterator().next(); +@@ -34,15 +34,15 @@ public final class TranscribeAudioFromURLTests extends TranscriptionClientTestBa + List responsePhrases = response.getPhrases(); + TranscribedPhrase responsePhrasesFirstItem = responsePhrases.iterator().next(); + Assertions.assertNotNull(responsePhrasesFirstItem); +- Assertions.assertEquals(40, responsePhrasesFirstItem.getOffset()); +- Assertions.assertEquals(320, responsePhrasesFirstItem.getDuration()); ++ Assertions.assertEquals(40, responsePhrasesFirstItem.getOffset().toMillis()); ++ Assertions.assertEquals(320, responsePhrasesFirstItem.getDuration().toMillis()); + Assertions.assertEquals("Weather", responsePhrasesFirstItem.getText()); + List responsePhrasesFirstItemWords = responsePhrasesFirstItem.getWords(); + TranscribedWord responsePhrasesFirstItemWordsFirstItem = responsePhrasesFirstItemWords.iterator().next(); + Assertions.assertNotNull(responsePhrasesFirstItemWordsFirstItem); + Assertions.assertEquals("weather", responsePhrasesFirstItemWordsFirstItem.getText()); +- Assertions.assertEquals(40, responsePhrasesFirstItemWordsFirstItem.getOffset()); +- Assertions.assertEquals(320, responsePhrasesFirstItemWordsFirstItem.getDuration()); ++ Assertions.assertEquals(40, responsePhrasesFirstItemWordsFirstItem.getOffset().toMillis()); ++ Assertions.assertEquals(320, responsePhrasesFirstItemWordsFirstItem.getDuration().toMillis()); + Assertions.assertEquals("en-US", responsePhrasesFirstItem.getLocale()); + Assertions.assertEquals(0.78983736, responsePhrasesFirstItem.getConfidence()); + } +diff --git a/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeWithEnhancedModeTests.java b/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeWithEnhancedModeTests.java +index 926e39c0905..b92423bd969 100644 +--- a/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeWithEnhancedModeTests.java ++++ b/sdk/transcription/azure-ai-speech-transcription/src/test/java/com/azure/ai/speech/transcription/generated/TranscribeWithEnhancedModeTests.java +@@ -24,7 +24,7 @@ public final class TranscribeWithEnhancedModeTests extends TranscriptionClientTe + // response assertion + Assertions.assertNotNull(response); + // verify property "duration" +- Assertions.assertEquals(2000, response.getDuration()); ++ Assertions.assertEquals(2000, response.getDuration().toMillis()); + // verify property "combinedPhrases" + List responseCombinedPhrases = response.getCombinedPhrases(); + ChannelCombinedPhrases responseCombinedPhrasesFirstItem = responseCombinedPhrases.iterator().next(); +@@ -34,15 +34,15 @@ public final class TranscribeWithEnhancedModeTests extends TranscriptionClientTe + List responsePhrases = response.getPhrases(); + TranscribedPhrase responsePhrasesFirstItem = responsePhrases.iterator().next(); + Assertions.assertNotNull(responsePhrasesFirstItem); +- Assertions.assertEquals(40, responsePhrasesFirstItem.getOffset()); +- Assertions.assertEquals(320, responsePhrasesFirstItem.getDuration()); ++ Assertions.assertEquals(40, responsePhrasesFirstItem.getOffset().toMillis()); ++ Assertions.assertEquals(320, responsePhrasesFirstItem.getDuration().toMillis()); + Assertions.assertEquals("天气", responsePhrasesFirstItem.getText()); + List responsePhrasesFirstItemWords = responsePhrasesFirstItem.getWords(); + TranscribedWord responsePhrasesFirstItemWordsFirstItem = responsePhrasesFirstItemWords.iterator().next(); + Assertions.assertNotNull(responsePhrasesFirstItemWordsFirstItem); + Assertions.assertEquals("天", responsePhrasesFirstItemWordsFirstItem.getText()); +- Assertions.assertEquals(0, responsePhrasesFirstItemWordsFirstItem.getOffset()); +- Assertions.assertEquals(0, responsePhrasesFirstItemWordsFirstItem.getDuration()); ++ Assertions.assertEquals(0, responsePhrasesFirstItemWordsFirstItem.getOffset().toMillis()); ++ Assertions.assertEquals(0, responsePhrasesFirstItemWordsFirstItem.getDuration().toMillis()); + Assertions.assertEquals("zh-CN", responsePhrasesFirstItem.getLocale()); + Assertions.assertEquals(0.78983736, responsePhrasesFirstItem.getConfidence()); + } +-- +2.53.0.windows.2 + diff --git a/eng/pipelines/scripts/patches/0001-revert-impl-in-communication.patch b/eng/pipelines/scripts/patches/0001-revert-impl-in-communication.patch new file mode 100644 index 000000000000..767d5d08bb4d --- /dev/null +++ b/eng/pipelines/scripts/patches/0001-revert-impl-in-communication.patch @@ -0,0 +1,268 @@ +From 46e470e80eeb94ef3da2346bce9e6368792ad4ae Mon Sep 17 00:00:00 2001 +From: Weidong Xu +Date: Thu, 7 Aug 2025 14:13:06 +0800 +Subject: [PATCH] revert impl in communication + +--- + .../JobRouterAdministrationClientImpl.java | 48 +++++++++++-------- + .../implementation/JobRouterClientImpl.java | 22 +++++---- + 2 files changed, 41 insertions(+), 29 deletions(-) + +diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/JobRouterAdministrationClientImpl.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/JobRouterAdministrationClientImpl.java +index 78b69849b85..3a598fb5a4e 100644 +--- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/JobRouterAdministrationClientImpl.java ++++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/JobRouterAdministrationClientImpl.java +@@ -234,8 +234,8 @@ public final class JobRouterAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteDistributionPolicy(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, +- @PathParam("distributionPolicyId") String distributionPolicyId, RequestOptions requestOptions, +- Context context); ++ @PathParam("distributionPolicyId") String distributionPolicyId, @HeaderParam("Accept") String accept, ++ RequestOptions requestOptions, Context context); + + @Delete("/routing/distributionPolicies/{distributionPolicyId}") + @ExpectedResponses({ 204 }) +@@ -245,8 +245,8 @@ public final class JobRouterAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteDistributionPolicySync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, +- @PathParam("distributionPolicyId") String distributionPolicyId, RequestOptions requestOptions, +- Context context); ++ @PathParam("distributionPolicyId") String distributionPolicyId, @HeaderParam("Accept") String accept, ++ RequestOptions requestOptions, Context context); + + @Patch("/routing/classificationPolicies/{classificationPolicyId}") + @ExpectedResponses({ 200, 201 }) +@@ -324,8 +324,8 @@ public final class JobRouterAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteClassificationPolicy(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, +- @PathParam("classificationPolicyId") String classificationPolicyId, RequestOptions requestOptions, +- Context context); ++ @PathParam("classificationPolicyId") String classificationPolicyId, @HeaderParam("Accept") String accept, ++ RequestOptions requestOptions, Context context); + + @Delete("/routing/classificationPolicies/{classificationPolicyId}") + @ExpectedResponses({ 204 }) +@@ -335,8 +335,8 @@ public final class JobRouterAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteClassificationPolicySync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, +- @PathParam("classificationPolicyId") String classificationPolicyId, RequestOptions requestOptions, +- Context context); ++ @PathParam("classificationPolicyId") String classificationPolicyId, @HeaderParam("Accept") String accept, ++ RequestOptions requestOptions, Context context); + + @Patch("/routing/exceptionPolicies/{exceptionPolicyId}") + @ExpectedResponses({ 200, 201 }) +@@ -410,7 +410,7 @@ public final class JobRouterAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteExceptionPolicy(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("exceptionPolicyId") String exceptionPolicyId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/routing/exceptionPolicies/{exceptionPolicyId}") + @ExpectedResponses({ 204 }) +@@ -420,7 +420,7 @@ public final class JobRouterAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteExceptionPolicySync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("exceptionPolicyId") String exceptionPolicyId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Patch("/routing/queues/{queueId}") + @ExpectedResponses({ 200, 201 }) +@@ -494,7 +494,7 @@ public final class JobRouterAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteQueue(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("queueId") String queueId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/routing/queues/{queueId}") + @ExpectedResponses({ 204 }) +@@ -504,7 +504,7 @@ public final class JobRouterAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteQueueSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("queueId") String queueId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) +@@ -1032,8 +1032,9 @@ public final class JobRouterAdministrationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteDistributionPolicyWithResponseAsync(String distributionPolicyId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteDistributionPolicy(this.getEndpoint(), +- this.getServiceVersion().getVersion(), distributionPolicyId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), distributionPolicyId, accept, requestOptions, context)); + } + + /** +@@ -1050,8 +1051,9 @@ public final class JobRouterAdministrationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteDistributionPolicyWithResponse(String distributionPolicyId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return service.deleteDistributionPolicySync(this.getEndpoint(), this.getServiceVersion().getVersion(), +- distributionPolicyId, requestOptions, Context.NONE); ++ distributionPolicyId, accept, requestOptions, Context.NONE); + } + + /** +@@ -1569,8 +1571,9 @@ public final class JobRouterAdministrationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteClassificationPolicyWithResponseAsync(String classificationPolicyId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteClassificationPolicy(this.getEndpoint(), +- this.getServiceVersion().getVersion(), classificationPolicyId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), classificationPolicyId, accept, requestOptions, context)); + } + + /** +@@ -1587,8 +1590,9 @@ public final class JobRouterAdministrationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteClassificationPolicyWithResponse(String classificationPolicyId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return service.deleteClassificationPolicySync(this.getEndpoint(), this.getServiceVersion().getVersion(), +- classificationPolicyId, requestOptions, Context.NONE); ++ classificationPolicyId, accept, requestOptions, Context.NONE); + } + + /** +@@ -2106,8 +2110,9 @@ public final class JobRouterAdministrationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteExceptionPolicyWithResponseAsync(String exceptionPolicyId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteExceptionPolicy(this.getEndpoint(), +- this.getServiceVersion().getVersion(), exceptionPolicyId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), exceptionPolicyId, accept, requestOptions, context)); + } + + /** +@@ -2123,8 +2128,9 @@ public final class JobRouterAdministrationClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteExceptionPolicyWithResponse(String exceptionPolicyId, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return service.deleteExceptionPolicySync(this.getEndpoint(), this.getServiceVersion().getVersion(), +- exceptionPolicyId, requestOptions, Context.NONE); ++ exceptionPolicyId, accept, requestOptions, Context.NONE); + } + + /** +@@ -2548,8 +2554,9 @@ public final class JobRouterAdministrationClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteQueueWithResponseAsync(String queueId, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteQueue(this.getEndpoint(), +- this.getServiceVersion().getVersion(), queueId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), queueId, accept, requestOptions, context)); + } + + /** +@@ -2565,7 +2572,8 @@ public final class JobRouterAdministrationClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteQueueWithResponse(String queueId, RequestOptions requestOptions) { +- return service.deleteQueueSync(this.getEndpoint(), this.getServiceVersion().getVersion(), queueId, ++ final String accept = "application/json"; ++ return service.deleteQueueSync(this.getEndpoint(), this.getServiceVersion().getVersion(), queueId, accept, + requestOptions, Context.NONE); + } + +diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/JobRouterClientImpl.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/JobRouterClientImpl.java +index 1ab1634dd63..e0d6dc7f6e7 100644 +--- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/JobRouterClientImpl.java ++++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/JobRouterClientImpl.java +@@ -210,7 +210,7 @@ public final class JobRouterClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteJob(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("jobId") String jobId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/routing/jobs/{jobId}") + @ExpectedResponses({ 204 }) +@@ -220,7 +220,7 @@ public final class JobRouterClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteJobSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("jobId") String jobId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/routing/jobs/{jobId}:reclassify") + @ExpectedResponses({ 200 }) +@@ -484,7 +484,7 @@ public final class JobRouterClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteWorker(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workerId") String workerId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/routing/workers/{workerId}") + @ExpectedResponses({ 204 }) +@@ -494,7 +494,7 @@ public final class JobRouterClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteWorkerSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("workerId") String workerId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/routing/workers") + @ExpectedResponses({ 200 }) +@@ -1012,8 +1012,9 @@ public final class JobRouterClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteJobWithResponseAsync(String jobId, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteJob(this.getEndpoint(), +- this.getServiceVersion().getVersion(), jobId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), jobId, accept, requestOptions, context)); + } + + /** +@@ -1029,8 +1030,9 @@ public final class JobRouterClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteJobWithResponse(String jobId, RequestOptions requestOptions) { +- return service.deleteJobSync(this.getEndpoint(), this.getServiceVersion().getVersion(), jobId, requestOptions, +- Context.NONE); ++ final String accept = "application/json"; ++ return service.deleteJobSync(this.getEndpoint(), this.getServiceVersion().getVersion(), jobId, accept, ++ requestOptions, Context.NONE); + } + + /** +@@ -2671,8 +2673,9 @@ public final class JobRouterClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteWorkerWithResponseAsync(String workerId, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteWorker(this.getEndpoint(), +- this.getServiceVersion().getVersion(), workerId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), workerId, accept, requestOptions, context)); + } + + /** +@@ -2688,7 +2691,8 @@ public final class JobRouterClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWorkerWithResponse(String workerId, RequestOptions requestOptions) { +- return service.deleteWorkerSync(this.getEndpoint(), this.getServiceVersion().getVersion(), workerId, ++ final String accept = "application/json"; ++ return service.deleteWorkerSync(this.getEndpoint(), this.getServiceVersion().getVersion(), workerId, accept, + requestOptions, Context.NONE); + } + +-- +2.50.1.windows.1 + diff --git a/eng/pipelines/scripts/patches/0001-revert-impl-in-contentsafety.patch b/eng/pipelines/scripts/patches/0001-revert-impl-in-contentsafety.patch new file mode 100644 index 000000000000..9bace5b40da0 --- /dev/null +++ b/eng/pipelines/scripts/patches/0001-revert-impl-in-contentsafety.patch @@ -0,0 +1,99 @@ +From 1185f9ded7e644d6b64c955c2faa9422765eea24 Mon Sep 17 00:00:00 2001 +From: Weidong Xu +Date: Thu, 7 Aug 2025 14:28:55 +0800 +Subject: [PATCH] revert impl in contentsafety + +--- + .../implementation/BlocklistClientImpl.java | 24 +++++++++++-------- + 1 file changed, 14 insertions(+), 10 deletions(-) + +diff --git a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/BlocklistClientImpl.java b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/BlocklistClientImpl.java +index e7e96b52ccf..727d27c5547 100644 +--- a/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/BlocklistClientImpl.java ++++ b/sdk/contentsafety/azure-ai-contentsafety/src/main/java/com/azure/ai/contentsafety/implementation/BlocklistClientImpl.java +@@ -216,7 +216,7 @@ public final class BlocklistClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteTextBlocklist(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/text/blocklists/{blocklistName}") + @ExpectedResponses({ 204 }) +@@ -226,7 +226,7 @@ public final class BlocklistClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteTextBlocklistSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/text/blocklists/{blocklistName}") + @ExpectedResponses({ 200 }) +@@ -318,8 +318,8 @@ public final class BlocklistClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> removeBlocklistItems(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, +- @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData options, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData options, RequestOptions requestOptions, Context context); + + @Post("/text/blocklists/{blocklistName}:removeBlocklistItems") + @ExpectedResponses({ 204 }) +@@ -329,8 +329,8 @@ public final class BlocklistClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response removeBlocklistItemsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("blocklistName") String name, +- @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData options, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData options, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) +@@ -587,8 +587,9 @@ public final class BlocklistClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteTextBlocklistWithResponseAsync(String name, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteTextBlocklist(this.getEndpoint(), +- this.getServiceVersion().getVersion(), name, requestOptions, context)); ++ this.getServiceVersion().getVersion(), name, accept, requestOptions, context)); + } + + /** +@@ -606,7 +607,8 @@ public final class BlocklistClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteTextBlocklistWithResponse(String name, RequestOptions requestOptions) { +- return service.deleteTextBlocklistSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, ++ final String accept = "application/json"; ++ return service.deleteTextBlocklistSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, + requestOptions, Context.NONE); + } + +@@ -1126,8 +1128,9 @@ public final class BlocklistClientImpl { + public Mono> removeBlocklistItemsWithResponseAsync(String name, BinaryData options, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.removeBlocklistItems(this.getEndpoint(), +- this.getServiceVersion().getVersion(), name, contentType, options, requestOptions, context)); ++ this.getServiceVersion().getVersion(), name, contentType, accept, options, requestOptions, context)); + } + + /** +@@ -1159,8 +1162,9 @@ public final class BlocklistClientImpl { + public Response removeBlocklistItemsWithResponse(String name, BinaryData options, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return service.removeBlocklistItemsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, +- contentType, options, requestOptions, Context.NONE); ++ contentType, accept, options, requestOptions, Context.NONE); + } + + /** +-- +2.50.1.windows.1 + diff --git a/eng/pipelines/scripts/patches/0001-revert-impl-in-documentintelligence.patch b/eng/pipelines/scripts/patches/0001-revert-impl-in-documentintelligence.patch new file mode 100644 index 000000000000..a43942ea8dee --- /dev/null +++ b/eng/pipelines/scripts/patches/0001-revert-impl-in-documentintelligence.patch @@ -0,0 +1,534 @@ +From 3efa4c0cb7a78e09ff941b751092948faa74e70a Mon Sep 17 00:00:00 2001 +From: Weidong Xu +Date: Thu, 7 Aug 2025 12:28:19 +0800 +Subject: [PATCH] revert impl in documentintelligence + +--- + ...tIntelligenceAdministrationClientImpl.java | 90 ++++++++++++------- + .../DocumentIntelligenceClientImpl.java | 68 ++++++++------ + 2 files changed, 98 insertions(+), 60 deletions(-) + +diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentIntelligenceAdministrationClientImpl.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentIntelligenceAdministrationClientImpl.java +index edb1f567ca1..54d0a403774 100644 +--- a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentIntelligenceAdministrationClientImpl.java ++++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentIntelligenceAdministrationClientImpl.java +@@ -178,7 +178,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> buildDocumentModel(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, +- @BodyParam("application/json") BinaryData buildRequest, RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData buildRequest, ++ RequestOptions requestOptions, Context context); + + @Post("/documentModels:build") + @ExpectedResponses({ 202 }) +@@ -188,7 +189,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response buildDocumentModelSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, +- @BodyParam("application/json") BinaryData buildRequest, RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData buildRequest, ++ RequestOptions requestOptions, Context context); + + @Post("/documentModels:compose") + @ExpectedResponses({ 202 }) +@@ -198,7 +200,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> composeModel(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, +- @BodyParam("application/json") BinaryData composeRequest, RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData composeRequest, ++ RequestOptions requestOptions, Context context); + + @Post("/documentModels:compose") + @ExpectedResponses({ 202 }) +@@ -208,7 +211,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response composeModelSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, +- @BodyParam("application/json") BinaryData composeRequest, RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData composeRequest, ++ RequestOptions requestOptions, Context context); + + @Post("/documentModels:authorizeCopy") + @ExpectedResponses({ 200 }) +@@ -240,8 +244,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> copyModelTo(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData copyToRequest, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData copyToRequest, RequestOptions requestOptions, Context context); + + @Post("/documentModels/{modelId}:copyTo") + @ExpectedResponses({ 202 }) +@@ -251,8 +255,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response copyModelToSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData copyToRequest, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData copyToRequest, RequestOptions requestOptions, Context context); + + @Get("/documentModels/{modelId}") + @ExpectedResponses({ 200 }) +@@ -302,7 +306,7 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteModel(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/documentModels/{modelId}") + @ExpectedResponses({ 204 }) +@@ -312,7 +316,7 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteModelSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/info") + @ExpectedResponses({ 200 }) +@@ -382,7 +386,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> buildClassifier(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, +- @BodyParam("application/json") BinaryData buildRequest, RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData buildRequest, ++ RequestOptions requestOptions, Context context); + + @Post("/documentClassifiers:build") + @ExpectedResponses({ 202 }) +@@ -392,7 +397,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response buildClassifierSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, +- @BodyParam("application/json") BinaryData buildRequest, RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData buildRequest, ++ RequestOptions requestOptions, Context context); + + @Post("/documentClassifiers:authorizeCopy") + @ExpectedResponses({ 200 }) +@@ -424,8 +430,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> copyClassifierTo(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("classifierId") String classifierId, +- @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData copyToRequest, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData copyToRequest, RequestOptions requestOptions, Context context); + + @Post("/documentClassifiers/{classifierId}:copyTo") + @ExpectedResponses({ 202 }) +@@ -435,8 +441,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response copyClassifierToSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("classifierId") String classifierId, +- @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData copyToRequest, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData copyToRequest, RequestOptions requestOptions, Context context); + + @Get("/documentClassifiers/{classifierId}") + @ExpectedResponses({ 200 }) +@@ -486,7 +492,7 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteClassifier(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("classifierId") String classifierId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/documentClassifiers/{classifierId}") + @ExpectedResponses({ 204 }) +@@ -496,7 +502,7 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteClassifierSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("classifierId") String classifierId, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) +@@ -598,8 +604,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + private Mono> buildDocumentModelWithResponseAsync(BinaryData buildRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.buildDocumentModel(this.getEndpoint(), +- this.getServiceVersion().getVersion(), contentType, buildRequest, requestOptions, context)); ++ this.getServiceVersion().getVersion(), contentType, accept, buildRequest, requestOptions, context)); + } + + /** +@@ -640,8 +647,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + private Response buildDocumentModelWithResponse(BinaryData buildRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return service.buildDocumentModelSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, +- buildRequest, requestOptions, Context.NONE); ++ accept, buildRequest, requestOptions, Context.NONE); + } + + /** +@@ -909,8 +917,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + private Mono> composeModelWithResponseAsync(BinaryData composeRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.composeModel(this.getEndpoint(), +- this.getServiceVersion().getVersion(), contentType, composeRequest, requestOptions, context)); ++ this.getServiceVersion().getVersion(), contentType, accept, composeRequest, requestOptions, context)); + } + + /** +@@ -971,7 +980,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + private Response composeModelWithResponse(BinaryData composeRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; +- return service.composeModelSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, ++ final String accept = "application/json"; ++ return service.composeModelSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, + composeRequest, requestOptions, Context.NONE); + } + +@@ -1391,8 +1401,10 @@ public final class DocumentIntelligenceAdministrationClientImpl { + private Mono> copyModelToWithResponseAsync(String modelId, BinaryData copyToRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; +- return FluxUtil.withContext(context -> service.copyModelTo(this.getEndpoint(), +- this.getServiceVersion().getVersion(), modelId, contentType, copyToRequest, requestOptions, context)); ++ final String accept = "application/json"; ++ return FluxUtil ++ .withContext(context -> service.copyModelTo(this.getEndpoint(), this.getServiceVersion().getVersion(), ++ modelId, contentType, accept, copyToRequest, requestOptions, context)); + } + + /** +@@ -1425,8 +1437,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + private Response copyModelToWithResponse(String modelId, BinaryData copyToRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return service.copyModelToSync(this.getEndpoint(), this.getServiceVersion().getVersion(), modelId, contentType, +- copyToRequest, requestOptions, Context.NONE); ++ accept, copyToRequest, requestOptions, Context.NONE); + } + + /** +@@ -2116,8 +2129,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteModelWithResponseAsync(String modelId, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteModel(this.getEndpoint(), +- this.getServiceVersion().getVersion(), modelId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), modelId, accept, requestOptions, context)); + } + + /** +@@ -2133,7 +2147,8 @@ public final class DocumentIntelligenceAdministrationClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteModelWithResponse(String modelId, RequestOptions requestOptions) { +- return service.deleteModelSync(this.getEndpoint(), this.getServiceVersion().getVersion(), modelId, ++ final String accept = "application/json"; ++ return service.deleteModelSync(this.getEndpoint(), this.getServiceVersion().getVersion(), modelId, accept, + requestOptions, Context.NONE); + } + +@@ -2544,8 +2559,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + private Mono> buildClassifierWithResponseAsync(BinaryData buildRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.buildClassifier(this.getEndpoint(), +- this.getServiceVersion().getVersion(), contentType, buildRequest, requestOptions, context)); ++ this.getServiceVersion().getVersion(), contentType, accept, buildRequest, requestOptions, context)); + } + + /** +@@ -2587,8 +2603,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + private Response buildClassifierWithResponse(BinaryData buildRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return service.buildClassifierSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, +- buildRequest, requestOptions, Context.NONE); ++ accept, buildRequest, requestOptions, Context.NONE); + } + + /** +@@ -2931,8 +2948,10 @@ public final class DocumentIntelligenceAdministrationClientImpl { + private Mono> copyClassifierToWithResponseAsync(String classifierId, BinaryData copyToRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; +- return FluxUtil.withContext(context -> service.copyClassifierTo(this.getEndpoint(), +- this.getServiceVersion().getVersion(), classifierId, contentType, copyToRequest, requestOptions, context)); ++ final String accept = "application/json"; ++ return FluxUtil ++ .withContext(context -> service.copyClassifierTo(this.getEndpoint(), this.getServiceVersion().getVersion(), ++ classifierId, contentType, accept, copyToRequest, requestOptions, context)); + } + + /** +@@ -2965,8 +2984,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + private Response copyClassifierToWithResponse(String classifierId, BinaryData copyToRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return service.copyClassifierToSync(this.getEndpoint(), this.getServiceVersion().getVersion(), classifierId, +- contentType, copyToRequest, requestOptions, Context.NONE); ++ contentType, accept, copyToRequest, requestOptions, Context.NONE); + } + + /** +@@ -3479,8 +3499,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteClassifierWithResponseAsync(String classifierId, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteClassifier(this.getEndpoint(), +- this.getServiceVersion().getVersion(), classifierId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), classifierId, accept, requestOptions, context)); + } + + /** +@@ -3496,8 +3517,9 @@ public final class DocumentIntelligenceAdministrationClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteClassifierWithResponse(String classifierId, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return service.deleteClassifierSync(this.getEndpoint(), this.getServiceVersion().getVersion(), classifierId, +- requestOptions, Context.NONE); ++ accept, requestOptions, Context.NONE); + } + + /** +diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentIntelligenceClientImpl.java b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentIntelligenceClientImpl.java +index 35d46b5d152..f1ad7faf330 100644 +--- a/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentIntelligenceClientImpl.java ++++ b/sdk/documentintelligence/azure-ai-documentintelligence/src/main/java/com/azure/ai/documentintelligence/implementation/DocumentIntelligenceClientImpl.java +@@ -174,8 +174,8 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> analyzeDocument(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData analyzeRequest, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData analyzeRequest, RequestOptions requestOptions, Context context); + + @Post("/documentModels/{modelId}:analyze") + @ExpectedResponses({ 202 }) +@@ -185,8 +185,8 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response analyzeDocumentSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData analyzeRequest, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData analyzeRequest, RequestOptions requestOptions, Context context); + + @Get("/documentModels/{modelId}/analyzeResults/{resultId}/pdf") + @ExpectedResponses({ 200 }) +@@ -240,7 +240,8 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteAnalyzeResult(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @PathParam("resultId") String resultId, RequestOptions requestOptions, Context context); ++ @PathParam("resultId") String resultId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, ++ Context context); + + @Delete("/documentModels/{modelId}/analyzeResults/{resultId}") + @ExpectedResponses({ 204 }) +@@ -250,7 +251,8 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteAnalyzeResultSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @PathParam("resultId") String resultId, RequestOptions requestOptions, Context context); ++ @PathParam("resultId") String resultId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, ++ Context context); + + @Post("/documentModels/{modelId}:analyzeBatch") + @ExpectedResponses({ 202 }) +@@ -260,7 +262,7 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> analyzeBatchDocuments(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @HeaderParam("content-type") String contentType, ++ @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData analyzeBatchRequest, RequestOptions requestOptions, + Context context); + +@@ -272,7 +274,7 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response analyzeBatchDocumentsSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @HeaderParam("content-type") String contentType, ++ @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData analyzeBatchRequest, RequestOptions requestOptions, + Context context); + +@@ -304,7 +306,8 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteAnalyzeBatchResult(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @PathParam("resultId") String resultId, RequestOptions requestOptions, Context context); ++ @PathParam("resultId") String resultId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, ++ Context context); + + @Delete("/documentModels/{modelId}/analyzeBatchResults/{resultId}") + @ExpectedResponses({ 204 }) +@@ -314,7 +317,8 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteAnalyzeBatchResultSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("modelId") String modelId, +- @PathParam("resultId") String resultId, RequestOptions requestOptions, Context context); ++ @PathParam("resultId") String resultId, @HeaderParam("Accept") String accept, RequestOptions requestOptions, ++ Context context); + + @Get("/documentModels/{modelId}/analyzeBatchResults/{resultId}") + @ExpectedResponses({ 200 }) +@@ -346,8 +350,8 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> classifyDocument(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("classifierId") String classifierId, +- @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData classifyRequest, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData classifyRequest, RequestOptions requestOptions, Context context); + + @Post("/documentClassifiers/{classifierId}:analyze") + @ExpectedResponses({ 202 }) +@@ -357,8 +361,8 @@ public final class DocumentIntelligenceClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response classifyDocumentSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("classifierId") String classifierId, +- @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData classifyRequest, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData classifyRequest, RequestOptions requestOptions, Context context); + + @Get("{nextLink}") + @ExpectedResponses({ 200 }) +@@ -427,8 +431,10 @@ public final class DocumentIntelligenceClientImpl { + private Mono> analyzeDocumentWithResponseAsync(String modelId, BinaryData analyzeRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; +- return FluxUtil.withContext(context -> service.analyzeDocument(this.getEndpoint(), +- this.getServiceVersion().getVersion(), modelId, contentType, analyzeRequest, requestOptions, context)); ++ final String accept = "application/json"; ++ return FluxUtil ++ .withContext(context -> service.analyzeDocument(this.getEndpoint(), this.getServiceVersion().getVersion(), ++ modelId, contentType, accept, analyzeRequest, requestOptions, context)); + } + + /** +@@ -477,8 +483,9 @@ public final class DocumentIntelligenceClientImpl { + private Response analyzeDocumentWithResponse(String modelId, BinaryData analyzeRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return service.analyzeDocumentSync(this.getEndpoint(), this.getServiceVersion().getVersion(), modelId, +- contentType, analyzeRequest, requestOptions, Context.NONE); ++ contentType, accept, analyzeRequest, requestOptions, Context.NONE); + } + + /** +@@ -842,8 +849,9 @@ public final class DocumentIntelligenceClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteAnalyzeResultWithResponseAsync(String modelId, String resultId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteAnalyzeResult(this.getEndpoint(), +- this.getServiceVersion().getVersion(), modelId, resultId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), modelId, resultId, accept, requestOptions, context)); + } + + /** +@@ -861,8 +869,9 @@ public final class DocumentIntelligenceClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteAnalyzeResultWithResponse(String modelId, String resultId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return service.deleteAnalyzeResultSync(this.getEndpoint(), this.getServiceVersion().getVersion(), modelId, +- resultId, requestOptions, Context.NONE); ++ resultId, accept, requestOptions, Context.NONE); + } + + /** +@@ -920,8 +929,10 @@ public final class DocumentIntelligenceClientImpl { + private Mono> analyzeBatchDocumentsWithResponseAsync(String modelId, BinaryData analyzeBatchRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; +- return FluxUtil.withContext(context -> service.analyzeBatchDocuments(this.getEndpoint(), +- this.getServiceVersion().getVersion(), modelId, contentType, analyzeBatchRequest, requestOptions, context)); ++ final String accept = "application/json"; ++ return FluxUtil.withContext( ++ context -> service.analyzeBatchDocuments(this.getEndpoint(), this.getServiceVersion().getVersion(), modelId, ++ contentType, accept, analyzeBatchRequest, requestOptions, context)); + } + + /** +@@ -979,8 +990,9 @@ public final class DocumentIntelligenceClientImpl { + private Response analyzeBatchDocumentsWithResponse(String modelId, BinaryData analyzeBatchRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return service.analyzeBatchDocumentsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), modelId, +- contentType, analyzeBatchRequest, requestOptions, Context.NONE); ++ contentType, accept, analyzeBatchRequest, requestOptions, Context.NONE); + } + + /** +@@ -1507,8 +1519,9 @@ public final class DocumentIntelligenceClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteAnalyzeBatchResultWithResponseAsync(String modelId, String resultId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteAnalyzeBatchResult(this.getEndpoint(), +- this.getServiceVersion().getVersion(), modelId, resultId, requestOptions, context)); ++ this.getServiceVersion().getVersion(), modelId, resultId, accept, requestOptions, context)); + } + + /** +@@ -1526,8 +1539,9 @@ public final class DocumentIntelligenceClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteAnalyzeBatchResultWithResponse(String modelId, String resultId, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return service.deleteAnalyzeBatchResultSync(this.getEndpoint(), this.getServiceVersion().getVersion(), modelId, +- resultId, requestOptions, Context.NONE); ++ resultId, accept, requestOptions, Context.NONE); + } + + /** +@@ -1686,9 +1700,10 @@ public final class DocumentIntelligenceClientImpl { + private Mono> classifyDocumentWithResponseAsync(String classifierId, BinaryData classifyRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.classifyDocument(this.getEndpoint(), this.getServiceVersion().getVersion(), +- classifierId, contentType, classifyRequest, requestOptions, context)); ++ classifierId, contentType, accept, classifyRequest, requestOptions, context)); + } + + /** +@@ -1728,8 +1743,9 @@ public final class DocumentIntelligenceClientImpl { + private Response classifyDocumentWithResponse(String classifierId, BinaryData classifyRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return service.classifyDocumentSync(this.getEndpoint(), this.getServiceVersion().getVersion(), classifierId, +- contentType, classifyRequest, requestOptions, Context.NONE); ++ contentType, accept, classifyRequest, requestOptions, Context.NONE); + } + + /** +-- +2.50.1.windows.1 + diff --git a/eng/pipelines/scripts/patches/0001-revert-impl-in-easm.patch b/eng/pipelines/scripts/patches/0001-revert-impl-in-easm.patch new file mode 100644 index 000000000000..0ff7844e6d57 --- /dev/null +++ b/eng/pipelines/scripts/patches/0001-revert-impl-in-easm.patch @@ -0,0 +1,135 @@ +From ee9efb32a58711f5bcb4667e4ae9bea70be2e138 Mon Sep 17 00:00:00 2001 +From: Weidong Xu +Date: Thu, 7 Aug 2025 13:47:27 +0800 +Subject: [PATCH] revert impl in easm + +--- + .../easm/implementation/EasmClientImpl.java | 30 +++++++++++-------- + 1 file changed, 18 insertions(+), 12 deletions(-) + +diff --git a/sdk/easm/azure-analytics-defender-easm/src/main/java/com/azure/analytics/defender/easm/implementation/EasmClientImpl.java b/sdk/easm/azure-analytics-defender-easm/src/main/java/com/azure/analytics/defender/easm/implementation/EasmClientImpl.java +index 74965f145fd..cd574da24ef 100644 +--- a/sdk/easm/azure-analytics-defender-easm/src/main/java/com/azure/analytics/defender/easm/implementation/EasmClientImpl.java ++++ b/sdk/easm/azure-analytics-defender-easm/src/main/java/com/azure/analytics/defender/easm/implementation/EasmClientImpl.java +@@ -315,7 +315,7 @@ public final class EasmClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteDataConnection(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("dataConnectionName") String dataConnectionName, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/dataConnections/{dataConnectionName}") + @ExpectedResponses({ 204 }) +@@ -325,7 +325,7 @@ public final class EasmClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteDataConnectionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("dataConnectionName") String dataConnectionName, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/discoGroups") + @ExpectedResponses({ 200 }) +@@ -419,7 +419,7 @@ public final class EasmClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> runDiscoGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("groupName") String groupName, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/discoGroups/{groupName}:run") + @ExpectedResponses({ 204 }) +@@ -429,7 +429,7 @@ public final class EasmClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response runDiscoGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("groupName") String groupName, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/discoGroups/{groupName}/runs") + @ExpectedResponses({ 200 }) +@@ -625,7 +625,7 @@ public final class EasmClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteSavedFilter(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("filterName") String filterName, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Delete("/savedFilters/{filterName}") + @ExpectedResponses({ 204 }) +@@ -635,7 +635,7 @@ public final class EasmClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteSavedFilterSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("filterName") String filterName, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/tasks") + @ExpectedResponses({ 200 }) +@@ -1886,8 +1886,9 @@ public final class EasmClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteDataConnectionWithResponseAsync(String dataConnectionName, + RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteDataConnection(this.getEndpoint(), +- this.getServiceVersion().getVersion(), dataConnectionName, requestOptions, context)); ++ this.getServiceVersion().getVersion(), dataConnectionName, accept, requestOptions, context)); + } + + /** +@@ -1903,8 +1904,9 @@ public final class EasmClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteDataConnectionWithResponse(String dataConnectionName, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return service.deleteDataConnectionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), +- dataConnectionName, requestOptions, Context.NONE); ++ dataConnectionName, accept, requestOptions, Context.NONE); + } + + /** +@@ -2696,8 +2698,9 @@ public final class EasmClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> runDiscoGroupWithResponseAsync(String groupName, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.runDiscoGroup(this.getEndpoint(), +- this.getServiceVersion().getVersion(), groupName, requestOptions, context)); ++ this.getServiceVersion().getVersion(), groupName, accept, requestOptions, context)); + } + + /** +@@ -2713,7 +2716,8 @@ public final class EasmClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response runDiscoGroupWithResponse(String groupName, RequestOptions requestOptions) { +- return service.runDiscoGroupSync(this.getEndpoint(), this.getServiceVersion().getVersion(), groupName, ++ final String accept = "application/json"; ++ return service.runDiscoGroupSync(this.getEndpoint(), this.getServiceVersion().getVersion(), groupName, accept, + requestOptions, Context.NONE); + } + +@@ -4053,8 +4057,9 @@ public final class EasmClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteSavedFilterWithResponseAsync(String filterName, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.deleteSavedFilter(this.getEndpoint(), +- this.getServiceVersion().getVersion(), filterName, requestOptions, context)); ++ this.getServiceVersion().getVersion(), filterName, accept, requestOptions, context)); + } + + /** +@@ -4070,8 +4075,9 @@ public final class EasmClientImpl { + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteSavedFilterWithResponse(String filterName, RequestOptions requestOptions) { ++ final String accept = "application/json"; + return service.deleteSavedFilterSync(this.getEndpoint(), this.getServiceVersion().getVersion(), filterName, +- requestOptions, Context.NONE); ++ accept, requestOptions, Context.NONE); + } + + /** +-- +2.50.1.windows.1 + diff --git a/eng/pipelines/scripts/patches/0001-revert-impl-in-monitor.patch b/eng/pipelines/scripts/patches/0001-revert-impl-in-monitor.patch new file mode 100644 index 000000000000..f54f516b672e --- /dev/null +++ b/eng/pipelines/scripts/patches/0001-revert-impl-in-monitor.patch @@ -0,0 +1,58 @@ +From d767417fc77ec1a5754ea6c973c258acab2cc9a6 Mon Sep 17 00:00:00 2001 +From: Weidong Xu +Date: Thu, 7 Aug 2025 12:44:57 +0800 +Subject: [PATCH] revert impl in monitor + +--- + .../implementation/LogsIngestionClientImpl.java | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/LogsIngestionClientImpl.java b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/LogsIngestionClientImpl.java +index 1d513291f2b..7e7a7ed1484 100644 +--- a/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/LogsIngestionClientImpl.java ++++ b/sdk/monitor/azure-monitor-ingestion/src/main/java/com/azure/monitor/ingestion/implementation/LogsIngestionClientImpl.java +@@ -161,7 +161,8 @@ public final class LogsIngestionClientImpl { + Mono> upload(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("ruleId") String ruleId, + @PathParam("stream") String streamName, @HeaderParam("Content-Type") String contentType, +- @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, ++ RequestOptions requestOptions, Context context); + + @Post("/dataCollectionRules/{ruleId}/streams/{stream}") + @ExpectedResponses({ 204 }) +@@ -171,8 +172,8 @@ public final class LogsIngestionClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("ruleId") String ruleId, @PathParam("stream") String streamName, +- @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, +- RequestOptions requestOptions, Context context); ++ @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, ++ @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + } + + /** +@@ -211,8 +212,9 @@ public final class LogsIngestionClientImpl { + public Mono> uploadWithResponseAsync(String ruleId, String streamName, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.upload(this.getEndpoint(), this.getServiceVersion().getVersion(), +- ruleId, streamName, contentType, body, requestOptions, context)); ++ ruleId, streamName, contentType, accept, body, requestOptions, context)); + } + + /** +@@ -251,7 +253,8 @@ public final class LogsIngestionClientImpl { + public Response uploadWithResponse(String ruleId, String streamName, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return service.uploadSync(this.getEndpoint(), this.getServiceVersion().getVersion(), ruleId, streamName, +- contentType, body, requestOptions, Context.NONE); ++ contentType, accept, body, requestOptions, Context.NONE); + } + } +-- +2.50.1.windows.1 + diff --git a/eng/pipelines/scripts/patches/0001-revert-impl-in-translation.patch b/eng/pipelines/scripts/patches/0001-revert-impl-in-translation.patch new file mode 100644 index 000000000000..1a561ced9a94 --- /dev/null +++ b/eng/pipelines/scripts/patches/0001-revert-impl-in-translation.patch @@ -0,0 +1,59 @@ +From 67cd3515137238ae3c69008d0a65ec74af3338e9 Mon Sep 17 00:00:00 2001 +From: Weidong Xu +Date: Thu, 7 Aug 2025 12:13:55 +0800 +Subject: [PATCH] revert impl in translation + +--- + .../DocumentTranslationClientImpl.java | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +diff --git a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/implementation/DocumentTranslationClientImpl.java b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/implementation/DocumentTranslationClientImpl.java +index 9fb5a9e6fc8..cefc7bff313 100644 +--- a/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/implementation/DocumentTranslationClientImpl.java ++++ b/sdk/translation/azure-ai-translation-document/src/main/java/com/azure/ai/translation/document/implementation/DocumentTranslationClientImpl.java +@@ -179,7 +179,8 @@ public final class DocumentTranslationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> translation(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, +- @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, ++ RequestOptions requestOptions, Context context); + + @Post("/document/batches") + @ExpectedResponses({ 202 }) +@@ -189,7 +190,8 @@ public final class DocumentTranslationClientImpl { + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response translationSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, +- @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); ++ @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, ++ RequestOptions requestOptions, Context context); + + @Get("/document/batches") + @ExpectedResponses({ 200 }) +@@ -426,8 +428,9 @@ public final class DocumentTranslationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> translationWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; ++ final String accept = "application/json"; + return FluxUtil.withContext(context -> service.translation(this.getEndpoint(), +- this.getServiceVersion().getVersion(), contentType, body, requestOptions, context)); ++ this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); + } + + /** +@@ -502,8 +505,9 @@ public final class DocumentTranslationClientImpl { + @ServiceMethod(returns = ReturnType.SINGLE) + private Response translationWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; +- return service.translationSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, body, +- requestOptions, Context.NONE); ++ final String accept = "application/json"; ++ return service.translationSync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, ++ body, requestOptions, Context.NONE); + } + + /** +-- +2.50.1.windows.1 + diff --git a/eng/pipelines/scripts/sync_emitter.py b/eng/pipelines/scripts/sync_emitter.py new file mode 100644 index 000000000000..827aa1be459d --- /dev/null +++ b/eng/pipelines/scripts/sync_emitter.py @@ -0,0 +1,489 @@ +#!/usr/bin/env python3 + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +import os +import sys +import logging +import argparse +import subprocess +import glob +import shutil +import json +import tarfile +import tempfile +import urllib.request +from typing import List + +sdk_root: str +# script is in "eng/pipelines/scripts/" +script_root: str = os.path.dirname(os.path.realpath(__file__)) + +skip_artifacts: List[str] = [ + "azure-ai-anomalydetector", # deprecated + # expect failure on below + # emitter generates inconsistent code for id-parameterized subclients (LargePersonGroup, + # LargeFaceList): wrapper clients call the removed plural getLargePersonGroups()/getLargeFaceLists() + # accessors and stale plural *sImpl files are left behind, so the module does not compile. + "azure-ai-vision-face", + # "azure-developer-devcenter", # 2 breaks introduced into stable api-version +] + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser() + parser.add_argument( + "--sdk-root", + type=str, + required=True, + help="azure-sdk-for-java repository root.", + ) + parser.add_argument( + "--package-json-path", + type=str, + required=False, + default="", + help="path to package.json of typespec-java. Required when --emitter-version is empty " + "(the dev build route).", + ) + parser.add_argument( + "--emitter-version", + type=str, + required=False, + default="", + help="published @azure-tools/typespec-java version to regenerate with. When empty, the " + "emitter is built from source (dev route) instead.", + ) + return parser.parse_args() + + +EMITTER_PACKAGE_NAME = "@azure-tools/typespec-java" + +# Prefixes of the TypeSpec dependency entries in emitter-package.json whose versions we resolve to +# the latest published npm version (see resolve_dependency_versions_to_latest). +TYPESPEC_DEPENDENCY_PREFIXES = ("@azure-tools/", "@typespec/") + +# TypeSpec libraries that some specs depend on but which are intentionally NOT declared as +# dependencies of the typespec-java emitter itself (declaring them there would force every +# downstream emitter/repo to carry them - see discussion on Azure/typespec-azure PR 4866). We add +# them to emitter-package.json here so that generated SDKs referencing these libraries compile. +# +# These are versioned from the azure-rest-api-specs package.json (the source of truth for the +# versions the specs actually use), falling back to the latest published npm version if the specs +# repo has not updated yet. They are released independently of the TypeSpec compiler/Azure +# libraries, so their specs-pinned version does not have to move in lockstep with the emitter's +# other dependencies. +DESIGNATED_LIBRARIES_FROM_SPECS = [ + "@azure-tools/openai-typespec", + "@azure-tools/typespec-liftr-base", +] + +# These designated libraries are versioned from the latest published npm version instead of the +# specs repo. They belong to the same release group as the TypeSpec compiler / Azure libraries that +# the emitter depends on (e.g. @typespec/*, @azure-tools/typespec-azure-*), which +# resolve_dependency_versions_to_latest already pins to the latest published version. Sourcing +# these from npm latest too keeps the whole release group on the same version, avoiding peer +# conflicts that a lagging specs-repo pin (e.g. openapi3 requiring an older @typespec/http) would +# otherwise cause. +DESIGNATED_LIBRARIES_FROM_NPM_LATEST = [ + "@azure-tools/typespec-azure-portal-core", + "@typespec/openapi3", +] + +# All designated libraries, used to exclude them from resolve_dependency_versions_to_latest (they +# are versioned separately by add_designated_libraries). +DESIGNATED_LIBRARIES = DESIGNATED_LIBRARIES_FROM_SPECS + DESIGNATED_LIBRARIES_FROM_NPM_LATEST + +# package.json of the specs repo, the source of truth for the specs-versioned designated libraries. +SPECS_PACKAGE_JSON_URL = "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/package.json" + + +def emitter_package_json_path() -> str: + return os.path.join(sdk_root, "eng", "emitter-package.json") + + +def extract_package_json_from_tgz(tgz_path: str, dest_path: str) -> None: + # npm/pnpm pack tarballs place all files under a top-level "package/" directory. The + # package.json inside has the "catalog:"/"workspace:" protocols resolved to concrete + # versions, which is what tsp-client generate-config-files needs (npm cannot resolve those + # protocols, and generate-config-files reads the emitter's peerDependencies from this file). + with tarfile.open(tgz_path, "r:gz") as tar: + with tar.extractfile("package/package.json") as member: + with open(dest_path, "wb") as f: + f.write(member.read()) + + +def generate_config_files(emitter_package_json: str, use_npm_pinning: bool, overrides_path: str = "") -> None: + # tsp-client generate-config-files seeds eng/emitter-package.json from an emitter package.json + # (its peerDependencies) and then generates the lock file (via "npm install"). Used by both + # routes: + # - Published route: use_npm_pinning=True so peer versions are pinned from the published + # emitter's dependencies (looked up with "npm view"). + # - Dev route: overrides_path points the emitter dependency at the locally built dev tarball, + # so the lock-generation "npm install" resolves the (unpublished) emitter from that tarball + # instead of the registry. --use-npm-pinning is not used, because it would "npm view" the + # unpublished dev emitter, which does not exist on the registry. + # + # Remove the designated libraries from any existing eng/emitter-package.json first: + # generate-config-files MERGES into it rather than replacing it, and it only overwrites entries + # that are emitter peers. A designated library left from a previous run (e.g. @typespec/openapi3, + # which is NOT an emitter peer) would survive the merge with its stale version and break the + # lock-generation "npm install" with ERESOLVE. We add the designated libraries back (from npm + # latest or the specs repo) after seeding, so the merge starts from only the emitter's own peers. + # + # Alternative: delete the whole eng/emitter-package.json before generating (os.remove) so it is + # seeded entirely from scratch. That is more robust against non-designated orphans (e.g. an + # emitter peer that was dropped), but it regenerates the key order from the emitter manifest, + # producing noisier diffs. We remove only the designated entries to keep the existing key order. + remove_designated_libraries() + + command = [ + "tsp-client", + "generate-config-files", + "--package-json", + emitter_package_json, + "--emitter-package-json-path", + emitter_package_json_path(), + ] + if use_npm_pinning: + command.append("--use-npm-pinning") + if overrides_path: + command.extend(["--overrides", overrides_path]) + subprocess.check_call(command, cwd=sdk_root) + + +def npm_view_version(package_ref: str) -> str: + # "npm view version" reads a published version from the npm registry. Preferred over + # "ncu -u" (which may be unavailable in CFS environments) for looking up dependency versions. + return subprocess.check_output( + ["npm", "view", package_ref, "version"], + cwd=sdk_root, + text=True, + ).strip() + + +def load_emitter_package_json() -> dict: + with open(emitter_package_json_path(), "r") as json_file: + return json.load(json_file) + + +def save_emitter_package_json(package_json: dict) -> None: + with open(emitter_package_json_path(), "w") as json_file: + json.dump(package_json, json_file, indent=2) + + +def remove_designated_libraries() -> None: + # Remove the designated libraries from an existing eng/emitter-package.json before seeding. + # generate-config-files merges into that file and only overwrites emitter-peer entries, so a + # designated library carried over from a previous run (e.g. @typespec/openapi3) would keep its + # stale version and conflict with the freshly pinned peers. They are added back afterward by + # add_designated_libraries. The skipped designated libraries (still emitter peers) are re-added + # by generate-config-files itself from the emitter's peerDependencies. + path = emitter_package_json_path() + if not os.path.exists(path): + return + package_json = load_emitter_package_json() + dev_dependencies = package_json.get("devDependencies", {}) + for library in DESIGNATED_LIBRARIES: + if library in dev_dependencies: + logging.info(f"Remove designated library {library} before seeding") + del dev_dependencies[library] + save_emitter_package_json(package_json) + + +def resolve_dependency_versions_to_latest() -> None: + # Seeding (either route) leaves the @azure-tools/* and @typespec/* devDependencies as the + # emitter's caret ranges (e.g. "^0.70.0"), but eng/emitter-package.json must pin exact versions. + # Resolve each of these entries to its latest published version via "npm view ...@latest". + # Designated libraries are handled separately (from the specs repo), so skip them here. + package_json = load_emitter_package_json() + dev_dependencies = package_json.get("devDependencies", {}) + for name in list(dev_dependencies.keys()): + if name in DESIGNATED_LIBRARIES: + continue + if name.startswith(TYPESPEC_DEPENDENCY_PREFIXES): + version = npm_view_version(f"{name}@latest") + logging.info(f"Resolve {name} to latest published version {version}") + dev_dependencies[name] = version + save_emitter_package_json(package_json) + + +def fetch_specs_dev_dependencies() -> dict: + # Read the devDependencies map from the specs repo package.json, the source of truth for the + # designated library versions. + logging.info(f"Fetch designated library versions from {SPECS_PACKAGE_JSON_URL}") + with urllib.request.urlopen(SPECS_PACKAGE_JSON_URL, timeout=30) as response: + specs_package_json = json.loads(response.read().decode("utf-8")) + return specs_package_json.get("devDependencies", {}) + + +def add_designated_libraries() -> None: + # Add the designated libraries (not declared by the emitter) to emitter-package.json. Two + # groups, versioned from different sources: + # - DESIGNATED_LIBRARIES_FROM_SPECS: pinned to the exact version declared in the specs repo + # package.json (the version the specs actually use). If a library is missing there (the + # specs repo may not have updated yet), fall back to its latest published npm version. + # - DESIGNATED_LIBRARIES_FROM_NPM_LATEST: pinned to the latest published npm version. + specs_dev_dependencies = fetch_specs_dev_dependencies() + package_json = load_emitter_package_json() + dev_dependencies = package_json.setdefault("devDependencies", {}) + + for library in DESIGNATED_LIBRARIES_FROM_SPECS: + version = specs_dev_dependencies.get(library) + if version: + logging.info(f"Add designated library {library}@{version} (from specs repo)") + else: + version = npm_view_version(f"{library}@latest") + logging.info(f"Add designated library {library}@{version} (specs repo missing it, using npm latest)") + dev_dependencies[library] = version + + for library in DESIGNATED_LIBRARIES_FROM_NPM_LATEST: + version = npm_view_version(f"{library}@latest") + logging.info(f"Add designated library {library}@{version} (from npm latest)") + dev_dependencies[library] = version + + save_emitter_package_json(package_json) + + +def update_emitter(package_json_path: str, emitter_version: str): + # 'none' is the pipeline sentinel for "not specified" (Azure DevOps string parameters + # cannot be left truly empty in the run UI), so normalize it to empty here. + if emitter_version.lower() == "none": + emitter_version = "" + + if emitter_version: + # Published route (post-publish): seed emitter-package.json from the published emitter. + logging.info(f"Seed emitter-package.json from published typespec-java {emitter_version}") + with tempfile.TemporaryDirectory() as tmp_dir: + # "npm view --json" returns the published registry manifest (name, version, main, + # peerDependencies). generate-config-files --use-npm-pinning reads its peerDependencies + # to seed emitter-package.json, pinning the emitter to this published version. + manifest = subprocess.check_output( + ["npm", "view", f"{EMITTER_PACKAGE_NAME}@{emitter_version}", "--json"], + cwd=sdk_root, + text=True, + ) + published_package_json_path = os.path.join(tmp_dir, "package.json") + with open(published_package_json_path, "w") as f: + f.write(manifest) + + logging.info("Update emitter-package.json") + generate_config_files(published_package_json_path, use_npm_pinning=True) + else: + # Dev route: build the emitter from source, then seed emitter-package.json from the local + # dev package. The dev emitter version is unpublished, so generate-config-files consumes + # the emitter's (resolved) package.json extracted from the dev tarball, and an overrides + # file points the emitter dependency at that tarball so the lock-generation "npm install" + # can resolve the emitter locally instead of from the registry. + if not package_json_path: + raise ValueError("--package-json-path is required when --emitter-version is empty.") + + # Locate the dev package tarball built by the "Build typespec-java dev package" step of + # the post-publish-emitter pipeline (pnpm pack), next to the emitter's package.json. + dev_package_path = None + typespec_extension_path = os.path.dirname(package_json_path) + for file in os.listdir(typespec_extension_path): + if file.endswith(".tgz"): + dev_package_path = os.path.abspath(os.path.join(typespec_extension_path, file)) + logging.info(f'Found dev package at "{dev_package_path}"') + break + if not dev_package_path: + logging.error("Failed to locate the dev package.") + return + + with tempfile.TemporaryDirectory() as tmp_dir: + # The tarball's package.json has "catalog:"/"workspace:" protocols resolved to concrete + # versions, which generate-config-files needs (npm cannot resolve those protocols). + resolved_package_json_path = os.path.join(tmp_dir, "package.json") + extract_package_json_from_tgz(dev_package_path, resolved_package_json_path) + + # Point the (unpublished) emitter dependency at the local dev tarball. + overrides_path = os.path.join(tmp_dir, "overrides.json") + with open(overrides_path, "w") as f: + json.dump({EMITTER_PACKAGE_NAME: dev_package_path}, f) + + logging.info("Update emitter-package.json") + generate_config_files(resolved_package_json_path, use_npm_pinning=False, overrides_path=overrides_path) + + # Both routes: pin the emitter's TypeSpec dependencies to their latest published versions and + # add the designated libraries from the specs repo, then (re)generate the lock file so it + # reflects the final dependency set. + resolve_dependency_versions_to_latest() + add_designated_libraries() + + logging.info("Update emitter-package-lock.json") + generate_lock_file() + + +def update_latest_dev(): + subprocess.check_call( + ["npx", "-y", "@azure-tools/typespec-bump-deps", "eng/emitter-package.json", "--add-npm-overrides"], + cwd=sdk_root, + ) + + +def generate_lock_file(): + subprocess.check_call(["tsp-client", "generate-lock-file"], cwd=sdk_root) + + +def get_generated_folder_from_artifact(module_path: str, artifact: str, type: str) -> str: + path = os.path.join(module_path, "src", type, "java", "com") + for seg in artifact.split("-"): + path = os.path.join(path, seg) + path = os.path.join(path, "generated") + return path + + +def update_sdks(): + failed_modules = [] + for tsp_location_file in glob.glob(os.path.join(sdk_root, "sdk/*/*/tsp-location.yaml")): + module_path = os.path.dirname(tsp_location_file) + artifact = os.path.basename(module_path) + + arm_module = "-resourcemanager-" in artifact + + if artifact in skip_artifacts: + continue + + # # update commit ID for ARM module + # commit_id = "3c15c2f8c50fb3130b34887d29442da75f07fefb" + # if commit_id and arm_module: + # with open(tsp_location_file, "r", encoding="utf-8") as f_in: + # lines = f_in.readlines() + # lines_out = [] + # for line in lines: + # if line.startswith("commit:"): + # line = f"commit: {commit_id}\n" + # lines_out.append(line) + # with open(tsp_location_file, "w", encoding="utf-8") as f_out: + # f_out.writelines(lines_out) + + # logging.info("Updated tsp-location file content:\n%s", "".join(lines_out)) + + if os.path.dirname(module_path).endswith("-v2"): + # skip modules on azure-core-v2 + logging.info(f"Skip azure-core-v2 module on path {module_path}") + continue + + generated_samples_path = get_generated_folder_from_artifact(module_path, artifact, "samples") + generated_test_path = get_generated_folder_from_artifact(module_path, artifact, "test") + generated_samples_exists = os.path.isdir(generated_samples_path) + generated_test_exists = os.path.isdir(generated_test_path) + + if arm_module: + logging.info("Delete generated source code of resourcemanager module %s", artifact) + shutil.rmtree(os.path.join(module_path, "src", "main", "resources"), ignore_errors=True) + delete_generated_source_code(os.path.join(module_path, "src", "main", "java")) + + logging.info(f"Generate for module {artifact}") + try: + subprocess.check_call(["tsp-client", "update"], cwd=module_path) + except subprocess.CalledProcessError: + # one retry + # sometimes customization have intermittent failure + logging.warning(f"Retry generate for module {artifact}") + try: + subprocess.check_call(["tsp-client", "update", "--debug"], cwd=module_path) + except subprocess.CalledProcessError: + logging.error(f"Failed to generate for module {artifact}") + failed_modules.append(artifact) + + if not arm_module: + # run mvn package, as this is what's done in "TypeSpec-Compare-CurrentToCodegeneration.ps1" script + try: + subprocess.check_call( + ["mvn", "--no-transfer-progress", "codesnippet:update-codesnippet"], cwd=module_path + ) + except subprocess.CalledProcessError: + logging.error(f"Failed to update code snippet for module {artifact}") + failed_modules.append(artifact) + + if arm_module: + # revert mock test code + cmd = ["git", "checkout", "src/test"] + subprocess.check_call(cmd, cwd=module_path) + + # For ARM module, we want to keep the generated samples code. + # For data-plane, if the generated samples/test code is not there before generation, we will delete the generated code after generation, to avoid unnecessary code check-in. + if not generated_samples_exists and not arm_module: + shutil.rmtree(generated_samples_path, ignore_errors=True) + if not generated_test_exists: + shutil.rmtree(generated_test_path, ignore_errors=True) + + # revert change on pom.xml, readme.md, changelog.md, etc. + cmd = ["git", "checkout", "**/pom.xml"] + subprocess.check_call(cmd, cwd=sdk_root) + cmd = ["git", "checkout", "**/*.md"] + subprocess.check_call(cmd, cwd=sdk_root) + + # temporary, revert change on metadata.json + cmd = ["git", "checkout", "**/*_metadata.json"] + subprocess.check_call(cmd, cwd=sdk_root) + + cmd = ["git", "add", "."] + subprocess.check_call(cmd, cwd=sdk_root) + + if failed_modules: + logging.error(f"Failed modules {failed_modules}") + + +def apply_patches() -> None: + failed_patches = [] + for patch_file in glob.glob(os.path.join(script_root, "patches/*.patch")): + try: + subprocess.check_call(["git", "apply", patch_file, "--ignore-whitespace"], cwd=sdk_root) + except subprocess.CalledProcessError: + logging.error(f"Failed to apply patch {patch_file}") + failed_patches.append(patch_file) + + if failed_patches: + logging.error(f"Failed patches {failed_patches}") + + +def delete_generated_source_code(path: str) -> None: + autorest_generated_header = "Code generated by Microsoft (R) AutoRest Code Generator" + typespec_generated_header = "Code generated by Microsoft (R) TypeSpec Code Generator" + if os.path.exists(path): + for file in os.listdir(path): + cur_path = os.path.join(path, file) + if os.path.isdir(cur_path): + # Recurse into subdirectory + delete_generated_source_code(cur_path) + else: + try: + # Read file content and check for header + with open(cur_path, "r", encoding="utf-8") as f: + content = f.read() + if autorest_generated_header in content or typespec_generated_header in content: + os.remove(cur_path) # Delete the file + except Exception as e: + # Skip files that can't be read (binary files, permission issues) + print(f"Warning: Could not process file {cur_path}: {e}") + continue + + +def main(): + global sdk_root + + args = vars(parse_args()) + sdk_root = args["sdk_root"] + + update_emitter( + args["package_json_path"], + args["emitter_version"], + ) + + update_sdks() + + apply_patches() + + +if __name__ == "__main__": + logging.basicConfig( + stream=sys.stdout, + level=logging.INFO, + format="%(asctime)s %(levelname)s %(message)s", + datefmt="%Y-%m-%d %X", + ) + main() diff --git a/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/IotHubResourcesTestAllRoutesWithResponseMockTests.java b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/IotHubResourcesTestAllRoutesWithResponseMockTests.java new file mode 100644 index 000000000000..78646f316465 --- /dev/null +++ b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/IotHubResourcesTestAllRoutesWithResponseMockTests.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.iothub.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.iothub.IotHubManager; +import com.azure.resourcemanager.iothub.models.RoutingMessage; +import com.azure.resourcemanager.iothub.models.RoutingSource; +import com.azure.resourcemanager.iothub.models.RoutingTwin; +import com.azure.resourcemanager.iothub.models.RoutingTwinProperties; +import com.azure.resourcemanager.iothub.models.TestAllRoutesInput; +import com.azure.resourcemanager.iothub.models.TestAllRoutesResult; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class IotHubResourcesTestAllRoutesWithResponseMockTests { + @Test + public void testTestAllRoutesWithResponse() throws Exception { + String responseStr + = "{\"routes\":[{\"properties\":{\"name\":\"p\",\"source\":\"DeviceJobLifecycleEvents\",\"condition\":\"stwit\",\"endpointNames\":[\"hevxcced\",\"pnmdyodnwzxltjcv\",\"hlt\"],\"isEnabled\":true}},{\"properties\":{\"name\":\"cxnavv\",\"source\":\"DeviceMessages\",\"condition\":\"ibyqunyowxwlmdj\",\"endpointNames\":[\"vfgbvfvpdboda\"],\"isEnabled\":true}},{\"properties\":{\"name\":\"sjq\",\"source\":\"DeviceMessages\",\"condition\":\"rribd\",\"endpointNames\":[\"b\",\"ipqkghvxndzwm\"],\"isEnabled\":true}}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + IotHubManager manager = IotHubManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + TestAllRoutesResult response = manager.iotHubResources() + .testAllRoutesWithResponse("dcngqqmoakufgmj", "rwr", + new TestAllRoutesInput().withRoutingSource(RoutingSource.DIGITAL_TWIN_CHANGE_EVENTS) + .withMessage(new RoutingMessage().withBody("aenuuz") + .withAppProperties(mapOf("iefozbhdmsml", "bminrfdwoyuhhzi", "rmaequ", "zqhof")) + .withSystemProperties( + mapOf("z", "xicslfao", "kaivwit", "iyylhalnswhccsp", "bwemhairs", "scywuggwoluhc"))) + .withTwin(new RoutingTwin().withTags(mapOf("ggicccnxqhue", "\"datadwmsweypqwd\"")) + .withProperties(new RoutingTwinProperties() + .withDesired(mapOf("zrncsdt", "\"datatlstvlzywem\"", "bsfgytguslfea", "\"datalusiy\"", + "qukyhejhzi", "\"datacy\"", "srp", "\"dataxgfpelolppv\"")) + .withReported(mapOf("swibyr", "\"datajzraehtwdwrf\"", "h", "\"datadl\"")))), + com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("p", response.routes().get(0).properties().name()); + Assertions.assertEquals(RoutingSource.DEVICE_JOB_LIFECYCLE_EVENTS, + response.routes().get(0).properties().source()); + Assertions.assertEquals("stwit", response.routes().get(0).properties().condition()); + Assertions.assertEquals("hevxcced", response.routes().get(0).properties().endpointNames().get(0)); + Assertions.assertTrue(response.routes().get(0).properties().isEnabled()); + } + + // 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/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/IotHubResourcesTestRouteWithResponseMockTests.java b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/IotHubResourcesTestRouteWithResponseMockTests.java new file mode 100644 index 000000000000..81f4570afaf3 --- /dev/null +++ b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/IotHubResourcesTestRouteWithResponseMockTests.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.iothub.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.iothub.IotHubManager; +import com.azure.resourcemanager.iothub.models.RouteErrorSeverity; +import com.azure.resourcemanager.iothub.models.RouteProperties; +import com.azure.resourcemanager.iothub.models.RoutingMessage; +import com.azure.resourcemanager.iothub.models.RoutingSource; +import com.azure.resourcemanager.iothub.models.RoutingTwin; +import com.azure.resourcemanager.iothub.models.RoutingTwinProperties; +import com.azure.resourcemanager.iothub.models.TestResultStatus; +import com.azure.resourcemanager.iothub.models.TestRouteInput; +import com.azure.resourcemanager.iothub.models.TestRouteResult; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class IotHubResourcesTestRouteWithResponseMockTests { + @Test + public void testTestRouteWithResponse() throws Exception { + String responseStr + = "{\"result\":\"false\",\"details\":{\"compilationErrors\":[{\"message\":\"vriiio\",\"severity\":\"error\",\"location\":{\"start\":{},\"end\":{}}},{\"message\":\"kvtvsexso\",\"severity\":\"error\",\"location\":{\"start\":{},\"end\":{}}},{\"message\":\"hahhxvrhmzkwpj\",\"severity\":\"warning\",\"location\":{\"start\":{},\"end\":{}}},{\"message\":\"hftqsxhqxujxukn\",\"severity\":\"warning\",\"location\":{\"start\":{},\"end\":{}}}]}}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + IotHubManager manager = IotHubManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + TestRouteResult response + = manager.iotHubResources() + .testRouteWithResponse("efajpj", "rwkq", new TestRouteInput() + .withMessage(new RoutingMessage().withBody("gbijtjivfx") + .withAppProperties( + mapOf("bsystawfsdjpvk", "ab", "jxbkzbzkdvn", "p", "zhjjklffhmouwq", "jabudurgkakmo")) + .withSystemProperties(mapOf("bizikayuhq", "rfzeey", "wrv", "bjbsybb"))) + .withRoute(new RouteProperties().withName("ldgmfpgvmpip") + .withSource(RoutingSource.TWIN_CHANGE_EVENTS) + .withCondition("thaqfxssmwu") + .withEndpointNames(Arrays.asList("bdsrez", "drhneuyow")) + .withIsEnabled(false)) + .withTwin(new RoutingTwin() + .withTags(mapOf("sibircgpi", "\"datat\"", "vrmbzono", "\"datapzimejzanlfzxi\"")) + .withProperties(new RoutingTwinProperties().withDesired(mapOf("irgzp", "\"datajq\"")) + .withReported( + mapOf("jylwbtlhflsj", "\"dataazszrnwoiindfpw\"", "bgofeljag", "\"datadhszfjv\"")))), + com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals(TestResultStatus.FALSE, response.result()); + Assertions.assertEquals("vriiio", response.details().compilationErrors().get(0).message()); + Assertions.assertEquals(RouteErrorSeverity.ERROR, response.details().compilationErrors().get(0).severity()); + } + + // 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/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/RoutingTwinPropertiesTests.java b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/RoutingTwinPropertiesTests.java new file mode 100644 index 000000000000..e15525f6aa81 --- /dev/null +++ b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/RoutingTwinPropertiesTests.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.iothub.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.iothub.models.RoutingTwinProperties; +import java.util.HashMap; +import java.util.Map; + +public final class RoutingTwinPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + RoutingTwinProperties model = BinaryData.fromString( + "{\"desired\":{\"dtpnapnyiropuhp\":\"\\\"dataxknalaulppg\\\"\",\"gqgitxmedjvcsl\":\"\\\"datagvpgy\\\"\",\"wwncwzzhxgk\":\"\\\"datan\\\"\"},\"reported\":{\"ellwptfdy\":\"\\\"datagucnapkte\\\"\",\"rhhuaopppcqeqx\":\"\\\"datapfqbuaceopzf\\\"\"}}") + .toObject(RoutingTwinProperties.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + RoutingTwinProperties model = new RoutingTwinProperties() + .withDesired(mapOf("dtpnapnyiropuhp", "\"dataxknalaulppg\"", "gqgitxmedjvcsl", "\"datagvpgy\"", + "wwncwzzhxgk", "\"datan\"")) + .withReported(mapOf("ellwptfdy", "\"datagucnapkte\"", "rhhuaopppcqeqx", "\"datapfqbuaceopzf\"")); + model = BinaryData.fromObject(model).toObject(RoutingTwinProperties.class); + } + + // 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/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/RoutingTwinTests.java b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/RoutingTwinTests.java new file mode 100644 index 000000000000..7eaac6c799ed --- /dev/null +++ b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/RoutingTwinTests.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.iothub.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.iothub.models.RoutingTwin; +import com.azure.resourcemanager.iothub.models.RoutingTwinProperties; +import java.util.HashMap; +import java.util.Map; + +public final class RoutingTwinTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + RoutingTwin model = BinaryData.fromString( + "{\"tags\":{\"ultskzbbtdz\":\"\\\"dataxipeilpjzuaejx\\\"\",\"ekg\":\"\\\"datamv\\\"\"},\"properties\":{\"desired\":{\"fpbsjyofdxl\":\"\\\"datauh\\\"\",\"ttouwaboekqvkel\":\"\\\"dataus\\\"\",\"xwyjsflhhc\":\"\\\"datasmv\\\"\"},\"reported\":{\"ixisxyawjoy\":\"\\\"datan\\\"\",\"yexz\":\"\\\"dataqcslyjpkiid\\\"\",\"hnrztfol\":\"\\\"dataeli\\\"\"}}}") + .toObject(RoutingTwin.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + RoutingTwin model = new RoutingTwin() + .withTags(mapOf("ultskzbbtdz", "\"dataxipeilpjzuaejx\"", "ekg", "\"datamv\"")) + .withProperties(new RoutingTwinProperties() + .withDesired( + mapOf("fpbsjyofdxl", "\"datauh\"", "ttouwaboekqvkel", "\"dataus\"", "xwyjsflhhc", "\"datasmv\"")) + .withReported( + mapOf("ixisxyawjoy", "\"datan\"", "yexz", "\"dataqcslyjpkiid\"", "hnrztfol", "\"dataeli\""))); + model = BinaryData.fromObject(model).toObject(RoutingTwin.class); + } + + // 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/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/TestAllRoutesInputTests.java b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/TestAllRoutesInputTests.java new file mode 100644 index 000000000000..45f2015dbb11 --- /dev/null +++ b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/TestAllRoutesInputTests.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 com.azure.resourcemanager.iothub.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.iothub.models.RoutingMessage; +import com.azure.resourcemanager.iothub.models.RoutingSource; +import com.azure.resourcemanager.iothub.models.RoutingTwin; +import com.azure.resourcemanager.iothub.models.RoutingTwinProperties; +import com.azure.resourcemanager.iothub.models.TestAllRoutesInput; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class TestAllRoutesInputTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TestAllRoutesInput model = BinaryData.fromString( + "{\"routingSource\":\"MqttBrokerMessages\",\"message\":{\"body\":\"io\",\"appProperties\":{\"xosow\":\"hakauhashsf\",\"cjooxdjebwpucwwf\":\"xcug\",\"hzceuojgjrwjue\":\"ovbvmeueciv\"},\"systemProperties\":{\"xnrj\":\"wmcdytdxwi\"}},\"twin\":{\"tags\":{\"skxfbk\":\"\\\"datawgxhn\\\"\",\"gklwn\":\"\\\"datay\\\"\",\"vylwzbtdhxuj\":\"\\\"datanhjdauw\\\"\"},\"properties\":{\"desired\":{\"wpr\":\"\\\"datapow\\\"\",\"xobbcswsrt\":\"\\\"dataqlveualupjmkh\\\"\"},\"reported\":{\"blcg\":\"\\\"dataplrbpbewtghf\\\"\",\"nmxiebwwaloayqc\":\"\\\"dataxzvlvqhjkbegib\\\"\",\"uzgwyzmhtx\":\"\\\"datawrtz\\\"\",\"wxqpsrknftguvri\":\"\\\"datangmtsavjcb\\\"\"}}}}") + .toObject(TestAllRoutesInput.class); + Assertions.assertEquals(RoutingSource.MQTT_BROKER_MESSAGES, model.routingSource()); + Assertions.assertEquals("io", model.message().body()); + Assertions.assertEquals("hakauhashsf", model.message().appProperties().get("xosow")); + Assertions.assertEquals("wmcdytdxwi", model.message().systemProperties().get("xnrj")); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TestAllRoutesInput model = new TestAllRoutesInput().withRoutingSource(RoutingSource.MQTT_BROKER_MESSAGES) + .withMessage(new RoutingMessage().withBody("io") + .withAppProperties( + mapOf("xosow", "hakauhashsf", "cjooxdjebwpucwwf", "xcug", "hzceuojgjrwjue", "ovbvmeueciv")) + .withSystemProperties(mapOf("xnrj", "wmcdytdxwi"))) + .withTwin(new RoutingTwin() + .withTags(mapOf("skxfbk", "\"datawgxhn\"", "gklwn", "\"datay\"", "vylwzbtdhxuj", "\"datanhjdauw\"")) + .withProperties(new RoutingTwinProperties() + .withDesired(mapOf("wpr", "\"datapow\"", "xobbcswsrt", "\"dataqlveualupjmkh\"")) + .withReported(mapOf("blcg", "\"dataplrbpbewtghf\"", "nmxiebwwaloayqc", "\"dataxzvlvqhjkbegib\"", + "uzgwyzmhtx", "\"datawrtz\"", "wxqpsrknftguvri", "\"datangmtsavjcb\"")))); + model = BinaryData.fromObject(model).toObject(TestAllRoutesInput.class); + Assertions.assertEquals(RoutingSource.MQTT_BROKER_MESSAGES, model.routingSource()); + Assertions.assertEquals("io", model.message().body()); + Assertions.assertEquals("hakauhashsf", model.message().appProperties().get("xosow")); + Assertions.assertEquals("wmcdytdxwi", model.message().systemProperties().get("xnrj")); + } + + // 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/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/TestRouteInputTests.java b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/TestRouteInputTests.java new file mode 100644 index 000000000000..f0d885991b16 --- /dev/null +++ b/sdk/iothub/azure-resourcemanager-iothub/src/test/java/com/azure/resourcemanager/iothub/generated/TestRouteInputTests.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 com.azure.resourcemanager.iothub.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.iothub.models.RouteProperties; +import com.azure.resourcemanager.iothub.models.RoutingMessage; +import com.azure.resourcemanager.iothub.models.RoutingSource; +import com.azure.resourcemanager.iothub.models.RoutingTwin; +import com.azure.resourcemanager.iothub.models.RoutingTwinProperties; +import com.azure.resourcemanager.iothub.models.TestRouteInput; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class TestRouteInputTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + TestRouteInput model = BinaryData.fromString( + "{\"message\":{\"body\":\"xv\",\"appProperties\":{\"blytk\":\"yslqbhsfx\",\"rn\":\"lmpewwwfbkr\"},\"systemProperties\":{\"rruvwbhsq\":\"hqjohxcrsbfova\",\"gjb\":\"sub\",\"rfbjf\":\"rxbpyb\"}},\"route\":{\"name\":\"twss\",\"source\":\"Invalid\",\"condition\":\"tpvjzbexilzznfqq\",\"endpointNames\":[\"wpmqt\"],\"isEnabled\":false},\"twin\":{\"tags\":{\"ybn\":\"\\\"datajmkcjhwqytj\\\"\",\"aen\":\"\\\"datajewgdrjerv\\\"\",\"fthnzdn\":\"\\\"datapehindoygm\\\"\"},\"properties\":{\"desired\":{\"ynduha\":\"\\\"datanayqi\\\"\",\"bgycduiertgccym\":\"\\\"datahqlkthumaqo\\\"\",\"lqlfm\":\"\\\"dataaolps\\\"\"},\"reported\":{\"yhz\":\"\\\"databbglzpswiydmc\\\"\"}}}}") + .toObject(TestRouteInput.class); + Assertions.assertEquals("xv", model.message().body()); + Assertions.assertEquals("yslqbhsfx", model.message().appProperties().get("blytk")); + Assertions.assertEquals("hqjohxcrsbfova", model.message().systemProperties().get("rruvwbhsq")); + Assertions.assertEquals("twss", model.route().name()); + Assertions.assertEquals(RoutingSource.INVALID, model.route().source()); + Assertions.assertEquals("tpvjzbexilzznfqq", model.route().condition()); + Assertions.assertEquals("wpmqt", model.route().endpointNames().get(0)); + Assertions.assertFalse(model.route().isEnabled()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + TestRouteInput model + = new TestRouteInput() + .withMessage(new RoutingMessage().withBody("xv") + .withAppProperties(mapOf("blytk", "yslqbhsfx", "rn", "lmpewwwfbkr")) + .withSystemProperties(mapOf("rruvwbhsq", "hqjohxcrsbfova", "gjb", "sub", "rfbjf", "rxbpyb"))) + .withRoute(new RouteProperties().withName("twss") + .withSource(RoutingSource.INVALID) + .withCondition("tpvjzbexilzznfqq") + .withEndpointNames(Arrays.asList("wpmqt")) + .withIsEnabled(false)) + .withTwin( + new RoutingTwin() + .withTags(mapOf("ybn", "\"datajmkcjhwqytj\"", "aen", "\"datajewgdrjerv\"", "fthnzdn", + "\"datapehindoygm\"")) + .withProperties(new RoutingTwinProperties() + .withDesired(mapOf("ynduha", "\"datanayqi\"", "bgycduiertgccym", "\"datahqlkthumaqo\"", + "lqlfm", "\"dataaolps\"")) + .withReported(mapOf("yhz", "\"databbglzpswiydmc\"")))); + model = BinaryData.fromObject(model).toObject(TestRouteInput.class); + Assertions.assertEquals("xv", model.message().body()); + Assertions.assertEquals("yslqbhsfx", model.message().appProperties().get("blytk")); + Assertions.assertEquals("hqjohxcrsbfova", model.message().systemProperties().get("rruvwbhsq")); + Assertions.assertEquals("twss", model.route().name()); + Assertions.assertEquals(RoutingSource.INVALID, model.route().source()); + Assertions.assertEquals("tpvjzbexilzznfqq", model.route().condition()); + Assertions.assertEquals("wpmqt", model.route().endpointNames().get(0)); + Assertions.assertFalse(model.route().isEnabled()); + } + + // 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/sdk/planetarycomputer/azure-analytics-planetarycomputer/src/main/java/com/azure/analytics/planetarycomputer/DataAsyncClient.java b/sdk/planetarycomputer/azure-analytics-planetarycomputer/src/main/java/com/azure/analytics/planetarycomputer/DataAsyncClient.java index aba4dc301c3d..3bebb8bc7568 100644 --- a/sdk/planetarycomputer/azure-analytics-planetarycomputer/src/main/java/com/azure/analytics/planetarycomputer/DataAsyncClient.java +++ b/sdk/planetarycomputer/azure-analytics-planetarycomputer/src/main/java/com/azure/analytics/planetarycomputer/DataAsyncClient.java @@ -5,6 +5,7 @@ package com.azure.analytics.planetarycomputer; import com.azure.analytics.planetarycomputer.implementation.DatasImpl; +import com.azure.analytics.planetarycomputer.implementation.XmlSerializerProviders; import com.azure.analytics.planetarycomputer.implementation.models.RegisterMosaicsSearchRequest; import com.azure.analytics.planetarycomputer.models.AssetStatisticsResponse; import com.azure.analytics.planetarycomputer.models.ClassMapLegendResponse; @@ -55,6 +56,7 @@ import com.azure.core.util.FluxUtil; import com.azure.core.util.serializer.CollectionFormat; import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.ObjectSerializer; import com.azure.core.util.serializer.TypeReference; import java.util.List; import java.util.Objects; @@ -66,6 +68,9 @@ */ @ServiceClient(builder = PlanetaryComputerProClientBuilder.class, isAsync = true) public final class DataAsyncClient { + @Generated + private static final ObjectSerializer SERIALIZER = XmlSerializerProviders.createInstance(); + @Generated private final DatasImpl serviceClient; @@ -4217,7 +4222,7 @@ public Mono getWmtsCapabilities(String collectionId, String itemId, Stri } return getWmtsCapabilitiesWithResponse(collectionId, itemId, tileMatrixSetId, requestOptions) .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(byte[].class)); + .map(protocolMethodData -> protocolMethodData.toObject(byte[].class, SERIALIZER)); } /** @@ -5118,7 +5123,7 @@ public Mono getMosaicsWmtsCapabilities(String searchId, String tileMatri } return getMosaicsWmtsCapabilitiesWithResponse(searchId, tileMatrixSetId, requestOptions) .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(byte[].class)); + .map(protocolMethodData -> protocolMethodData.toObject(byte[].class, SERIALIZER)); } @Generated diff --git a/sdk/planetarycomputer/azure-analytics-planetarycomputer/src/main/java/com/azure/analytics/planetarycomputer/DataClient.java b/sdk/planetarycomputer/azure-analytics-planetarycomputer/src/main/java/com/azure/analytics/planetarycomputer/DataClient.java index 527d6e873add..808d4d505411 100644 --- a/sdk/planetarycomputer/azure-analytics-planetarycomputer/src/main/java/com/azure/analytics/planetarycomputer/DataClient.java +++ b/sdk/planetarycomputer/azure-analytics-planetarycomputer/src/main/java/com/azure/analytics/planetarycomputer/DataClient.java @@ -5,6 +5,7 @@ package com.azure.analytics.planetarycomputer; import com.azure.analytics.planetarycomputer.implementation.DatasImpl; +import com.azure.analytics.planetarycomputer.implementation.XmlSerializerProviders; import com.azure.analytics.planetarycomputer.implementation.models.RegisterMosaicsSearchRequest; import com.azure.analytics.planetarycomputer.models.AssetStatisticsResponse; import com.azure.analytics.planetarycomputer.models.ClassMapLegendResponse; @@ -54,6 +55,7 @@ import com.azure.core.util.BinaryData; import com.azure.core.util.serializer.CollectionFormat; import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.ObjectSerializer; import com.azure.core.util.serializer.TypeReference; import java.util.List; import java.util.Objects; @@ -64,6 +66,9 @@ */ @ServiceClient(builder = PlanetaryComputerProClientBuilder.class) public final class DataClient { + @Generated + private static final ObjectSerializer SERIALIZER = XmlSerializerProviders.createInstance(); + @Generated private final DatasImpl serviceClient; @@ -4194,7 +4199,7 @@ public byte[] getWmtsCapabilities(String collectionId, String itemId, String til requestOptions.addQueryParam("return_mask", String.valueOf(returnMask), false); } return getWmtsCapabilitiesWithResponse(collectionId, itemId, tileMatrixSetId, requestOptions).getValue() - .toObject(byte[].class); + .toObject(byte[].class, SERIALIZER); } /** @@ -5087,7 +5092,7 @@ public byte[] getMosaicsWmtsCapabilities(String searchId, String tileMatrixSetId requestOptions.addQueryParam("return_mask", String.valueOf(returnMask), false); } return getMosaicsWmtsCapabilitiesWithResponse(searchId, tileMatrixSetId, requestOptions).getValue() - .toObject(byte[].class); + .toObject(byte[].class, SERIALIZER); } @Generated