From fb0cd8067ed93078879bf7b4aa37287556603199 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 01:56:22 +0000 Subject: [PATCH 1/5] Initial plan From 7cc30fd363702ceb5b653a16c14b1cf302a3e4e7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 4 Jan 2026 02:00:58 +0000 Subject: [PATCH 2/5] Update @azure-tools/typespec-client-generator-core from 0.63.1 to 0.63.3 Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> --- .../package.json | 2 +- .../http-client-generator-test/package.json | 2 +- packages/http-client-java/package-lock.json | 28 ++++--------------- packages/http-client-java/package.json | 4 +-- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json index 35478e55f04..a4067408457 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json @@ -30,7 +30,7 @@ "@typespec/sse": "0.77.0", "@typespec/streams": "0.77.0", "@azure-tools/typespec-azure-core": "0.63.0", - "@azure-tools/typespec-client-generator-core": "0.63.1", + "@azure-tools/typespec-client-generator-core": "0.63.3", "@azure-tools/typespec-azure-resource-manager": "0.63.0", "@azure-tools/typespec-autorest": "0.63.1" }, diff --git a/packages/http-client-java/generator/http-client-generator-test/package.json b/packages/http-client-java/generator/http-client-generator-test/package.json index b9553a05d52..952a799635d 100644 --- a/packages/http-client-java/generator/http-client-generator-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-test/package.json @@ -30,7 +30,7 @@ "@typespec/sse": "0.77.0", "@typespec/streams": "0.77.0", "@azure-tools/typespec-azure-core": "0.63.0", - "@azure-tools/typespec-client-generator-core": "0.63.1", + "@azure-tools/typespec-client-generator-core": "0.63.3", "@azure-tools/typespec-azure-resource-manager": "0.63.0", "@azure-tools/typespec-autorest": "0.63.1" }, diff --git a/packages/http-client-java/package-lock.json b/packages/http-client-java/package-lock.json index 452195a0fdd..11a47c78415 100644 --- a/packages/http-client-java/package-lock.json +++ b/packages/http-client-java/package-lock.json @@ -18,7 +18,7 @@ "@azure-tools/typespec-azure-core": "0.63.0", "@azure-tools/typespec-azure-resource-manager": "0.63.0", "@azure-tools/typespec-azure-rulesets": "0.63.0", - "@azure-tools/typespec-client-generator-core": "0.63.1", + "@azure-tools/typespec-client-generator-core": "0.63.3", "@microsoft/api-extractor": "^7.55.2", "@microsoft/api-extractor-model": "^7.32.2", "@types/js-yaml": "~4.0.9", @@ -48,7 +48,7 @@ "@azure-tools/typespec-autorest": ">=0.63.1 <1.0.0", "@azure-tools/typespec-azure-core": ">=0.63.0 <1.0.0", "@azure-tools/typespec-azure-resource-manager": ">=0.63.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.63.1 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.63.3 <1.0.0", "@typespec/compiler": "^1.7.1", "@typespec/events": ">=0.77.0 <1.0.0", "@typespec/http": "^1.7.0", @@ -141,7 +141,6 @@ "integrity": "sha512-FbEmpZSQENzBt/Y8qSF1b98T8CqT3bV7IRV8AGGm/73NQZiWQCm2LvQzR0/lbqGntS2EnSBrt394Kt69wM4ifA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -157,7 +156,6 @@ "integrity": "sha512-QXHryXgV9Rh7lBW9hrehjdGVM/W8eBN6wnfRRZtAAyfTc1AkRGDKOMFBtRtfbEkQpur16mgQTd7EyH2tpqfuSw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "change-case": "~5.4.4", "pluralize": "^8.0.0" @@ -191,12 +189,11 @@ } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.63.1", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.63.1.tgz", - "integrity": "sha512-/LMrPVKrzPRBicjVSz+zqC/EBysqbIKgjfoAxMDXa4nmJchzxls+hgvprAZsCAJy5uEeshOn7WdNT/aQkBQRXw==", + "version": "0.63.3", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.63.3.tgz", + "integrity": "sha512-+ZSajpbwjZgMztgYgszFWzLrhOzjWNW7VEQjWvc7mMBtsF0fDTvB0gGfQlJ81CBM9yudPBW0JpwYrO26NXXk8g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "change-case": "~5.4.4", "pluralize": "^8.0.0", @@ -2285,7 +2282,6 @@ "integrity": "sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -2296,7 +2292,6 @@ "integrity": "sha512-sb3MEsKjFlAx8ZG484exs5Ec+JwmYf2anJqLjMusrV3rRMUhv3fbEulk9MD+l4eOkBS46VMNGqRu0wTn8suVVA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "~7.27.1", "@inquirer/prompts": "^8.0.1", @@ -2474,7 +2469,6 @@ "integrity": "sha512-NbOzi7axEt/xGgXaLjcGGV2HjQKNFjbvsQpCeDA6loUghZDK5+5ik/jwMumeUDunoBsAKF78ZxVF5qhQh56dGA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -2488,7 +2482,6 @@ "integrity": "sha512-4cGkcMiob3bedWbFkRcq614TDH7WPEI3YMgrg44mBarj903arpEniAESIhNUbLQzQFFc5rOJagexQDl4agVDyA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -2508,7 +2501,6 @@ "integrity": "sha512-tEAIgGnjLvOjbGAoCfkBudvpe/tXaOXkzy5nVFXs4921/jAaMTwzcJIt0bTXZpp5cExdlL7w9ZrnehARHiposQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -2523,7 +2515,6 @@ "integrity": "sha512-DEUMD9zYqUVUhKCGktV7Z+sFkzj+bcSpJRhEXxOrJxupWM4I3N4deMop+ulxezxlLxIRUz7ELc+6WucYXgOnAA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -2758,7 +2749,6 @@ "integrity": "sha512-rVML/sPNj+MomKXftko/eUNM5OhHlIevoit3Dbtaf1aWS5pcJ5jKX05Prz53VIyeUP7ra5ocmPE/iIEPb8ZbCA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -2775,7 +2765,6 @@ "integrity": "sha512-qqfJW4n19Jgi5FxQhsEgoIc5zD9o47AAoZxLKUX91z6aB/YWrLSTrrrIAvhNCESXuB89zlJPwlZ/j4YmpxZ/jw==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -2804,7 +2793,6 @@ "integrity": "sha512-eAInPZYPkxpBUS8IKQfNZ5eZsLfkWqEX0d6YM/AfooGYbxcKdHQBfYOWBvRC4NkKEMub4ROaD5GcPLYTyWQIWw==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -2818,7 +2806,6 @@ "integrity": "sha512-DNVAOMaRUPGpLEsqf3sn7UAWuAE1rs8Jf1FIAU7DF/sVmzeXs4OBanxSSsVmbcdfPRHPbjPuRnW6e+QS2Sjk3Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=20.0.0" }, @@ -2961,7 +2948,6 @@ "integrity": "sha512-rkoPH+RqWopVxDnCBE/ysIdfQ2A7j1eDmW8tCxxrR9nnFBa9jKf86VgsSAzxBd1x+ny0GC4JgiD3SNfRHv3pOg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@vitest/utils": "4.0.16", "fflate": "^0.8.2", @@ -6840,7 +6826,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -7031,7 +7016,6 @@ "integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -7125,7 +7109,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -7139,7 +7122,6 @@ "integrity": "sha512-E4t7DJ9pESL6E3I8nFjPa4xGUd3PmiWDLsDztS2qXSJWfHtbQnwAWylaBvSNY48I3vr8PTqIZlyK8TE3V3CA4Q==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@vitest/expect": "4.0.16", "@vitest/mocker": "4.0.16", diff --git a/packages/http-client-java/package.json b/packages/http-client-java/package.json index 84af36dd368..6cfc015cc37 100644 --- a/packages/http-client-java/package.json +++ b/packages/http-client-java/package.json @@ -52,7 +52,7 @@ "@azure-tools/typespec-autorest": ">=0.63.1 <1.0.0", "@azure-tools/typespec-azure-core": ">=0.63.0 <1.0.0", "@azure-tools/typespec-azure-resource-manager": ">=0.63.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.63.1 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.63.3 <1.0.0", "@typespec/compiler": "^1.7.1", "@typespec/events": ">=0.77.0 <1.0.0", "@typespec/http": "^1.7.0", @@ -73,7 +73,7 @@ "@azure-tools/typespec-azure-core": "0.63.0", "@azure-tools/typespec-azure-resource-manager": "0.63.0", "@azure-tools/typespec-azure-rulesets": "0.63.0", - "@azure-tools/typespec-client-generator-core": "0.63.1", + "@azure-tools/typespec-client-generator-core": "0.63.3", "@microsoft/api-extractor": "^7.55.2", "@microsoft/api-extractor-model": "^7.32.2", "@types/js-yaml": "~4.0.9", From 7d15149efab855b5a345f7408bd01450f8c94a5f Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Sun, 4 Jan 2026 10:31:27 +0800 Subject: [PATCH 3/5] delete local test of multiple server/service --- .../tsp/multiple-apiversion.tsp | 101 ------------------ .../http-client-generator-test/tsp/server.tsp | 65 ----------- 2 files changed, 166 deletions(-) delete mode 100644 packages/http-client-java/generator/http-client-generator-test/tsp/multiple-apiversion.tsp delete mode 100644 packages/http-client-java/generator/http-client-generator-test/tsp/server.tsp diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-apiversion.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-apiversion.tsp deleted file mode 100644 index e6c06188d07..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/multiple-apiversion.tsp +++ /dev/null @@ -1,101 +0,0 @@ -import "@typespec/rest"; -import "@azure-tools/typespec-azure-core"; -import "@azure-tools/typespec-client-generator-core"; - -using TypeSpec.Http; -using TypeSpec.Rest; -using TypeSpec.Versioning; -using Azure.Core; -using Azure.Core.Foundations; -using Azure.Core.Traits; -using Azure.ClientGenerator.Core; - -@service(#{ title: "MultipleApiVersion" }) -@versioned(TspTest.MultipleApiVersion.Versions) -@Azure.ClientGenerator.Core.client({ - name: "FirstClient", -}) -@clientNamespace("tsptest.multipleapiversion", "java") -namespace TspTest.MultipleApiVersion { - @resource("resources") - model Resource { - @visibility(Lifecycle.Read) - id: string; - - @key - @visibility(Lifecycle.Read) - name: string; - - type: string; - } - - interface ResourceOperations - extends Azure.Core.ResourceOperations {} - - enum Versions { - v2022_06_01_preview: "2022-06-01-preview", - v2022_12_01_preview: "2022-12-01-preview", - } - - @route("/client1") - interface Client { - get is ResourceOperations.ResourceRead; - } -} - -@service(#{ title: "MultipleApiVersion2" }) -@versioned(TspTest.MultipleApiVersion2.Versions) -@Azure.ClientGenerator.Core.client({ - name: "SecondClient", -}) -@clientNamespace("tsptest.multipleapiversion", "java") -namespace TspTest.MultipleApiVersion2 { - @resource("resources") - model Resource2 { - @visibility(Lifecycle.Read) - id: string; - - @key - @visibility(Lifecycle.Read) - name: string; - - type: string; - } - - interface ResourceOperations - extends Azure.Core.ResourceOperations {} - - enum Versions { - v2022_10_01_preview: "2022-10-01-preview", - v2022_12_01_preview: "2022-12-01-preview", - } - - @route("/client2") - interface Client { - get is ResourceOperations.ResourceRead; - } -} - -@service(#{ title: "MultipleApiVersion3" }) -@versioned(TspTest.MultipleApiVersion3.Versions) -@Azure.ClientGenerator.Core.client({ - name: "NoApiVersionClient", -}) -@clientNamespace("tsptest.multipleapiversion", "java") -namespace TspTest.MultipleApiVersion3 { - enum Versions { - v2022_10_01_preview: "2022-10-01-preview", - v2022_12_01_preview: "2022-12-01-preview", - } - - @route("/client3") - interface Client { - // no api-version query parameter in the API - @post - action(@added(Versions.v2022_12_01_preview) @query param1?: string): OkResponse; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/server.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/server.tsp deleted file mode 100644 index 37b50aadee7..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/tsp/server.tsp +++ /dev/null @@ -1,65 +0,0 @@ -import "@typespec/rest"; -import "@typespec/versioning"; -import "@azure-tools/typespec-client-generator-core"; - -using TypeSpec.Http; -using TypeSpec.Versioning; -using Azure.ClientGenerator.Core; - -@service(#{ title: "HttpbinServer" }) -@server( - "https://{domain}.{tld}{relative-path}", - "Httpbin endpoint", - { - @doc("second-level domain, use httpbin") - domain: string = "httpbin", - - @doc("top-level domain, use org") - tld: string = "org", - - @doc("relative path segment, can be empty") - `relative-path`?: string, - } -) -@clientNamespace("tsptest.server", "java") -namespace TspTest.Server { - @Azure.ClientGenerator.Core.client({ - name: "HttpbinClient", - service: TspTest.Server, - }) - @route("/status/{code}") - interface ServerOp { - status(@path code: int32): OkResponse | NoContentResponse; - } -} - -@service(#{ title: "ContosoServer" }) -@versioned(TspTest.ContosoServer.APIVersions) -@server( - "{Endpoint}/contoso/{ApiVersion}", - "Service endpoint", - { - @doc("Service endpoint") - Endpoint: url, - - @doc("Api Version") - @path - ApiVersion: APIVersions, - } -) -@clientNamespace("tsptest.server.contoso", "java") -namespace TspTest.ContosoServer { - enum APIVersions { - v1: "v1", - } - - @client({ - name: "ContosoClient", - service: TspTest.ContosoServer, - }) - @route("/contoso/") - @clientNamespace("tsptest.server.contoso.sub", "java") - interface ServerOp { - get(@path(#{ allowReserved: true }) group: string): OkResponse | NoContentResponse; - } -} From 156a7ec0e5edafa5486196ca65cd090cd890af43 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Sun, 4 Jan 2026 10:46:12 +0800 Subject: [PATCH 4/5] regen --- .../multipleapiversion/FirstAsyncClient.java | 89 ----- .../multipleapiversion/FirstClient.java | 86 ----- .../FirstClientBuilder.java | 308 ---------------- .../FirstServiceVersion.java | 45 --- .../NoApiVersionAsyncClient.java | 72 ---- .../NoApiVersionClient.java | 69 ---- .../NoApiVersionClientBuilder.java | 308 ---------------- .../NoApiVersionServiceVersion.java | 45 --- .../multipleapiversion/SecondAsyncClient.java | 89 ----- .../multipleapiversion/SecondClient.java | 86 ----- .../SecondClientBuilder.java | 308 ---------------- .../SecondServiceVersion.java | 45 --- .../implementation/FirstClientImpl.java | 225 ------------ .../NoApiVersionClientImpl.java | 194 ----------- .../implementation/SecondClientImpl.java | 225 ------------ .../implementation/package-info.java | 10 - .../multipleapiversion/models/Resource.java | 125 ------- .../multipleapiversion/models/Resource2.java | 125 ------- .../models/package-info.java | 10 - .../multipleapiversion/package-info.java | 10 - .../tsptest/server/ContosoServiceVersion.java | 40 --- .../tsptest/server/HttpbinAsyncClient.java | 75 ---- .../java/tsptest/server/HttpbinClient.java | 72 ---- .../tsptest/server/HttpbinClientBuilder.java | 326 ----------------- .../server/contoso/models/APIVersions.java | 51 --- .../server/contoso/models/package-info.java | 10 - .../contoso/sub/ContosoAsyncClient.java | 75 ---- .../server/contoso/sub/ContosoClient.java | 72 ---- .../contoso/sub/ContosoClientBuilder.java | 328 ------------------ .../server/contoso/sub/package-info.java | 10 - .../implementation/ContosoClientImpl.java | 216 ------------ .../implementation/HttpbinClientImpl.java | 215 ------------ .../server/implementation/package-info.java | 10 - .../java/tsptest/server/package-info.java | 10 - ...multipleapiversion_apiview_properties.json | 28 -- .../tsptest-multipleapiversion_metadata.json | 1 - .../tsptest-server_apiview_properties.json | 20 -- .../META-INF/tsptest-server_metadata.json | 1 - .../tsptest-multipleapiversion.properties | 2 - .../main/resources/tsptest-server.properties | 2 - .../generated/FirstClientTestBase.java | 60 ---- .../generated/HttpbinClientTestBase.java | 51 --- 42 files changed, 4149 deletions(-) delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/FirstAsyncClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/FirstClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/FirstClientBuilder.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/FirstServiceVersion.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/NoApiVersionAsyncClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/NoApiVersionClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/NoApiVersionClientBuilder.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/NoApiVersionServiceVersion.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/SecondAsyncClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/SecondClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/SecondClientBuilder.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/SecondServiceVersion.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/implementation/FirstClientImpl.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/implementation/NoApiVersionClientImpl.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/implementation/SecondClientImpl.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/implementation/package-info.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/Resource.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/Resource2.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/package-info.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/package-info.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/ContosoServiceVersion.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinAsyncClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinClientBuilder.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/models/APIVersions.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/models/package-info.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoAsyncClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoClient.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoClientBuilder.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/package-info.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/ContosoClientImpl.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/HttpbinClientImpl.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/package-info.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/package-info.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-multipleapiversion_apiview_properties.json delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-multipleapiversion_metadata.json delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-server_apiview_properties.json delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-server_metadata.json delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/tsptest-multipleapiversion.properties delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/main/resources/tsptest-server.properties delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/multipleapiversion/generated/FirstClientTestBase.java delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/server/generated/HttpbinClientTestBase.java diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/FirstAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/FirstAsyncClient.java deleted file mode 100644 index 1006384b72c..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/FirstAsyncClient.java +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.BinaryData; -import com.azure.core.util.FluxUtil; -import reactor.core.publisher.Mono; -import tsptest.multipleapiversion.implementation.FirstClientImpl; -import tsptest.multipleapiversion.models.Resource; - -/** - * Initializes a new instance of the asynchronous FirstClient type. - */ -@ServiceClient(builder = FirstClientBuilder.class, isAsync = true) -public final class FirstAsyncClient { - @Generated - private final FirstClientImpl serviceClient; - - /** - * Initializes an instance of FirstAsyncClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - FirstAsyncClient(FirstClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * Resource read operation template. - *

Response Body Schema

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

Response Body Schema

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

Response Body Schema

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

Response Body Schema

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

Response Body Schema

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

Response Body Schema

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

Response Body Schema

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

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     id: String (Required)
-     *     name: String (Required)
-     *     type: String (Required)
-     * }
-     * }
-     * 
- * - * @param name The name parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String name, RequestOptions requestOptions) { - final String accept = "application/json"; - return service.getSync(this.getEndpoint(), this.getServiceVersion().getVersion(), name, accept, requestOptions, - Context.NONE); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/implementation/package-info.java deleted file mode 100644 index ec238a77b29..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/implementation/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -/** - * - * Package containing the implementations for MultipleApiVersion. - * - */ -package tsptest.multipleapiversion.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/Resource.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/Resource.java deleted file mode 100644 index 831c5980185..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/Resource.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The Resource model. - */ -@Immutable -public final class Resource implements JsonSerializable { - /* - * The id property. - */ - @Generated - private String id; - - /* - * The name property. - */ - @Generated - private String name; - - /* - * The type property. - */ - @Generated - private final String type; - - /** - * Creates an instance of Resource class. - * - * @param type the type value to set. - */ - @Generated - private Resource(String type) { - this.type = type; - } - - /** - * Get the id property: The id property. - * - * @return the id value. - */ - @Generated - public String getId() { - return this.id; - } - - /** - * Get the name property: The name property. - * - * @return the name value. - */ - @Generated - public String getName() { - return this.name; - } - - /** - * Get the type property: The type property. - * - * @return the type value. - */ - @Generated - public String getType() { - return this.type; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Resource from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Resource if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the Resource. - */ - @Generated - public static Resource fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - String name = null; - String type = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("name".equals(fieldName)) { - name = reader.getString(); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - Resource deserializedResource = new Resource(type); - deserializedResource.id = id; - deserializedResource.name = name; - - return deserializedResource; - }); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/Resource2.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/Resource2.java deleted file mode 100644 index 99b5658d4f0..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/Resource2.java +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion.models; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The Resource2 model. - */ -@Immutable -public final class Resource2 implements JsonSerializable { - /* - * The id property. - */ - @Generated - private String id; - - /* - * The name property. - */ - @Generated - private String name; - - /* - * The type property. - */ - @Generated - private final String type; - - /** - * Creates an instance of Resource2 class. - * - * @param type the type value to set. - */ - @Generated - private Resource2(String type) { - this.type = type; - } - - /** - * Get the id property: The id property. - * - * @return the id value. - */ - @Generated - public String getId() { - return this.id; - } - - /** - * Get the name property: The name property. - * - * @return the name value. - */ - @Generated - public String getName() { - return this.name; - } - - /** - * Get the type property: The type property. - * - * @return the type value. - */ - @Generated - public String getType() { - return this.type; - } - - /** - * {@inheritDoc} - */ - @Generated - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("type", this.type); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Resource2 from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Resource2 if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the Resource2. - */ - @Generated - public static Resource2 fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - String name = null; - String type = null; - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("name".equals(fieldName)) { - name = reader.getString(); - } else if ("type".equals(fieldName)) { - type = reader.getString(); - } else { - reader.skipChildren(); - } - } - Resource2 deserializedResource2 = new Resource2(type); - deserializedResource2.id = id; - deserializedResource2.name = name; - - return deserializedResource2; - }); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/package-info.java deleted file mode 100644 index 61f99c6514b..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/models/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -/** - * - * Package containing the data models for MultipleApiVersion. - * - */ -package tsptest.multipleapiversion.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/package-info.java deleted file mode 100644 index 72648ba3f35..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/multipleapiversion/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -/** - * - * Package containing the classes for MultipleApiVersion. - * - */ -package tsptest.multipleapiversion; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/ContosoServiceVersion.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/ContosoServiceVersion.java deleted file mode 100644 index 8e4ca4c4680..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/ContosoServiceVersion.java +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server; - -import com.azure.core.util.ServiceVersion; - -/** - * Service version of ContosoClient. - */ -public enum ContosoServiceVersion implements ServiceVersion { - /** - * Enum value v1. - */ - V1("v1"); - - private final String version; - - ContosoServiceVersion(String version) { - this.version = version; - } - - /** - * {@inheritDoc} - */ - @Override - public String getVersion() { - return this.version; - } - - /** - * Gets the latest service version supported by this client library. - * - * @return The latest {@link ContosoServiceVersion}. - */ - public static ContosoServiceVersion getLatest() { - return V1; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinAsyncClient.java deleted file mode 100644 index 18fd7b26638..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinAsyncClient.java +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.FluxUtil; -import reactor.core.publisher.Mono; -import tsptest.server.implementation.HttpbinClientImpl; - -/** - * Initializes a new instance of the asynchronous HttpbinClient type. - */ -@ServiceClient(builder = HttpbinClientBuilder.class, isAsync = true) -public final class HttpbinAsyncClient { - @Generated - private final HttpbinClientImpl serviceClient; - - /** - * Initializes an instance of HttpbinAsyncClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - HttpbinAsyncClient(HttpbinClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The status operation. - * - * @param code The code parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> statusWithResponse(int code, RequestOptions requestOptions) { - return this.serviceClient.statusWithResponseAsync(code, requestOptions); - } - - /** - * The status operation. - * - * @param code The code parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono status(int code) { - // Generated convenience method for statusWithResponse - RequestOptions requestOptions = new RequestOptions(); - return statusWithResponse(code, requestOptions).flatMap(FluxUtil::toMono); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinClient.java deleted file mode 100644 index 6aecfadf0a1..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinClient.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import tsptest.server.implementation.HttpbinClientImpl; - -/** - * Initializes a new instance of the synchronous HttpbinClient type. - */ -@ServiceClient(builder = HttpbinClientBuilder.class) -public final class HttpbinClient { - @Generated - private final HttpbinClientImpl serviceClient; - - /** - * Initializes an instance of HttpbinClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - HttpbinClient(HttpbinClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The status operation. - * - * @param code The code parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response statusWithResponse(int code, RequestOptions requestOptions) { - return this.serviceClient.statusWithResponse(code, requestOptions); - } - - /** - * The status operation. - * - * @param code The code parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void status(int code) { - // Generated convenience method for statusWithResponse - RequestOptions requestOptions = new RequestOptions(); - statusWithResponse(code, requestOptions).getValue(); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinClientBuilder.java deleted file mode 100644 index efed384dca8..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/HttpbinClientBuilder.java +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.policy.AddDatePolicy; -import com.azure.core.http.policy.AddHeadersFromContextPolicy; -import com.azure.core.http.policy.AddHeadersPolicy; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.HttpLoggingPolicy; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.policy.HttpPolicyProviders; -import com.azure.core.http.policy.RequestIdPolicy; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.http.policy.RetryPolicy; -import com.azure.core.http.policy.UserAgentPolicy; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.builder.ClientBuilderUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.serializer.JacksonAdapter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import tsptest.server.implementation.HttpbinClientImpl; - -/** - * A builder for creating a new instance of the HttpbinClient type. - */ -@ServiceClientBuilder(serviceClients = { HttpbinClient.class, HttpbinAsyncClient.class }) -public final class HttpbinClientBuilder - implements HttpTrait, ConfigurationTrait { - @Generated - private static final String SDK_NAME = "name"; - - @Generated - private static final String SDK_VERSION = "version"; - - @Generated - private static final Map PROPERTIES = CoreUtils.getProperties("tsptest-server.properties"); - - @Generated - private final List pipelinePolicies; - - /** - * Create an instance of the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder() { - this.pipelinePolicies = new ArrayList<>(); - } - - /* - * The HTTP client used to send the request. - */ - @Generated - private HttpClient httpClient; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /* - * The HTTP pipeline to send requests through. - */ - @Generated - private HttpPipeline pipeline; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder pipeline(HttpPipeline pipeline) { - if (this.pipeline != null && pipeline == null) { - LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); - } - this.pipeline = pipeline; - return this; - } - - /* - * The logging configuration for HTTP requests and responses. - */ - @Generated - private HttpLogOptions httpLogOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { - this.httpLogOptions = httpLogOptions; - return this; - } - - /* - * The client options such as application ID and custom headers to set on a request. - */ - @Generated - private ClientOptions clientOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - return this; - } - - /* - * The retry options to configure retry policy for failed requests. - */ - @Generated - private RetryOptions retryOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder retryOptions(RetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { - Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); - pipelinePolicies.add(customPolicy); - return this; - } - - /* - * The configuration store that is used during construction of the service client. - */ - @Generated - private Configuration configuration; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public HttpbinClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /* - * second-level domain, use httpbin - */ - @Generated - private String domain; - - /** - * Sets second-level domain, use httpbin. - * - * @param domain the domain value. - * @return the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder domain(String domain) { - this.domain = domain; - return this; - } - - /* - * top-level domain, use org - */ - @Generated - private String tld; - - /** - * Sets top-level domain, use org. - * - * @param tld the tld value. - * @return the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder tld(String tld) { - this.tld = tld; - return this; - } - - /* - * relative path segment, can be empty - */ - @Generated - private String relativePath; - - /** - * Sets relative path segment, can be empty. - * - * @param relativePath the relativePath value. - * @return the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder relativePath(String relativePath) { - this.relativePath = relativePath; - return this; - } - - /* - * The retry policy that will attempt to retry failed requests, if applicable. - */ - @Generated - private RetryPolicy retryPolicy; - - /** - * Sets The retry policy that will attempt to retry failed requests, if applicable. - * - * @param retryPolicy the retryPolicy value. - * @return the HttpbinClientBuilder. - */ - @Generated - public HttpbinClientBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - return this; - } - - /** - * Builds an instance of HttpbinClientImpl with the provided parameters. - * - * @return an instance of HttpbinClientImpl. - */ - @Generated - private HttpbinClientImpl buildInnerClient() { - this.validateClient(); - HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - String localDomain = (domain != null) ? domain : "httpbin"; - String localTld = (tld != null) ? tld : "org"; - HttpbinClientImpl client = new HttpbinClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), - localDomain, localTld, this.relativePath); - return client; - } - - @Generated - private void validateClient() { - // This method is invoked from 'buildInnerClient'/'buildClient' method. - // Developer can customize this method, to validate that the necessary conditions are met for the new client. - Objects.requireNonNull(relativePath, "'relativePath' cannot be null."); - } - - @Generated - private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration - = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; - ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; - List policies = new ArrayList<>(); - String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); - policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); - policies.add(new RequestIdPolicy()); - policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); - if (headers != null) { - policies.add(new AddHeadersPolicy(headers)); - } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); - policies.add(new AddDatePolicy()); - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(localHttpLogOptions)); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); - return httpPipeline; - } - - /** - * Builds an instance of HttpbinAsyncClient class. - * - * @return an instance of HttpbinAsyncClient. - */ - @Generated - public HttpbinAsyncClient buildAsyncClient() { - return new HttpbinAsyncClient(buildInnerClient()); - } - - /** - * Builds an instance of HttpbinClient class. - * - * @return an instance of HttpbinClient. - */ - @Generated - public HttpbinClient buildClient() { - return new HttpbinClient(buildInnerClient()); - } - - private static final ClientLogger LOGGER = new ClientLogger(HttpbinClientBuilder.class); -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/models/APIVersions.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/models/APIVersions.java deleted file mode 100644 index bbd8442bca2..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/models/APIVersions.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.contoso.models; - -/** - * Defines values for APIVersions. - */ -public enum APIVersions { - /** - * Enum value v1. - */ - V1("v1"); - - /** - * The actual serialized value for a APIVersions instance. - */ - private final String value; - - APIVersions(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a APIVersions instance. - * - * @param value the serialized value to parse. - * @return the parsed APIVersions object, or null if unable to parse. - */ - public static APIVersions fromString(String value) { - if (value == null) { - return null; - } - APIVersions[] items = APIVersions.values(); - for (APIVersions item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return this.value; - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/models/package-info.java deleted file mode 100644 index 94d43028ddd..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/models/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -/** - * - * Package containing the data models for Server. - * - */ -package tsptest.server.contoso.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoAsyncClient.java deleted file mode 100644 index 58149c987b9..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoAsyncClient.java +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.contoso.sub; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.FluxUtil; -import reactor.core.publisher.Mono; -import tsptest.server.implementation.ContosoClientImpl; - -/** - * Initializes a new instance of the asynchronous ContosoClient type. - */ -@ServiceClient(builder = ContosoClientBuilder.class, isAsync = true) -public final class ContosoAsyncClient { - @Generated - private final ContosoClientImpl serviceClient; - - /** - * Initializes an instance of ContosoAsyncClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - ContosoAsyncClient(ContosoClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The get operation. - * - * @param group The group parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponse(String group, RequestOptions requestOptions) { - return this.serviceClient.getWithResponseAsync(group, requestOptions); - } - - /** - * The get operation. - * - * @param group The group parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono get(String group) { - // Generated convenience method for getWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getWithResponse(group, requestOptions).flatMap(FluxUtil::toMono); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoClient.java deleted file mode 100644 index aa786d3070e..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoClient.java +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.contoso.sub; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import tsptest.server.implementation.ContosoClientImpl; - -/** - * Initializes a new instance of the synchronous ContosoClient type. - */ -@ServiceClient(builder = ContosoClientBuilder.class) -public final class ContosoClient { - @Generated - private final ContosoClientImpl serviceClient; - - /** - * Initializes an instance of ContosoClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - ContosoClient(ContosoClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * The get operation. - * - * @param group The group parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String group, RequestOptions requestOptions) { - return this.serviceClient.getWithResponse(group, requestOptions); - } - - /** - * The get operation. - * - * @param group The group parameter. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void get(String group) { - // Generated convenience method for getWithResponse - RequestOptions requestOptions = new RequestOptions(); - getWithResponse(group, requestOptions).getValue(); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoClientBuilder.java deleted file mode 100644 index 3fed7c357c9..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/ContosoClientBuilder.java +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.contoso.sub; - -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.ConfigurationTrait; -import com.azure.core.client.traits.EndpointTrait; -import com.azure.core.client.traits.HttpTrait; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.policy.AddDatePolicy; -import com.azure.core.http.policy.AddHeadersFromContextPolicy; -import com.azure.core.http.policy.AddHeadersPolicy; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.HttpLoggingPolicy; -import com.azure.core.http.policy.HttpPipelinePolicy; -import com.azure.core.http.policy.HttpPolicyProviders; -import com.azure.core.http.policy.RequestIdPolicy; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.http.policy.RetryPolicy; -import com.azure.core.http.policy.UserAgentPolicy; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.builder.ClientBuilderUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.serializer.JacksonAdapter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import tsptest.server.ContosoServiceVersion; -import tsptest.server.contoso.models.APIVersions; -import tsptest.server.implementation.ContosoClientImpl; - -/** - * A builder for creating a new instance of the ContosoClient type. - */ -@ServiceClientBuilder(serviceClients = { ContosoClient.class, ContosoAsyncClient.class }) -public final class ContosoClientBuilder implements HttpTrait, - ConfigurationTrait, EndpointTrait { - @Generated - private static final String SDK_NAME = "name"; - - @Generated - private static final String SDK_VERSION = "version"; - - @Generated - private static final Map PROPERTIES = CoreUtils.getProperties("tsptest-server.properties"); - - @Generated - private final List pipelinePolicies; - - /** - * Create an instance of the ContosoClientBuilder. - */ - @Generated - public ContosoClientBuilder() { - this.pipelinePolicies = new ArrayList<>(); - } - - /* - * The HTTP client used to send the request. - */ - @Generated - private HttpClient httpClient; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /* - * The HTTP pipeline to send requests through. - */ - @Generated - private HttpPipeline pipeline; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder pipeline(HttpPipeline pipeline) { - if (this.pipeline != null && pipeline == null) { - LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); - } - this.pipeline = pipeline; - return this; - } - - /* - * The logging configuration for HTTP requests and responses. - */ - @Generated - private HttpLogOptions httpLogOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { - this.httpLogOptions = httpLogOptions; - return this; - } - - /* - * The client options such as application ID and custom headers to set on a request. - */ - @Generated - private ClientOptions clientOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - return this; - } - - /* - * The retry options to configure retry policy for failed requests. - */ - @Generated - private RetryOptions retryOptions; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder retryOptions(RetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { - Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); - pipelinePolicies.add(customPolicy); - return this; - } - - /* - * The configuration store that is used during construction of the service client. - */ - @Generated - private Configuration configuration; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - return this; - } - - /* - * The service endpoint - */ - @Generated - private String endpoint; - - /** - * {@inheritDoc}. - */ - @Generated - @Override - public ContosoClientBuilder endpoint(String endpoint) { - this.endpoint = endpoint; - return this; - } - - /* - * Api Version - */ - @Generated - private APIVersions apiVersion; - - /** - * Sets Api Version. - * - * @param apiVersion the apiVersion value. - * @return the ContosoClientBuilder. - */ - @Generated - public ContosoClientBuilder apiVersion(APIVersions apiVersion) { - this.apiVersion = apiVersion; - return this; - } - - /* - * Service version - */ - @Generated - private ContosoServiceVersion serviceVersion; - - /** - * Sets Service version. - * - * @param serviceVersion the serviceVersion value. - * @return the ContosoClientBuilder. - */ - @Generated - public ContosoClientBuilder serviceVersion(ContosoServiceVersion serviceVersion) { - this.serviceVersion = serviceVersion; - return this; - } - - /* - * The retry policy that will attempt to retry failed requests, if applicable. - */ - @Generated - private RetryPolicy retryPolicy; - - /** - * Sets The retry policy that will attempt to retry failed requests, if applicable. - * - * @param retryPolicy the retryPolicy value. - * @return the ContosoClientBuilder. - */ - @Generated - public ContosoClientBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - return this; - } - - /** - * Builds an instance of ContosoClientImpl with the provided parameters. - * - * @return an instance of ContosoClientImpl. - */ - @Generated - private ContosoClientImpl buildInnerClient() { - this.validateClient(); - HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - ContosoServiceVersion localServiceVersion - = (serviceVersion != null) ? serviceVersion : ContosoServiceVersion.getLatest(); - ContosoClientImpl client = new ContosoClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), - this.endpoint, this.apiVersion, localServiceVersion); - return client; - } - - @Generated - private void validateClient() { - // This method is invoked from 'buildInnerClient'/'buildClient' method. - // Developer can customize this method, to validate that the necessary conditions are met for the new client. - Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); - Objects.requireNonNull(apiVersion, "'apiVersion' cannot be null."); - } - - @Generated - private HttpPipeline createHttpPipeline() { - Configuration buildConfiguration - = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; - HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; - ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; - List policies = new ArrayList<>(); - String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); - String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); - String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); - policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); - policies.add(new RequestIdPolicy()); - policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); - if (headers != null) { - policies.add(new AddHeadersPolicy(headers)); - } - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); - policies.add(new AddDatePolicy()); - this.pipelinePolicies.stream() - .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) - .forEach(p -> policies.add(p)); - HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(localHttpLogOptions)); - HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .clientOptions(localClientOptions) - .build(); - return httpPipeline; - } - - /** - * Builds an instance of ContosoAsyncClient class. - * - * @return an instance of ContosoAsyncClient. - */ - @Generated - public ContosoAsyncClient buildAsyncClient() { - return new ContosoAsyncClient(buildInnerClient()); - } - - /** - * Builds an instance of ContosoClient class. - * - * @return an instance of ContosoClient. - */ - @Generated - public ContosoClient buildClient() { - return new ContosoClient(buildInnerClient()); - } - - private static final ClientLogger LOGGER = new ClientLogger(ContosoClientBuilder.class); -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/package-info.java deleted file mode 100644 index 584771a66f7..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/contoso/sub/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -/** - * - * Package containing the classes for ContosoClient. - * - */ -package tsptest.server.contoso.sub; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/ContosoClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/ContosoClientImpl.java deleted file mode 100644 index 9048cb1193d..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/ContosoClientImpl.java +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.implementation; - -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; -import com.azure.core.annotation.Host; -import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.PathParam; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceInterface; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.annotation.UnexpectedResponseExceptionType; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.policy.RetryPolicy; -import com.azure.core.http.policy.UserAgentPolicy; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; -import reactor.core.publisher.Mono; -import tsptest.server.ContosoServiceVersion; -import tsptest.server.contoso.models.APIVersions; - -/** - * Initializes a new instance of the ContosoClient type. - */ -public final class ContosoClientImpl { - /** - * The proxy service used to perform REST calls. - */ - private final ContosoClientService service; - - /** - * Service endpoint. - */ - private final String endpoint; - - /** - * Gets Service endpoint. - * - * @return the endpoint value. - */ - public String getEndpoint() { - return this.endpoint; - } - - /** - * Api Version. - */ - private final APIVersions apiVersion; - - /** - * Gets Api Version. - * - * @return the apiVersion value. - */ - public APIVersions getApiVersion() { - return this.apiVersion; - } - - /** - * Service version. - */ - private final ContosoServiceVersion serviceVersion; - - /** - * Gets Service version. - * - * @return the serviceVersion value. - */ - public ContosoServiceVersion getServiceVersion() { - return this.serviceVersion; - } - - /** - * The HTTP pipeline to send requests through. - */ - private final HttpPipeline httpPipeline; - - /** - * Gets The HTTP pipeline to send requests through. - * - * @return the httpPipeline value. - */ - public HttpPipeline getHttpPipeline() { - return this.httpPipeline; - } - - /** - * The serializer to serialize an object into a string. - */ - private final SerializerAdapter serializerAdapter; - - /** - * Gets The serializer to serialize an object into a string. - * - * @return the serializerAdapter value. - */ - public SerializerAdapter getSerializerAdapter() { - return this.serializerAdapter; - } - - /** - * Initializes an instance of ContosoClient client. - * - * @param endpoint Service endpoint. - * @param apiVersion Api Version. - * @param serviceVersion Service version. - */ - public ContosoClientImpl(String endpoint, APIVersions apiVersion, ContosoServiceVersion serviceVersion) { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), endpoint, apiVersion, serviceVersion); - } - - /** - * Initializes an instance of ContosoClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param endpoint Service endpoint. - * @param apiVersion Api Version. - * @param serviceVersion Service version. - */ - public ContosoClientImpl(HttpPipeline httpPipeline, String endpoint, APIVersions apiVersion, - ContosoServiceVersion serviceVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, apiVersion, serviceVersion); - } - - /** - * Initializes an instance of ContosoClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param serializerAdapter The serializer to serialize an object into a string. - * @param endpoint Service endpoint. - * @param apiVersion Api Version. - * @param serviceVersion Service version. - */ - public ContosoClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, - APIVersions apiVersion, ContosoServiceVersion serviceVersion) { - this.httpPipeline = httpPipeline; - this.serializerAdapter = serializerAdapter; - this.endpoint = endpoint; - this.apiVersion = apiVersion; - this.serviceVersion = serviceVersion; - this.service = RestProxy.create(ContosoClientService.class, this.httpPipeline, this.getSerializerAdapter()); - } - - /** - * The interface defining all the services for ContosoClient to be used by the proxy service to perform REST calls. - */ - @Host("{Endpoint}/contoso/{ApiVersion}") - @ServiceInterface(name = "ContosoClient") - public interface ContosoClientService { - @Get("/contoso/{group}") - @ExpectedResponses({ 200, 204 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> get(@HostParam("Endpoint") String endpoint, - @HostParam("ApiVersion") APIVersions apiVersion, @PathParam(value = "group", encoded = true) String group, - RequestOptions requestOptions, Context context); - - @Get("/contoso/{group}") - @ExpectedResponses({ 200, 204 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getSync(@HostParam("Endpoint") String endpoint, @HostParam("ApiVersion") APIVersions apiVersion, - @PathParam(value = "group", encoded = true) String group, RequestOptions requestOptions, Context context); - } - - /** - * The get operation. - * - * @param group The group parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getWithResponseAsync(String group, RequestOptions requestOptions) { - return FluxUtil.withContext( - context -> service.get(this.getEndpoint(), this.getApiVersion(), group, requestOptions, context)); - } - - /** - * The get operation. - * - * @param group The group parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getWithResponse(String group, RequestOptions requestOptions) { - return service.getSync(this.getEndpoint(), this.getApiVersion(), group, requestOptions, Context.NONE); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/HttpbinClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/HttpbinClientImpl.java deleted file mode 100644 index e183ec6ac5f..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/HttpbinClientImpl.java +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.implementation; - -import com.azure.core.annotation.ExpectedResponses; -import com.azure.core.annotation.Get; -import com.azure.core.annotation.Host; -import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.PathParam; -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceInterface; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.annotation.UnexpectedResponseExceptionType; -import com.azure.core.exception.ClientAuthenticationException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.policy.RetryPolicy; -import com.azure.core.http.policy.UserAgentPolicy; -import com.azure.core.http.rest.RequestOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; -import reactor.core.publisher.Mono; - -/** - * Initializes a new instance of the HttpbinClient type. - */ -public final class HttpbinClientImpl { - /** - * The proxy service used to perform REST calls. - */ - private final HttpbinClientService service; - - /** - * second-level domain, use httpbin. - */ - private final String domain; - - /** - * Gets second-level domain, use httpbin. - * - * @return the domain value. - */ - public String getDomain() { - return this.domain; - } - - /** - * top-level domain, use org. - */ - private final String tld; - - /** - * Gets top-level domain, use org. - * - * @return the tld value. - */ - public String getTld() { - return this.tld; - } - - /** - * relative path segment, can be empty. - */ - private final String relativePath; - - /** - * Gets relative path segment, can be empty. - * - * @return the relativePath value. - */ - public String getRelativePath() { - return this.relativePath; - } - - /** - * The HTTP pipeline to send requests through. - */ - private final HttpPipeline httpPipeline; - - /** - * Gets The HTTP pipeline to send requests through. - * - * @return the httpPipeline value. - */ - public HttpPipeline getHttpPipeline() { - return this.httpPipeline; - } - - /** - * The serializer to serialize an object into a string. - */ - private final SerializerAdapter serializerAdapter; - - /** - * Gets The serializer to serialize an object into a string. - * - * @return the serializerAdapter value. - */ - public SerializerAdapter getSerializerAdapter() { - return this.serializerAdapter; - } - - /** - * Initializes an instance of HttpbinClient client. - * - * @param domain second-level domain, use httpbin. - * @param tld top-level domain, use org. - * @param relativePath relative path segment, can be empty. - */ - public HttpbinClientImpl(String domain, String tld, String relativePath) { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), domain, tld, relativePath); - } - - /** - * Initializes an instance of HttpbinClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param domain second-level domain, use httpbin. - * @param tld top-level domain, use org. - * @param relativePath relative path segment, can be empty. - */ - public HttpbinClientImpl(HttpPipeline httpPipeline, String domain, String tld, String relativePath) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), domain, tld, relativePath); - } - - /** - * Initializes an instance of HttpbinClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param serializerAdapter The serializer to serialize an object into a string. - * @param domain second-level domain, use httpbin. - * @param tld top-level domain, use org. - * @param relativePath relative path segment, can be empty. - */ - public HttpbinClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String domain, String tld, - String relativePath) { - this.httpPipeline = httpPipeline; - this.serializerAdapter = serializerAdapter; - this.domain = domain; - this.tld = tld; - this.relativePath = relativePath; - this.service = RestProxy.create(HttpbinClientService.class, this.httpPipeline, this.getSerializerAdapter()); - } - - /** - * The interface defining all the services for HttpbinClient to be used by the proxy service to perform REST calls. - */ - @Host("https://{domain}.{tld}{relative-path}") - @ServiceInterface(name = "HttpbinClient") - public interface HttpbinClientService { - @Get("/status/{code}") - @ExpectedResponses({ 200, 204 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> status(@HostParam("domain") String domain, @HostParam("tld") String tld, - @HostParam("relative-path") String relativePath, @PathParam("code") int code, RequestOptions requestOptions, - Context context); - - @Get("/status/{code}") - @ExpectedResponses({ 200, 204 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response statusSync(@HostParam("domain") String domain, @HostParam("tld") String tld, - @HostParam("relative-path") String relativePath, @PathParam("code") int code, RequestOptions requestOptions, - Context context); - } - - /** - * The status operation. - * - * @param code The code parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> statusWithResponseAsync(int code, RequestOptions requestOptions) { - return FluxUtil.withContext(context -> service.status(this.getDomain(), this.getTld(), this.getRelativePath(), - code, requestOptions, context)); - } - - /** - * The status operation. - * - * @param code The code parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response statusWithResponse(int code, RequestOptions requestOptions) { - return service.statusSync(this.getDomain(), this.getTld(), this.getRelativePath(), code, requestOptions, - Context.NONE); - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/package-info.java deleted file mode 100644 index eb40ad22584..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/implementation/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -/** - * - * Package containing the implementations for Server. - * - */ -package tsptest.server.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/package-info.java deleted file mode 100644 index 5e0b067c32d..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/server/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -/** - * - * Package containing the classes for Server. - * - */ -package tsptest.server; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-multipleapiversion_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-multipleapiversion_apiview_properties.json deleted file mode 100644 index 3a1c3c27f68..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-multipleapiversion_apiview_properties.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "flavor": "Azure", - "CrossLanguageDefinitionId": { - "tsptest.multipleapiversion.FirstAsyncClient": "TspTest.MultipleApiVersion", - "tsptest.multipleapiversion.FirstAsyncClient.get": "TspTest.MultipleApiVersion.Client.get", - "tsptest.multipleapiversion.FirstAsyncClient.getWithResponse": "TspTest.MultipleApiVersion.Client.get", - "tsptest.multipleapiversion.FirstClient": "TspTest.MultipleApiVersion", - "tsptest.multipleapiversion.FirstClient.get": "TspTest.MultipleApiVersion.Client.get", - "tsptest.multipleapiversion.FirstClient.getWithResponse": "TspTest.MultipleApiVersion.Client.get", - "tsptest.multipleapiversion.FirstClientBuilder": "TspTest.MultipleApiVersion", - "tsptest.multipleapiversion.NoApiVersionAsyncClient": "TspTest.MultipleApiVersion3", - "tsptest.multipleapiversion.NoApiVersionAsyncClient.action": "TspTest.MultipleApiVersion3.Client.action", - "tsptest.multipleapiversion.NoApiVersionAsyncClient.actionWithResponse": "TspTest.MultipleApiVersion3.Client.action", - "tsptest.multipleapiversion.NoApiVersionClient": "TspTest.MultipleApiVersion3", - "tsptest.multipleapiversion.NoApiVersionClient.action": "TspTest.MultipleApiVersion3.Client.action", - "tsptest.multipleapiversion.NoApiVersionClient.actionWithResponse": "TspTest.MultipleApiVersion3.Client.action", - "tsptest.multipleapiversion.NoApiVersionClientBuilder": "TspTest.MultipleApiVersion3", - "tsptest.multipleapiversion.SecondAsyncClient": "TspTest.MultipleApiVersion2", - "tsptest.multipleapiversion.SecondAsyncClient.get": "TspTest.MultipleApiVersion2.Client.get", - "tsptest.multipleapiversion.SecondAsyncClient.getWithResponse": "TspTest.MultipleApiVersion2.Client.get", - "tsptest.multipleapiversion.SecondClient": "TspTest.MultipleApiVersion2", - "tsptest.multipleapiversion.SecondClient.get": "TspTest.MultipleApiVersion2.Client.get", - "tsptest.multipleapiversion.SecondClient.getWithResponse": "TspTest.MultipleApiVersion2.Client.get", - "tsptest.multipleapiversion.SecondClientBuilder": "TspTest.MultipleApiVersion2", - "tsptest.multipleapiversion.models.Resource": "TspTest.MultipleApiVersion.Resource", - "tsptest.multipleapiversion.models.Resource2": "TspTest.MultipleApiVersion2.Resource2" - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-multipleapiversion_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-multipleapiversion_metadata.json deleted file mode 100644 index bf054c4f23c..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-multipleapiversion_metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"flavor":"Azure","apiVersion":"2022-12-01-preview","crossLanguageDefinitions":{"tsptest.multipleapiversion.FirstAsyncClient":"TspTest.MultipleApiVersion","tsptest.multipleapiversion.FirstAsyncClient.get":"TspTest.MultipleApiVersion.Client.get","tsptest.multipleapiversion.FirstAsyncClient.getWithResponse":"TspTest.MultipleApiVersion.Client.get","tsptest.multipleapiversion.FirstClient":"TspTest.MultipleApiVersion","tsptest.multipleapiversion.FirstClient.get":"TspTest.MultipleApiVersion.Client.get","tsptest.multipleapiversion.FirstClient.getWithResponse":"TspTest.MultipleApiVersion.Client.get","tsptest.multipleapiversion.FirstClientBuilder":"TspTest.MultipleApiVersion","tsptest.multipleapiversion.NoApiVersionAsyncClient":"TspTest.MultipleApiVersion3","tsptest.multipleapiversion.NoApiVersionAsyncClient.action":"TspTest.MultipleApiVersion3.Client.action","tsptest.multipleapiversion.NoApiVersionAsyncClient.actionWithResponse":"TspTest.MultipleApiVersion3.Client.action","tsptest.multipleapiversion.NoApiVersionClient":"TspTest.MultipleApiVersion3","tsptest.multipleapiversion.NoApiVersionClient.action":"TspTest.MultipleApiVersion3.Client.action","tsptest.multipleapiversion.NoApiVersionClient.actionWithResponse":"TspTest.MultipleApiVersion3.Client.action","tsptest.multipleapiversion.NoApiVersionClientBuilder":"TspTest.MultipleApiVersion3","tsptest.multipleapiversion.SecondAsyncClient":"TspTest.MultipleApiVersion2","tsptest.multipleapiversion.SecondAsyncClient.get":"TspTest.MultipleApiVersion2.Client.get","tsptest.multipleapiversion.SecondAsyncClient.getWithResponse":"TspTest.MultipleApiVersion2.Client.get","tsptest.multipleapiversion.SecondClient":"TspTest.MultipleApiVersion2","tsptest.multipleapiversion.SecondClient.get":"TspTest.MultipleApiVersion2.Client.get","tsptest.multipleapiversion.SecondClient.getWithResponse":"TspTest.MultipleApiVersion2.Client.get","tsptest.multipleapiversion.SecondClientBuilder":"TspTest.MultipleApiVersion2","tsptest.multipleapiversion.models.Resource":"TspTest.MultipleApiVersion.Resource","tsptest.multipleapiversion.models.Resource2":"TspTest.MultipleApiVersion2.Resource2"},"generatedFiles":["src/main/java/module-info.java","src/main/java/tsptest/multipleapiversion/FirstAsyncClient.java","src/main/java/tsptest/multipleapiversion/FirstClient.java","src/main/java/tsptest/multipleapiversion/FirstClientBuilder.java","src/main/java/tsptest/multipleapiversion/FirstServiceVersion.java","src/main/java/tsptest/multipleapiversion/NoApiVersionAsyncClient.java","src/main/java/tsptest/multipleapiversion/NoApiVersionClient.java","src/main/java/tsptest/multipleapiversion/NoApiVersionClientBuilder.java","src/main/java/tsptest/multipleapiversion/NoApiVersionServiceVersion.java","src/main/java/tsptest/multipleapiversion/SecondAsyncClient.java","src/main/java/tsptest/multipleapiversion/SecondClient.java","src/main/java/tsptest/multipleapiversion/SecondClientBuilder.java","src/main/java/tsptest/multipleapiversion/SecondServiceVersion.java","src/main/java/tsptest/multipleapiversion/implementation/FirstClientImpl.java","src/main/java/tsptest/multipleapiversion/implementation/NoApiVersionClientImpl.java","src/main/java/tsptest/multipleapiversion/implementation/SecondClientImpl.java","src/main/java/tsptest/multipleapiversion/implementation/package-info.java","src/main/java/tsptest/multipleapiversion/models/Resource.java","src/main/java/tsptest/multipleapiversion/models/Resource2.java","src/main/java/tsptest/multipleapiversion/models/package-info.java","src/main/java/tsptest/multipleapiversion/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-server_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-server_apiview_properties.json deleted file mode 100644 index f94e4c2f2cc..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-server_apiview_properties.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "flavor": "Azure", - "CrossLanguageDefinitionId": { - "tsptest.server.HttpbinAsyncClient": "TspTest.Server.ServerOp", - "tsptest.server.HttpbinAsyncClient.status": "TspTest.Server.ServerOp.status", - "tsptest.server.HttpbinAsyncClient.statusWithResponse": "TspTest.Server.ServerOp.status", - "tsptest.server.HttpbinClient": "TspTest.Server.ServerOp", - "tsptest.server.HttpbinClient.status": "TspTest.Server.ServerOp.status", - "tsptest.server.HttpbinClient.statusWithResponse": "TspTest.Server.ServerOp.status", - "tsptest.server.HttpbinClientBuilder": "TspTest.Server.ServerOp", - "tsptest.server.contoso.models.APIVersions": "TspTest.ContosoServer.APIVersions", - "tsptest.server.contoso.sub.ContosoAsyncClient": "TspTest.ContosoServer.ServerOp", - "tsptest.server.contoso.sub.ContosoAsyncClient.get": "TspTest.ContosoServer.ServerOp.get", - "tsptest.server.contoso.sub.ContosoAsyncClient.getWithResponse": "TspTest.ContosoServer.ServerOp.get", - "tsptest.server.contoso.sub.ContosoClient": "TspTest.ContosoServer.ServerOp", - "tsptest.server.contoso.sub.ContosoClient.get": "TspTest.ContosoServer.ServerOp.get", - "tsptest.server.contoso.sub.ContosoClient.getWithResponse": "TspTest.ContosoServer.ServerOp.get", - "tsptest.server.contoso.sub.ContosoClientBuilder": "TspTest.ContosoServer.ServerOp" - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-server_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-server_metadata.json deleted file mode 100644 index f9e6f46a8b2..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-server_metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"flavor":"Azure","crossLanguageDefinitions":{"tsptest.server.HttpbinAsyncClient":"TspTest.Server.ServerOp","tsptest.server.HttpbinAsyncClient.status":"TspTest.Server.ServerOp.status","tsptest.server.HttpbinAsyncClient.statusWithResponse":"TspTest.Server.ServerOp.status","tsptest.server.HttpbinClient":"TspTest.Server.ServerOp","tsptest.server.HttpbinClient.status":"TspTest.Server.ServerOp.status","tsptest.server.HttpbinClient.statusWithResponse":"TspTest.Server.ServerOp.status","tsptest.server.HttpbinClientBuilder":"TspTest.Server.ServerOp","tsptest.server.contoso.models.APIVersions":"TspTest.ContosoServer.APIVersions","tsptest.server.contoso.sub.ContosoAsyncClient":"TspTest.ContosoServer.ServerOp","tsptest.server.contoso.sub.ContosoAsyncClient.get":"TspTest.ContosoServer.ServerOp.get","tsptest.server.contoso.sub.ContosoAsyncClient.getWithResponse":"TspTest.ContosoServer.ServerOp.get","tsptest.server.contoso.sub.ContosoClient":"TspTest.ContosoServer.ServerOp","tsptest.server.contoso.sub.ContosoClient.get":"TspTest.ContosoServer.ServerOp.get","tsptest.server.contoso.sub.ContosoClient.getWithResponse":"TspTest.ContosoServer.ServerOp.get","tsptest.server.contoso.sub.ContosoClientBuilder":"TspTest.ContosoServer.ServerOp"},"generatedFiles":["src/main/java/module-info.java","src/main/java/tsptest/server/ContosoServiceVersion.java","src/main/java/tsptest/server/HttpbinAsyncClient.java","src/main/java/tsptest/server/HttpbinClient.java","src/main/java/tsptest/server/HttpbinClientBuilder.java","src/main/java/tsptest/server/contoso/models/APIVersions.java","src/main/java/tsptest/server/contoso/models/package-info.java","src/main/java/tsptest/server/contoso/sub/ContosoAsyncClient.java","src/main/java/tsptest/server/contoso/sub/ContosoClient.java","src/main/java/tsptest/server/contoso/sub/ContosoClientBuilder.java","src/main/java/tsptest/server/contoso/sub/package-info.java","src/main/java/tsptest/server/implementation/ContosoClientImpl.java","src/main/java/tsptest/server/implementation/HttpbinClientImpl.java","src/main/java/tsptest/server/implementation/package-info.java","src/main/java/tsptest/server/package-info.java"]} \ No newline at end of file diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/tsptest-multipleapiversion.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/tsptest-multipleapiversion.properties deleted file mode 100644 index ca812989b4f..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/tsptest-multipleapiversion.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/tsptest-server.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/tsptest-server.properties deleted file mode 100644 index ca812989b4f..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/tsptest-server.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/multipleapiversion/generated/FirstClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/multipleapiversion/generated/FirstClientTestBase.java deleted file mode 100644 index f95717e79ad..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/multipleapiversion/generated/FirstClientTestBase.java +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.multipleapiversion.generated; - -// The Java test files under 'generated' package are generated for your reference. -// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. -// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. - -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.test.TestMode; -import com.azure.core.test.TestProxyTestBase; -import com.azure.core.util.Configuration; -import tsptest.multipleapiversion.FirstClient; -import tsptest.multipleapiversion.FirstClientBuilder; -import tsptest.multipleapiversion.NoApiVersionClient; -import tsptest.multipleapiversion.NoApiVersionClientBuilder; -import tsptest.multipleapiversion.SecondClient; -import tsptest.multipleapiversion.SecondClientBuilder; - -class FirstClientTestBase extends TestProxyTestBase { - protected FirstClient firstClient; - - protected SecondClient secondClient; - - protected NoApiVersionClient noApiVersionClient; - - @Override - protected void beforeTest() { - FirstClientBuilder firstClientbuilder - = new FirstClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - firstClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - firstClient = firstClientbuilder.buildClient(); - - SecondClientBuilder secondClientbuilder - = new SecondClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - secondClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - secondClient = secondClientbuilder.buildClient(); - - NoApiVersionClientBuilder noApiVersionClientbuilder = new NoApiVersionClientBuilder() - .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - noApiVersionClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - noApiVersionClient = noApiVersionClientbuilder.buildClient(); - - } -} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/server/generated/HttpbinClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/server/generated/HttpbinClientTestBase.java deleted file mode 100644 index f51d39cc4c4..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/server/generated/HttpbinClientTestBase.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package tsptest.server.generated; - -// The Java test files under 'generated' package are generated for your reference. -// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. -// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. - -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.test.TestMode; -import com.azure.core.test.TestProxyTestBase; -import com.azure.core.util.Configuration; -import tsptest.server.HttpbinClient; -import tsptest.server.HttpbinClientBuilder; -import tsptest.server.contoso.models.APIVersions; -import tsptest.server.contoso.sub.ContosoClient; -import tsptest.server.contoso.sub.ContosoClientBuilder; - -class HttpbinClientTestBase extends TestProxyTestBase { - protected HttpbinClient httpbinClient; - - protected ContosoClient contosoClient; - - @Override - protected void beforeTest() { - HttpbinClientBuilder httpbinClientbuilder - = new HttpbinClientBuilder().domain(Configuration.getGlobalConfiguration().get("DOMAIN", "httpbin")) - .tld(Configuration.getGlobalConfiguration().get("TLD", "org")) - .relativePath(Configuration.getGlobalConfiguration().get("RELATIVEPATH", "relativepath")) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - httpbinClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - httpbinClient = httpbinClientbuilder.buildClient(); - - ContosoClientBuilder contosoClientbuilder = new ContosoClientBuilder() - .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) - .apiVersion(APIVersions.fromString(Configuration.getGlobalConfiguration().get("APIVERSION", "apiversion"))) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - contosoClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - contosoClient = contosoClientbuilder.buildClient(); - - } -} From e38dfb0988661777a54f5a2b3da2cd8e50366559 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Sun, 4 Jan 2026 10:47:01 +0800 Subject: [PATCH 5/5] delete test --- .../test/java/tsptest/server/ServerTests.java | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/server/ServerTests.java diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/server/ServerTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/server/ServerTests.java deleted file mode 100644 index 4db130449b3..00000000000 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/server/ServerTests.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package tsptest.server; - -import com.azure.core.http.rest.RequestOptions; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -public class ServerTests { - - @Disabled("test calls httpbin.org") - @Test - public void serverTests() { - HttpbinClient client = new HttpbinClientBuilder().domain("httpbin").tld("org").buildClient(); - Assertions.assertEquals(204, client.statusWithResponse(204, new RequestOptions()).getStatusCode()); - } -}