diff --git a/core b/core index fe4c59011e..30be58d52e 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit fe4c59011ef95245c2bd5308e85b88f29d00926a +Subproject commit 30be58d52e2938c7096fc0266cb8eb65b8ee7cdb diff --git a/typespec-extension/changelog.md b/typespec-extension/changelog.md index 26730ae417..a46d152499 100644 --- a/typespec-extension/changelog.md +++ b/typespec-extension/changelog.md @@ -1,5 +1,11 @@ # Release History +## 0.39.2 (2026-02-11) + +Compatible with compiler 1.9.0. + +- Updated package dependencies to the latest versions. + ## 0.39.1 (2026-02-09) Compatible with compiler 1.8.0. diff --git a/typespec-extension/package-lock.json b/typespec-extension/package-lock.json index 160064d9fc..7b8add6762 100644 --- a/typespec-extension/package-lock.json +++ b/typespec-extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "@azure-tools/typespec-java", - "version": "0.39.1", + "version": "0.39.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@azure-tools/typespec-java", - "version": "0.39.1", + "version": "0.39.2", "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.1", @@ -14,29 +14,29 @@ "lodash": "~4.17.23" }, "devDependencies": { - "@azure-tools/openai-typespec": "^1.8.0", - "@azure-tools/typespec-autorest": "0.64.1", - "@azure-tools/typespec-azure-core": "0.64.0", - "@azure-tools/typespec-azure-resource-manager": "0.64.1", - "@azure-tools/typespec-azure-rulesets": "0.64.0", - "@azure-tools/typespec-client-generator-core": "0.64.6", + "@azure-tools/openai-typespec": "^1.9.0", + "@azure-tools/typespec-autorest": "0.65.0", + "@azure-tools/typespec-azure-core": "0.65.0", + "@azure-tools/typespec-azure-resource-manager": "0.65.0", + "@azure-tools/typespec-azure-rulesets": "0.65.0", + "@azure-tools/typespec-client-generator-core": "0.65.0", "@azure-tools/typespec-liftr-base": "0.11.0", "@microsoft/api-extractor": "^7.56.3", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.23", - "@types/node": "~25.2.2", - "@typescript-eslint/eslint-plugin": "~8.54.0", - "@typescript-eslint/parser": "~8.54.0", - "@typespec/compiler": "1.8.0", - "@typespec/events": "0.78.0", - "@typespec/http": "1.8.0", - "@typespec/openapi": "1.8.0", - "@typespec/rest": "0.78.0", - "@typespec/sse": "0.78.0", - "@typespec/streams": "0.78.0", - "@typespec/tspd": "0.73.3", - "@typespec/versioning": "0.78.0", - "@typespec/xml": "0.78.0", + "@types/node": "~25.2.3", + "@typescript-eslint/eslint-plugin": "~8.55.0", + "@typescript-eslint/parser": "~8.55.0", + "@typespec/compiler": "1.9.0", + "@typespec/events": "0.79.0", + "@typespec/http": "1.9.0", + "@typespec/openapi": "1.9.0", + "@typespec/rest": "0.79.0", + "@typespec/sse": "0.79.0", + "@typespec/streams": "0.79.0", + "@typespec/tspd": "0.74.0", + "@typespec/versioning": "0.79.0", + "@typespec/xml": "0.79.0", "@vitest/coverage-v8": "^4.0.18", "@vitest/ui": "^4.0.18", "c8": "~10.1.3", @@ -47,26 +47,26 @@ "prettier": "~3.8.1", "rimraf": "~6.1.2", "typescript": "~5.9.3", - "typescript-eslint": "^8.54.0", + "typescript-eslint": "^8.55.0", "vitest": "^4.0.18" }, "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@azure-tools/openai-typespec": "^1.8.0", - "@azure-tools/typespec-autorest": ">=0.64.1 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.64.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.64.1 <1.0.0", - "@azure-tools/typespec-azure-rulesets": ">=0.64.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.64.6 <1.0.0", + "@azure-tools/openai-typespec": "^1.9.0", + "@azure-tools/typespec-autorest": ">=0.65.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.65.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.65.0 <1.0.0", + "@azure-tools/typespec-azure-rulesets": ">=0.65.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.65.0 <1.0.0", "@azure-tools/typespec-liftr-base": ">=0.11.0 <1.0.0", - "@typespec/compiler": "^1.8.0", - "@typespec/http": "^1.8.0", - "@typespec/openapi": "^1.8.0", - "@typespec/rest": ">=0.78.0 <1.0.0", - "@typespec/versioning": ">=0.78.0 <1.0.0", - "@typespec/xml": ">=0.78.0 <1.0.0" + "@typespec/compiler": "^1.9.0", + "@typespec/http": "^1.9.0", + "@typespec/openapi": "^1.9.0", + "@typespec/rest": ">=0.79.0 <1.0.0", + "@typespec/versioning": ">=0.79.0 <1.0.0", + "@typespec/xml": ">=0.79.0 <1.0.0" } }, "node_modules/@alloy-js/core": { @@ -147,9 +147,9 @@ } }, "node_modules/@azure-tools/openai-typespec": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@azure-tools/openai-typespec/-/openai-typespec-1.8.0.tgz", - "integrity": "sha512-iJRimNIbwqAF6ueYpiL5xY1GJSOA1k3NkqA1NdPlxSJ3bZLP690zR+hHTqEq95HnwqFh2feCDjof9ABtY4keWg==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@azure-tools/openai-typespec/-/openai-typespec-1.9.0.tgz", + "integrity": "sha512-dfBMsDUJ1/c9W2mHdJBPmi25EzUOgs//xLgBu/zssrYzhOmBdBPPCnGQD7lNYPySgvC1a6uymOMQ+bR64L3Llg==", "dev": true, "license": "MIT", "peerDependencies": { @@ -167,24 +167,24 @@ } }, "node_modules/@azure-tools/typespec-autorest": { - "version": "0.64.1", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.64.1.tgz", - "integrity": "sha512-WzSRiX0XS7hCL+uiivLBYMbirEUenxNzPT4giF0J+r54CVNXq/u8PLnA/06F5EHkXPa92swF4BxB1vFWB2TKow==", + "version": "0.65.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-autorest/-/typespec-autorest-0.65.0.tgz", + "integrity": "sha512-R8pZt7rYdA2Hr3nck93OGapkQZe3MSzoYq4PgRtsGDHcvA5Qp7RBQMF/tP5DEcFWDDm+unoQeDpbD02POb/LTA==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.64.0", - "@azure-tools/typespec-azure-resource-manager": "^0.64.1", - "@azure-tools/typespec-client-generator-core": "^0.64.4", - "@typespec/compiler": "^1.8.0", - "@typespec/http": "^1.8.0", - "@typespec/openapi": "^1.8.0", - "@typespec/rest": "^0.78.0", - "@typespec/versioning": "^0.78.0", - "@typespec/xml": "^0.78.0" + "@azure-tools/typespec-azure-core": "^0.65.0", + "@azure-tools/typespec-azure-resource-manager": "^0.65.0", + "@azure-tools/typespec-client-generator-core": "^0.65.0", + "@typespec/compiler": "^1.9.0", + "@typespec/http": "^1.9.0", + "@typespec/openapi": "^1.9.0", + "@typespec/rest": "^0.79.0", + "@typespec/versioning": "^0.79.0", + "@typespec/xml": "^0.79.0" }, "peerDependenciesMeta": { "@typespec/xml": { @@ -193,9 +193,9 @@ } }, "node_modules/@azure-tools/typespec-azure-core": { - "version": "0.64.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.64.0.tgz", - "integrity": "sha512-BXiHc5oayhMsG1dHFU1aFK/ZQX2Gl0dKB0FAFceapaFV9093J2obbsdhIDR3Tl0qei9g3Ha+iWKZ4KgnLdhv4w==", + "version": "0.65.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-core/-/typespec-azure-core-0.65.0.tgz", + "integrity": "sha512-dYgHtt0CY0Q9AimdIsMV41jHKLmAT4r++TLwyxAHRbxdiRG+Sll1UKJzOIIoq45Bq64wCfEltu5OOnyPA01/sQ==", "dev": true, "license": "MIT", "peer": true, @@ -203,15 +203,15 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.8.0", - "@typespec/http": "^1.8.0", - "@typespec/rest": "^0.78.0" + "@typespec/compiler": "^1.9.0", + "@typespec/http": "^1.9.0", + "@typespec/rest": "^0.79.0" } }, "node_modules/@azure-tools/typespec-azure-resource-manager": { - "version": "0.64.1", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.64.1.tgz", - "integrity": "sha512-qQV/+ZVF1h8PsTNKhmKYyb+vSCgnLA8SoGeEE1oOrevGrrp9VgtOMAZ2xIxj6DpU90QU/8t2+r5P/gcQUV1iqw==", + "version": "0.65.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-resource-manager/-/typespec-azure-resource-manager-0.65.0.tgz", + "integrity": "sha512-3rvyGDIYSqraZ7jHfq5Bfet8u3ZeERWJWhwWMNvbShnrS/vVR3iuu/1z2M0p5mTRFuwUaSMlL/dbtBp1YqgGAg==", "dev": true, "license": "MIT", "peer": true, @@ -223,34 +223,34 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.64.0", - "@typespec/compiler": "^1.8.0", - "@typespec/http": "^1.8.0", - "@typespec/openapi": "^1.8.0", - "@typespec/rest": "^0.78.0", - "@typespec/versioning": "^0.78.0" + "@azure-tools/typespec-azure-core": "^0.65.0", + "@typespec/compiler": "^1.9.0", + "@typespec/http": "^1.9.0", + "@typespec/openapi": "^1.9.0", + "@typespec/rest": "^0.79.0", + "@typespec/versioning": "^0.79.0" } }, "node_modules/@azure-tools/typespec-azure-rulesets": { - "version": "0.64.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-rulesets/-/typespec-azure-rulesets-0.64.0.tgz", - "integrity": "sha512-CvK5iolfsm8oAUZ5wegGVYp4Vvw2rwQa+rcUVoJkwi9c6QwEr+qT6/S4hIntuzEPLxybJSb/ZIWU9Qx3cDrzXg==", + "version": "0.65.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-azure-rulesets/-/typespec-azure-rulesets-0.65.0.tgz", + "integrity": "sha512-oGuCw61uU9fUASog/1iD1rGeGhcKgnAuyBWA63wRcMMrcW1ZqUK2xvjV1XJuoYRlMxU8HpQShFcvsj715pNVLQ==", "dev": true, "license": "MIT", "engines": { "node": ">=20.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.64.0", - "@azure-tools/typespec-azure-resource-manager": "^0.64.0", - "@azure-tools/typespec-client-generator-core": "^0.64.0", - "@typespec/compiler": "^1.8.0" + "@azure-tools/typespec-azure-core": "^0.65.0", + "@azure-tools/typespec-azure-resource-manager": "^0.65.0", + "@azure-tools/typespec-client-generator-core": "^0.65.0", + "@typespec/compiler": "^1.9.0" } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.64.6", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.64.6.tgz", - "integrity": "sha512-S0OH5UmIltjPdj/rdMD8RBpAQWpFP+0jjXLZSi2ARCZkhzi6++E1fEsqLLNDW7oP0CDq3RYQgpuWyCLZVtVf/A==", + "version": "0.65.0", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.65.0.tgz", + "integrity": "sha512-+g6+xB967chLQlukt2nKSCNUagg99MySrdFkY6Izu0z32Wq6ba/FI9IbqBDRTBGFveX+fxS39Xn/xCbtU3nTRg==", "dev": true, "license": "MIT", "peer": true, @@ -263,16 +263,16 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.64.0", - "@typespec/compiler": "^1.8.0", - "@typespec/events": "^0.78.0", - "@typespec/http": "^1.8.0", - "@typespec/openapi": "^1.8.0", - "@typespec/rest": "^0.78.0", - "@typespec/sse": "^0.78.0", - "@typespec/streams": "^0.78.0", - "@typespec/versioning": "^0.78.0", - "@typespec/xml": "^0.78.0" + "@azure-tools/typespec-azure-core": "^0.65.0", + "@typespec/compiler": "^1.9.0", + "@typespec/events": "^0.79.0", + "@typespec/http": "^1.9.0", + "@typespec/openapi": "^1.9.0", + "@typespec/rest": "^0.79.0", + "@typespec/sse": "^0.79.0", + "@typespec/streams": "^0.79.0", + "@typespec/versioning": "^0.79.0", + "@typespec/xml": "^0.79.0" } }, "node_modules/@azure-tools/typespec-liftr-base": { @@ -282,13 +282,13 @@ "dev": true }, "node_modules/@babel/code-frame": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", - "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.28.6.tgz", + "integrity": "sha512-JYgintcMjRiCvS8mMECzaEn+m3PfoQiyqukOMCCVQtoJGYJw8j/8LBJEiqkHLkfwCcs74E3pbAUFNg7d9VNJ+Q==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" }, @@ -2478,9 +2478,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "25.2.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.2.2.tgz", - "integrity": "sha512-BkmoP5/FhRYek5izySdkOneRyXYN35I860MFAGupTdebyE66uZaR+bXLHq8k4DirE5DwQi3NuhvRU1jqTVwUrQ==", + "version": "25.2.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.2.3.tgz", + "integrity": "sha512-m0jEgYlYz+mDJZ2+F4v8D1AyQb+QzsNqRuI7xg1VQX/KlKS0qT9r1Mo16yo5F/MtifXFgaofIFsdFMox2SxIbQ==", "dev": true, "license": "MIT", "peer": true, @@ -2496,17 +2496,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.54.0.tgz", - "integrity": "sha512-hAAP5io/7csFStuOmR782YmTthKBJ9ND3WVL60hcOjvtGFb+HJxH4O5huAcmcZ9v9G8P+JETiZ/G1B8MALnWZQ==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.55.0.tgz", + "integrity": "sha512-1y/MVSz0NglV1ijHC8OT49mPJ4qhPYjiK08YUQVbIOyu+5k862LKUHFkpKHWu//zmr7hDR2rhwUm6gnCGNmGBQ==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.54.0", - "@typescript-eslint/type-utils": "8.54.0", - "@typescript-eslint/utils": "8.54.0", - "@typescript-eslint/visitor-keys": "8.54.0", + "@typescript-eslint/scope-manager": "8.55.0", + "@typescript-eslint/type-utils": "8.55.0", + "@typescript-eslint/utils": "8.55.0", + "@typescript-eslint/visitor-keys": "8.55.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.4.0" @@ -2519,7 +2519,7 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.54.0", + "@typescript-eslint/parser": "^8.55.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } @@ -2548,17 +2548,17 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.54.0.tgz", - "integrity": "sha512-BtE0k6cjwjLZoZixN0t5AKP0kSzlGu7FctRXYuPAm//aaiZhmfq1JwdYpYr1brzEspYyFeF+8XF5j2VK6oalrA==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.55.0.tgz", + "integrity": "sha512-4z2nCSBfVIMnbuu8uinj+f0o4qOeggYJLbjpPHka3KH1om7e+H9yLKTYgksTaHcGco+NClhhY2vyO3HsMH1RGw==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "@typescript-eslint/scope-manager": "8.54.0", - "@typescript-eslint/types": "8.54.0", - "@typescript-eslint/typescript-estree": "8.54.0", - "@typescript-eslint/visitor-keys": "8.54.0", + "@typescript-eslint/scope-manager": "8.55.0", + "@typescript-eslint/types": "8.55.0", + "@typescript-eslint/typescript-estree": "8.55.0", + "@typescript-eslint/visitor-keys": "8.55.0", "debug": "^4.4.3" }, "engines": { @@ -2574,14 +2574,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.54.0.tgz", - "integrity": "sha512-YPf+rvJ1s7MyiWM4uTRhE4DvBXrEV+d8oC3P9Y2eT7S+HBS0clybdMIPnhiATi9vZOYDc7OQ1L/i6ga6NFYK/g==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.55.0.tgz", + "integrity": "sha512-zRcVVPFUYWa3kNnjaZGXSu3xkKV1zXy8M4nO/pElzQhFweb7PPtluDLQtKArEOGmjXoRjnUZ29NjOiF0eCDkcQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.54.0", - "@typescript-eslint/types": "^8.54.0", + "@typescript-eslint/tsconfig-utils": "^8.55.0", + "@typescript-eslint/types": "^8.55.0", "debug": "^4.4.3" }, "engines": { @@ -2596,14 +2596,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.54.0.tgz", - "integrity": "sha512-27rYVQku26j/PbHYcVfRPonmOlVI6gihHtXFbTdB5sb6qA0wdAQAbyXFVarQ5t4HRojIz64IV90YtsjQSSGlQg==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.55.0.tgz", + "integrity": "sha512-fVu5Omrd3jeqeQLiB9f1YsuK/iHFOwb04bCtY4BSCLgjNbOD33ZdV6KyEqplHr+IlpgT0QTZ/iJ+wT7hvTx49Q==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.54.0", - "@typescript-eslint/visitor-keys": "8.54.0" + "@typescript-eslint/types": "8.55.0", + "@typescript-eslint/visitor-keys": "8.55.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2614,9 +2614,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.54.0.tgz", - "integrity": "sha512-dRgOyT2hPk/JwxNMZDsIXDgyl9axdJI3ogZ2XWhBPsnZUv+hPesa5iuhdYt2gzwA9t8RE5ytOJ6xB0moV0Ujvw==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.55.0.tgz", + "integrity": "sha512-1R9cXqY7RQd7WuqSN47PK9EDpgFUK3VqdmbYrvWJZYDd0cavROGn+74ktWBlmJ13NXUQKlZ/iAEQHI/V0kKe0Q==", "dev": true, "license": "MIT", "engines": { @@ -2631,15 +2631,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.54.0.tgz", - "integrity": "sha512-hiLguxJWHjjwL6xMBwD903ciAwd7DmK30Y9Axs/etOkftC3ZNN9K44IuRD/EB08amu+Zw6W37x9RecLkOo3pMA==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.55.0.tgz", + "integrity": "sha512-x1iH2unH4qAt6I37I2CGlsNs+B9WGxurP2uyZLRz6UJoZWDBx9cJL1xVN/FiOmHEONEg6RIufdvyT0TEYIgC5g==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.54.0", - "@typescript-eslint/typescript-estree": "8.54.0", - "@typescript-eslint/utils": "8.54.0", + "@typescript-eslint/types": "8.55.0", + "@typescript-eslint/typescript-estree": "8.55.0", + "@typescript-eslint/utils": "8.55.0", "debug": "^4.4.3", "ts-api-utils": "^2.4.0" }, @@ -2669,9 +2669,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.54.0.tgz", - "integrity": "sha512-PDUI9R1BVjqu7AUDsRBbKMtwmjWcn4J3le+5LpcFgWULN3LvHC5rkc9gCVxbrsrGmO1jfPybN5s6h4Jy+OnkAA==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.55.0.tgz", + "integrity": "sha512-ujT0Je8GI5BJWi+/mMoR0wxwVEQaxM+pi30xuMiJETlX80OPovb2p9E8ss87gnSVtYXtJoU9U1Cowcr6w2FE0w==", "dev": true, "license": "MIT", "engines": { @@ -2683,16 +2683,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.54.0.tgz", - "integrity": "sha512-BUwcskRaPvTk6fzVWgDPdUndLjB87KYDrN5EYGetnktoeAvPtO4ONHlAZDnj5VFnUANg0Sjm7j4usBlnoVMHwA==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.55.0.tgz", + "integrity": "sha512-EwrH67bSWdx/3aRQhCoxDaHM+CrZjotc2UCCpEDVqfCE+7OjKAGWNY2HsCSTEVvWH2clYQK8pdeLp42EVs+xQw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.54.0", - "@typescript-eslint/tsconfig-utils": "8.54.0", - "@typescript-eslint/types": "8.54.0", - "@typescript-eslint/visitor-keys": "8.54.0", + "@typescript-eslint/project-service": "8.55.0", + "@typescript-eslint/tsconfig-utils": "8.55.0", + "@typescript-eslint/types": "8.55.0", + "@typescript-eslint/visitor-keys": "8.55.0", "debug": "^4.4.3", "minimatch": "^9.0.5", "semver": "^7.7.3", @@ -2724,16 +2724,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.54.0.tgz", - "integrity": "sha512-9Cnda8GS57AQakvRyG0PTejJNlA2xhvyNtEVIMlDWOOeEyBkYWhGPnfrIAnqxLMTSTo6q8g12XVjjev5l1NvMA==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.55.0.tgz", + "integrity": "sha512-BqZEsnPGdYpgyEIkDC1BadNY8oMwckftxBT+C8W0g1iKPdeqKZBtTfnvcq0nf60u7MkjFO8RBvpRGZBPw4L2ow==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.54.0", - "@typescript-eslint/types": "8.54.0", - "@typescript-eslint/typescript-estree": "8.54.0" + "@typescript-eslint/scope-manager": "8.55.0", + "@typescript-eslint/types": "8.55.0", + "@typescript-eslint/typescript-estree": "8.55.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2748,13 +2748,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.54.0.tgz", - "integrity": "sha512-VFlhGSl4opC0bprJiItPQ1RfUhGDIBokcPwaFH4yiBCaNPeld/9VeXbiPO1cLyorQi1G1vL+ecBk1x8o1axORA==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.55.0.tgz", + "integrity": "sha512-AxNRwEie8Nn4eFS1FzDMJWIISMGoXMb037sgCBJ3UR6o0fQTzr2tqN9WT+DkWJPhIdQCfV7T6D387566VtnCJA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.54.0", + "@typescript-eslint/types": "8.55.0", "eslint-visitor-keys": "^4.2.1" }, "engines": { @@ -2779,23 +2779,23 @@ } }, "node_modules/@typespec/compiler": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.8.0.tgz", - "integrity": "sha512-FeLb7Q0z6Bh5dDpqtnU2RlWiIWWWF7rujx2xGMta5dcTuIOZ4jbdyz1hVdxk4iM4qadvaSV4ey/qrSuffNoh3w==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-1.9.0.tgz", + "integrity": "sha512-Rz9fFWQSTJSnhBfZvtA/bDIuO82fknYdtyMsL9lZNJE82rquC6JByHPFsnbGH1VXA0HhMj9L7Oqyp3f0m/BTOA==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "@babel/code-frame": "~7.27.1", + "@babel/code-frame": "~7.28.6", "@inquirer/prompts": "^8.0.1", "ajv": "~8.17.1", "change-case": "~5.4.4", "env-paths": "^3.0.0", - "globby": "~16.0.0", + "globby": "~16.1.0", "is-unicode-supported": "^2.1.0", "mustache": "~4.2.0", "picocolors": "~1.1.1", - "prettier": "~3.7.4", + "prettier": "~3.8.0", "semver": "^7.7.1", "tar": "^7.5.2", "temporal-polyfill": "^0.3.0", @@ -2861,9 +2861,9 @@ "license": "MIT" }, "node_modules/@typespec/compiler/node_modules/globby": { - "version": "16.0.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-16.0.0.tgz", - "integrity": "sha512-ejy4TJFga99yW6Q0uhM3pFawKWZmtZzZD/v/GwI5+9bCV5Ew+D2pSND6W7fUes5UykqSsJkUfxFVdRh7Q1+P3Q==", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-16.1.0.tgz", + "integrity": "sha512-+A4Hq7m7Ze592k9gZRy4gJ27DrXRNnC1vPjxTt1qQxEY8RxagBkBxivkCwg7FxSTG0iLLEMaUx13oOr0R2/qcQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2891,22 +2891,6 @@ "node": ">= 4" } }, - "node_modules/@typespec/compiler/node_modules/prettier": { - "version": "3.7.4", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz", - "integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==", - "dev": true, - "license": "MIT", - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "node_modules/@typespec/compiler/node_modules/slash": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", @@ -3001,9 +2985,9 @@ } }, "node_modules/@typespec/events": { - "version": "0.78.0", - "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.78.0.tgz", - "integrity": "sha512-gSI4rAexxfYyZX0ZqYNRWQyuMb1UeakjAjOeh/2ntmxWCdYc+wSbJjxrxIArsZC+LwzTxq5WpdtD7+7OWzG4yw==", + "version": "0.79.0", + "resolved": "https://registry.npmjs.org/@typespec/events/-/events-0.79.0.tgz", + "integrity": "sha512-41R2jA7k21uMArjyUdvnqYzVnPPaSEcGi40dLMiRVP79m6XgnD3INuTdlMblaS1i+5jJ1BtS1o4QhBBuS/5/qg==", "dev": true, "license": "MIT", "peer": true, @@ -3011,13 +2995,13 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.8.0" + "@typespec/compiler": "^1.9.0" } }, "node_modules/@typespec/http": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.8.0.tgz", - "integrity": "sha512-ZKa4RISabwL8cUAmE3BkoNmtCYRjerO0+1Ba6XdDJKG+vJC5EGM2hkDf+ZmYsYZgrX0cvbhPXUKKh28zBV60hw==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.9.0.tgz", + "integrity": "sha512-JzlZZsgCo71f2KhWbf4BLOz5e+dVLj7gJJ4kvXvrmuG9QHoT41VaGPpCQamYgpZLMz2LQbsOtw34AmpovhuJSw==", "dev": true, "license": "MIT", "peer": true, @@ -3025,8 +3009,8 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.8.0", - "@typespec/streams": "^0.78.0" + "@typespec/compiler": "^1.9.0", + "@typespec/streams": "^0.79.0" }, "peerDependenciesMeta": { "@typespec/streams": { @@ -3035,9 +3019,9 @@ } }, "node_modules/@typespec/openapi": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.8.0.tgz", - "integrity": "sha512-v+RIJpx7vALBSGQmnUWemvXjnrk50HAVqJeg0RbaF3VUnh66Z4itsoNJJmIIc+HmBJng8Ie0V7xv3l02ek6HWA==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-1.9.0.tgz", + "integrity": "sha512-5ieXCWRLcyFLv3IFk26ena/RW/NxvT5KiHaoNVFRd79J0XZjFcE0Od6Lxxqj4dWmCo3C8oKtOwFoQuie18G3lQ==", "dev": true, "license": "MIT", "peer": true, @@ -3045,14 +3029,14 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.8.0", - "@typespec/http": "^1.8.0" + "@typespec/compiler": "^1.9.0", + "@typespec/http": "^1.9.0" } }, "node_modules/@typespec/rest": { - "version": "0.78.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.78.0.tgz", - "integrity": "sha512-1clnDw1JbBvjLcfFvEvHdIrnsQuQI5/Cl6mRIrzWWX0pKJ+R89rCdZD1KpidEXw4B4qscD48LsssyrEIFLtuPg==", + "version": "0.79.0", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.79.0.tgz", + "integrity": "sha512-6QIX7oaUGy/z4rseUrC86LjHxZn8rAAY4fXvGnlPRce6GhEdTb9S9OQPmlPeWngXwCx/07P2+FCR915APqmZxg==", "dev": true, "license": "MIT", "peer": true, @@ -3060,14 +3044,14 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.8.0", - "@typespec/http": "^1.8.0" + "@typespec/compiler": "^1.9.0", + "@typespec/http": "^1.9.0" } }, "node_modules/@typespec/sse": { - "version": "0.78.0", - "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.78.0.tgz", - "integrity": "sha512-jPARl+e1e/nsDW/1uVsGTzvKmjqezVMyUa13igXxk5nV2ScMdFpH1HhBwTmAhUeaZgY3J81dFHNUnIY67HCrmw==", + "version": "0.79.0", + "resolved": "https://registry.npmjs.org/@typespec/sse/-/sse-0.79.0.tgz", + "integrity": "sha512-YQYlDWCNBza75S360jc51emwntWXMZfkvqXKng+etKP4iCuogJfTX1J8h1yd8tZwkuUNBcklEPCuz3O/+psopg==", "dev": true, "license": "MIT", "peer": true, @@ -3075,16 +3059,16 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.8.0", - "@typespec/events": "^0.78.0", - "@typespec/http": "^1.8.0", - "@typespec/streams": "^0.78.0" + "@typespec/compiler": "^1.9.0", + "@typespec/events": "^0.79.0", + "@typespec/http": "^1.9.0", + "@typespec/streams": "^0.79.0" } }, "node_modules/@typespec/streams": { - "version": "0.78.0", - "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.78.0.tgz", - "integrity": "sha512-wzh5bVdzh+K+pFQFs/EZkVsTH5TQGi12XwhjxJS0UKRwaW2UwSZeY1HqX07oMMPdYESTbjgMrXcxtn89AlzjvQ==", + "version": "0.79.0", + "resolved": "https://registry.npmjs.org/@typespec/streams/-/streams-0.79.0.tgz", + "integrity": "sha512-nOXpLcEYNdWvLY/6WJ16rD6hGs7bKSmkH+WwgyVwdRON5KJ559quw56pns2DSANw+NaV0lJxJq/8ek5xKCGD6g==", "dev": true, "license": "MIT", "peer": true, @@ -3092,13 +3076,13 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.8.0" + "@typespec/compiler": "^1.9.0" } }, "node_modules/@typespec/tspd": { - "version": "0.73.3", - "resolved": "https://registry.npmjs.org/@typespec/tspd/-/tspd-0.73.3.tgz", - "integrity": "sha512-LbJ02YDM7WfFlFqklqdcEBovXtZFlMpw3qEv5MMzaCTmEN9cZqgCQuGVwCxQM/yJiqima7iR9pkaDXcUFcKoFQ==", + "version": "0.74.0", + "resolved": "https://registry.npmjs.org/@typespec/tspd/-/tspd-0.74.0.tgz", + "integrity": "sha512-3djIZittIUk7PWzBvXTyu3UII8WXujjBnKz+ADzKUEPcLCZgVMjdXUAjeYQHM8q7AJr6jAovUqAQSft49wCk3Q==", "dev": true, "license": "MIT", "dependencies": { @@ -3109,9 +3093,9 @@ "@microsoft/api-extractor-model": "^7.30.6", "@microsoft/tsdoc": "^0.16.0", "@microsoft/tsdoc-config": "^0.18.0", - "@typespec/compiler": "^1.8.0", + "@typespec/compiler": "^1.9.0", "picocolors": "~1.1.1", - "prettier": "~3.7.4", + "prettier": "~3.8.0", "typedoc": "^0.28.1", "typedoc-plugin-markdown": "^4.5.2", "yaml": "~2.8.2", @@ -3172,22 +3156,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@typespec/tspd/node_modules/prettier": { - "version": "3.7.4", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz", - "integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==", - "dev": true, - "license": "MIT", - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "node_modules/@typespec/tspd/node_modules/string-width": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", @@ -3269,9 +3237,9 @@ } }, "node_modules/@typespec/versioning": { - "version": "0.78.0", - "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.78.0.tgz", - "integrity": "sha512-I14X6+IMd0wFMNI8oMFSeFBi2nD4idub+geSO34vuCs4rwuEj3FNzy+rkNkDDvf0+gIUGxeyg7s+YDUcNyiqOA==", + "version": "0.79.0", + "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.79.0.tgz", + "integrity": "sha512-mk65zpKNm+ARyHASnre/lp3o3FKzb0P8Nj96ji182JUy7ShrVCCF0u+bC+ZXQ8ZTRza1d0xBjRC/Xr4iM+Uwag==", "dev": true, "license": "MIT", "peer": true, @@ -3279,13 +3247,13 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.8.0" + "@typespec/compiler": "^1.9.0" } }, "node_modules/@typespec/xml": { - "version": "0.78.0", - "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.78.0.tgz", - "integrity": "sha512-KSDhJX6A/Onsu9FKVZtR/xSy5va3k0y9/U4eiZUn91V/LQyMZNwmResPDHEVYk6JqaIH8bbd6ANWPu3nMd7mmw==", + "version": "0.79.0", + "resolved": "https://registry.npmjs.org/@typespec/xml/-/xml-0.79.0.tgz", + "integrity": "sha512-BqbbtkL9xuiAhehHKKUCMtRg0a1vjSvoiAOanvTIuoFq3N8PbKVV3dKTcyI/oS3iCCkJErdu11HQcAoD/VsIsA==", "dev": true, "license": "MIT", "peer": true, @@ -3293,7 +3261,7 @@ "node": ">=20.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.8.0" + "@typespec/compiler": "^1.9.0" } }, "node_modules/@vitest/coverage-v8": { @@ -4973,38 +4941,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/@eslint-community/eslint-utils": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz", - "integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" - } - }, - "node_modules/eslint/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/eslint/node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -8166,16 +8102,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.54.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.54.0.tgz", - "integrity": "sha512-CKsJ+g53QpsNPqbzUsfKVgd3Lny4yKZ1pP4qN3jdMOg/sisIDLGyDMezycquXLE5JsEU0wp3dGNdzig0/fmSVQ==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.55.0.tgz", + "integrity": "sha512-HE4wj+r5lmDVS9gdaN0/+iqNvPZwGfnJ5lZuz7s5vLlg9ODw0bIiiETaios9LvFI1U94/VBXGm3CB2Y5cNFMpw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.54.0", - "@typescript-eslint/parser": "8.54.0", - "@typescript-eslint/typescript-estree": "8.54.0", - "@typescript-eslint/utils": "8.54.0" + "@typescript-eslint/eslint-plugin": "8.55.0", + "@typescript-eslint/parser": "8.55.0", + "@typescript-eslint/typescript-estree": "8.55.0", + "@typescript-eslint/utils": "8.55.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/typespec-extension/package.json b/typespec-extension/package.json index f23e100b37..7636d0b0f9 100644 --- a/typespec-extension/package.json +++ b/typespec-extension/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/typespec-java", - "version": "0.39.1", + "version": "0.39.2", "description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding", "keywords": [ "TypeSpec" @@ -47,19 +47,19 @@ "generator/http-client-generator/target/classes/PerfAutomation.jfc" ], "peerDependencies": { - "@azure-tools/openai-typespec": "^1.8.0", - "@azure-tools/typespec-autorest": ">=0.64.1 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.64.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.64.1 <1.0.0", - "@azure-tools/typespec-azure-rulesets": ">=0.64.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.64.6 <1.0.0", + "@azure-tools/openai-typespec": "^1.9.0", + "@azure-tools/typespec-autorest": ">=0.65.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.65.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.65.0 <1.0.0", + "@azure-tools/typespec-azure-rulesets": ">=0.65.0 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.65.0 <1.0.0", "@azure-tools/typespec-liftr-base": ">=0.11.0 <1.0.0", - "@typespec/compiler": "^1.8.0", - "@typespec/http": "^1.8.0", - "@typespec/openapi": "^1.8.0", - "@typespec/rest": ">=0.78.0 <1.0.0", - "@typespec/versioning": ">=0.78.0 <1.0.0", - "@typespec/xml": ">=0.78.0 <1.0.0" + "@typespec/compiler": "^1.9.0", + "@typespec/http": "^1.9.0", + "@typespec/openapi": "^1.9.0", + "@typespec/rest": ">=0.79.0 <1.0.0", + "@typespec/versioning": ">=0.79.0 <1.0.0", + "@typespec/xml": ">=0.79.0 <1.0.0" }, "dependencies": { "@autorest/codemodel": "~4.20.1", @@ -67,29 +67,29 @@ "lodash": "~4.17.23" }, "devDependencies": { - "@azure-tools/openai-typespec": "^1.8.0", - "@azure-tools/typespec-autorest": "0.64.1", - "@azure-tools/typespec-azure-core": "0.64.0", - "@azure-tools/typespec-azure-resource-manager": "0.64.1", - "@azure-tools/typespec-azure-rulesets": "0.64.0", - "@azure-tools/typespec-client-generator-core": "0.64.6", + "@azure-tools/openai-typespec": "^1.9.0", + "@azure-tools/typespec-autorest": "0.65.0", + "@azure-tools/typespec-azure-core": "0.65.0", + "@azure-tools/typespec-azure-resource-manager": "0.65.0", + "@azure-tools/typespec-azure-rulesets": "0.65.0", + "@azure-tools/typespec-client-generator-core": "0.65.0", "@azure-tools/typespec-liftr-base": "0.11.0", "@microsoft/api-extractor": "^7.56.3", "@types/js-yaml": "~4.0.9", "@types/lodash": "~4.17.23", - "@types/node": "~25.2.2", - "@typescript-eslint/eslint-plugin": "~8.54.0", - "@typescript-eslint/parser": "~8.54.0", - "@typespec/compiler": "1.8.0", - "@typespec/events": "0.78.0", - "@typespec/http": "1.8.0", - "@typespec/openapi": "1.8.0", - "@typespec/rest": "0.78.0", - "@typespec/sse": "0.78.0", - "@typespec/streams": "0.78.0", - "@typespec/tspd": "0.73.3", - "@typespec/versioning": "0.78.0", - "@typespec/xml": "0.78.0", + "@types/node": "~25.2.3", + "@typescript-eslint/eslint-plugin": "~8.55.0", + "@typescript-eslint/parser": "~8.55.0", + "@typespec/compiler": "1.9.0", + "@typespec/events": "0.79.0", + "@typespec/http": "1.9.0", + "@typespec/openapi": "1.9.0", + "@typespec/rest": "0.79.0", + "@typespec/sse": "0.79.0", + "@typespec/streams": "0.79.0", + "@typespec/tspd": "0.74.0", + "@typespec/versioning": "0.79.0", + "@typespec/xml": "0.79.0", "@vitest/coverage-v8": "^4.0.18", "@vitest/ui": "^4.0.18", "c8": "~10.1.3", @@ -100,12 +100,12 @@ "prettier": "~3.8.1", "rimraf": "~6.1.2", "typescript": "~5.9.3", - "typescript-eslint": "^8.54.0", + "typescript-eslint": "^8.55.0", "vitest": "^4.0.18" }, "overrides": { "eslint": "~9.39.2", - "@typescript-eslint/eslint-plugin": "~8.54.0", - "@typescript-eslint/parser": "~8.54.0" + "@typescript-eslint/eslint-plugin": "~8.55.0", + "@typescript-eslint/parser": "~8.55.0" } } diff --git a/typespec-tests/package.json b/typespec-tests/package.json index d0a40c07f5..e155115ac5 100644 --- a/typespec-tests/package.json +++ b/typespec-tests/package.json @@ -10,30 +10,30 @@ }, "dependencies": { "@typespec/spec-api": "0.1.0-alpha.12", - "@typespec/spector": "0.1.0-alpha.22", - "@typespec/http-specs": "0.1.0-alpha.31", - "@azure-tools/azure-http-specs": "0.1.0-alpha.36", - "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.39.1.tgz" + "@typespec/spector": "0.1.0-alpha.23", + "@typespec/http-specs": "0.1.0-alpha.32", + "@azure-tools/azure-http-specs": "0.1.0-alpha.37", + "@azure-tools/typespec-java": "file:/../typespec-extension/azure-tools-typespec-java-0.39.2.tgz" }, "devDependencies": { - "@typespec/prettier-plugin-typespec": "^1.8.0", + "@typespec/prettier-plugin-typespec": "^1.9.0", "prettier-plugin-organize-imports": "^4.3.0", "prettier": "^3.8.1" }, "overrides": { - "@typespec/compiler": "1.8.0", - "@typespec/http": "1.8.0", - "@typespec/rest": "0.78.0", - "@typespec/versioning": "0.78.0", - "@typespec/openapi": "1.8.0", - "@typespec/xml": "0.78.0", - "@typespec/events": "0.78.0", - "@typespec/sse": "0.78.0", - "@typespec/streams": "0.78.0", - "@azure-tools/typespec-azure-core": "0.64.0", - "@azure-tools/typespec-client-generator-core": "0.64.6", - "@azure-tools/typespec-azure-resource-manager": "0.64.1", - "@azure-tools/typespec-autorest": "0.64.1", + "@typespec/compiler": "1.9.0", + "@typespec/http": "1.9.0", + "@typespec/rest": "0.79.0", + "@typespec/versioning": "0.79.0", + "@typespec/openapi": "1.9.0", + "@typespec/xml": "0.79.0", + "@typespec/events": "0.79.0", + "@typespec/sse": "0.79.0", + "@typespec/streams": "0.79.0", + "@azure-tools/typespec-azure-core": "0.65.0", + "@azure-tools/typespec-client-generator-core": "0.65.0", + "@azure-tools/typespec-azure-resource-manager": "0.65.0", + "@azure-tools/typespec-autorest": "0.65.0", "@azure-tools/typespec-liftr-base": "0.11.0" }, "private": true diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/HeaderParamAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/HeaderParamAsyncClient.java similarity index 95% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/HeaderParamAsyncClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/HeaderParamAsyncClient.java index 539b2d5456..199262de6a 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/HeaderParamAsyncClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/HeaderParamAsyncClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.HeaderParamClientImpl; -import azure.clientgenerator.core.clientinitialization.models.Input; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.HeaderParamClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.Input; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/HeaderParamClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/HeaderParamClient.java similarity index 94% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/HeaderParamClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/HeaderParamClient.java index 4bbcd7e836..89f1ea9ee4 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/HeaderParamClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/HeaderParamClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.HeaderParamClientImpl; -import azure.clientgenerator.core.clientinitialization.models.Input; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.HeaderParamClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.Input; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/HeaderParamClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/HeaderParamClientBuilder.java similarity index 96% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/HeaderParamClientBuilder.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/HeaderParamClientBuilder.java index 31137851e4..5f08efc49c 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/HeaderParamClientBuilder.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/HeaderParamClientBuilder.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.HeaderParamClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.HeaderParamClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.client.traits.ConfigurationTrait; @@ -51,7 +51,7 @@ public final class HeaderParamClientBuilder implements HttpTrait PROPERTIES - = CoreUtils.getProperties("azure-clientgenerator-core-clientinitialization.properties"); + = CoreUtils.getProperties("_specs_-azure-clientgenerator-core-clientinitialization-defaultclient.properties"); @Generated private final List pipelinePolicies; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MixedParamsAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MixedParamsAsyncClient.java similarity index 95% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MixedParamsAsyncClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MixedParamsAsyncClient.java index 04a316639b..bd7a724adc 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MixedParamsAsyncClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MixedParamsAsyncClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.MixedParamsClientImpl; -import azure.clientgenerator.core.clientinitialization.models.WithBodyRequest; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.MixedParamsClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.WithBodyRequest; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MixedParamsClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MixedParamsClient.java similarity index 94% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MixedParamsClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MixedParamsClient.java index 7ab664776b..f0ec7dbdac 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MixedParamsClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MixedParamsClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.MixedParamsClientImpl; -import azure.clientgenerator.core.clientinitialization.models.WithBodyRequest; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.MixedParamsClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.WithBodyRequest; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MixedParamsClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MixedParamsClientBuilder.java similarity index 96% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MixedParamsClientBuilder.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MixedParamsClientBuilder.java index 7ce9653523..74619a2b58 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MixedParamsClientBuilder.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MixedParamsClientBuilder.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.MixedParamsClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.MixedParamsClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.client.traits.ConfigurationTrait; @@ -51,7 +51,7 @@ public final class MixedParamsClientBuilder implements HttpTrait PROPERTIES - = CoreUtils.getProperties("azure-clientgenerator-core-clientinitialization.properties"); + = CoreUtils.getProperties("_specs_-azure-clientgenerator-core-clientinitialization-defaultclient.properties"); @Generated private final List pipelinePolicies; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MultipleParamsAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MultipleParamsAsyncClient.java similarity index 95% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MultipleParamsAsyncClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MultipleParamsAsyncClient.java index fffad715e0..87e4489609 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MultipleParamsAsyncClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MultipleParamsAsyncClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.MultipleParamsClientImpl; -import azure.clientgenerator.core.clientinitialization.models.Input; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.MultipleParamsClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.Input; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MultipleParamsClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MultipleParamsClient.java similarity index 94% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MultipleParamsClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MultipleParamsClient.java index 9972926770..3135bfd196 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MultipleParamsClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MultipleParamsClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.MultipleParamsClientImpl; -import azure.clientgenerator.core.clientinitialization.models.Input; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.MultipleParamsClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.Input; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MultipleParamsClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MultipleParamsClientBuilder.java similarity index 97% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MultipleParamsClientBuilder.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MultipleParamsClientBuilder.java index c448d71678..6f4fe5840f 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/MultipleParamsClientBuilder.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/MultipleParamsClientBuilder.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.MultipleParamsClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.MultipleParamsClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.client.traits.ConfigurationTrait; @@ -51,7 +51,7 @@ public final class MultipleParamsClientBuilder implements HttpTrait PROPERTIES - = CoreUtils.getProperties("azure-clientgenerator-core-clientinitialization.properties"); + = CoreUtils.getProperties("_specs_-azure-clientgenerator-core-clientinitialization-defaultclient.properties"); @Generated private final List pipelinePolicies; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/ParamAliasAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/ParamAliasAsyncClient.java similarity index 96% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/ParamAliasAsyncClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/ParamAliasAsyncClient.java index d15937a219..15dc398995 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/ParamAliasAsyncClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/ParamAliasAsyncClient.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.ParamAliasClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.ParamAliasClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/ParamAliasClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/ParamAliasClient.java similarity index 95% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/ParamAliasClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/ParamAliasClient.java index c373ba582a..fb4db9e8c8 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/ParamAliasClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/ParamAliasClient.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.ParamAliasClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.ParamAliasClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/ParamAliasClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/ParamAliasClientBuilder.java similarity index 96% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/ParamAliasClientBuilder.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/ParamAliasClientBuilder.java index fb31bfe198..e458847dc1 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/ParamAliasClientBuilder.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/ParamAliasClientBuilder.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.ParamAliasClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.ParamAliasClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.client.traits.ConfigurationTrait; @@ -51,7 +51,7 @@ public final class ParamAliasClientBuilder implements HttpTrait PROPERTIES - = CoreUtils.getProperties("azure-clientgenerator-core-clientinitialization.properties"); + = CoreUtils.getProperties("_specs_-azure-clientgenerator-core-clientinitialization-defaultclient.properties"); @Generated private final List pipelinePolicies; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/PathParamAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/PathParamAsyncClient.java similarity index 96% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/PathParamAsyncClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/PathParamAsyncClient.java index c62b4f90bf..a306c54dea 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/PathParamAsyncClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/PathParamAsyncClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.PathParamClientImpl; -import azure.clientgenerator.core.clientinitialization.models.BlobProperties; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.PathParamClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.BlobProperties; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/PathParamClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/PathParamClient.java similarity index 96% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/PathParamClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/PathParamClient.java index c724e68662..cb9a456624 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/PathParamClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/PathParamClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.PathParamClientImpl; -import azure.clientgenerator.core.clientinitialization.models.BlobProperties; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.PathParamClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.BlobProperties; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/PathParamClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/PathParamClientBuilder.java similarity index 96% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/PathParamClientBuilder.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/PathParamClientBuilder.java index 59ec31c7f3..6293f96269 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/PathParamClientBuilder.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/PathParamClientBuilder.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.PathParamClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.PathParamClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.client.traits.ConfigurationTrait; @@ -51,7 +51,7 @@ public final class PathParamClientBuilder implements HttpTrait PROPERTIES - = CoreUtils.getProperties("azure-clientgenerator-core-clientinitialization.properties"); + = CoreUtils.getProperties("_specs_-azure-clientgenerator-core-clientinitialization-defaultclient.properties"); @Generated private final List pipelinePolicies; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ChildAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/QueryParamAsyncClient.java similarity index 92% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ChildAsyncClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/QueryParamAsyncClient.java index 9c7040e586..5612353885 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ChildAsyncClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/QueryParamAsyncClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.parentclient; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.ChildClientImpl; -import azure.clientgenerator.core.clientinitialization.models.BlobProperties; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.QueryParamClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.BlobProperties; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -21,20 +21,20 @@ import reactor.core.publisher.Mono; /** - * Initializes a new instance of the asynchronous ChildClient type. + * Initializes a new instance of the asynchronous QueryParamClient type. */ -@ServiceClient(builder = ChildClientBuilder.class, isAsync = true) -public final class ChildAsyncClient { +@ServiceClient(builder = QueryParamClientBuilder.class, isAsync = true) +public final class QueryParamAsyncClient { @Generated - private final ChildClientImpl serviceClient; + private final QueryParamClientImpl serviceClient; /** - * Initializes an instance of ChildAsyncClient class. + * Initializes an instance of QueryParamAsyncClient class. * * @param serviceClient the service client implementation. */ @Generated - ChildAsyncClient(ChildClientImpl serviceClient) { + QueryParamAsyncClient(QueryParamClientImpl serviceClient) { this.serviceClient = serviceClient; } diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ChildClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/QueryParamClient.java similarity index 92% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ChildClient.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/QueryParamClient.java index 305cf7f8fc..f37d717bc1 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ChildClient.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/QueryParamClient.java @@ -2,10 +2,10 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.parentclient; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.ChildClientImpl; -import azure.clientgenerator.core.clientinitialization.models.BlobProperties; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.QueryParamClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models.BlobProperties; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -19,20 +19,20 @@ import com.azure.core.util.BinaryData; /** - * Initializes a new instance of the synchronous ChildClient type. + * Initializes a new instance of the synchronous QueryParamClient type. */ -@ServiceClient(builder = ChildClientBuilder.class) -public final class ChildClient { +@ServiceClient(builder = QueryParamClientBuilder.class) +public final class QueryParamClient { @Generated - private final ChildClientImpl serviceClient; + private final QueryParamClientImpl serviceClient; /** - * Initializes an instance of ChildClient class. + * Initializes an instance of QueryParamClient class. * * @param serviceClient the service client implementation. */ @Generated - ChildClient(ChildClientImpl serviceClient) { + QueryParamClient(QueryParamClientImpl serviceClient) { this.serviceClient = serviceClient; } diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ChildClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/QueryParamClientBuilder.java similarity index 76% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ChildClientBuilder.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/QueryParamClientBuilder.java index 17c2d14869..88e06209f2 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ChildClientBuilder.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/QueryParamClientBuilder.java @@ -2,9 +2,9 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.parentclient; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; -import azure.clientgenerator.core.clientinitialization.implementation.ChildClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation.QueryParamClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.client.traits.ConfigurationTrait; @@ -38,11 +38,11 @@ import java.util.Objects; /** - * A builder for creating a new instance of the ChildClient type. + * A builder for creating a new instance of the QueryParamClient type. */ -@ServiceClientBuilder(serviceClients = { ChildClient.class, ChildAsyncClient.class }) -public final class ChildClientBuilder implements HttpTrait, ConfigurationTrait, - EndpointTrait { +@ServiceClientBuilder(serviceClients = { QueryParamClient.class, QueryParamAsyncClient.class }) +public final class QueryParamClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -51,16 +51,16 @@ public final class ChildClientBuilder implements HttpTrait, @Generated private static final Map PROPERTIES - = CoreUtils.getProperties("azure-clientgenerator-core-clientinitialization.properties"); + = CoreUtils.getProperties("_specs_-azure-clientgenerator-core-clientinitialization-defaultclient.properties"); @Generated private final List pipelinePolicies; /** - * Create an instance of the ChildClientBuilder. + * Create an instance of the QueryParamClientBuilder. */ @Generated - public ChildClientBuilder() { + public QueryParamClientBuilder() { this.pipelinePolicies = new ArrayList<>(); } @@ -75,7 +75,7 @@ public ChildClientBuilder() { */ @Generated @Override - public ChildClientBuilder httpClient(HttpClient httpClient) { + public QueryParamClientBuilder httpClient(HttpClient httpClient) { this.httpClient = httpClient; return this; } @@ -91,7 +91,7 @@ public ChildClientBuilder httpClient(HttpClient httpClient) { */ @Generated @Override - public ChildClientBuilder pipeline(HttpPipeline pipeline) { + public QueryParamClientBuilder pipeline(HttpPipeline pipeline) { if (this.pipeline != null && pipeline == null) { LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); } @@ -110,7 +110,7 @@ public ChildClientBuilder pipeline(HttpPipeline pipeline) { */ @Generated @Override - public ChildClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + public QueryParamClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { this.httpLogOptions = httpLogOptions; return this; } @@ -126,7 +126,7 @@ public ChildClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { */ @Generated @Override - public ChildClientBuilder clientOptions(ClientOptions clientOptions) { + public QueryParamClientBuilder clientOptions(ClientOptions clientOptions) { this.clientOptions = clientOptions; return this; } @@ -142,7 +142,7 @@ public ChildClientBuilder clientOptions(ClientOptions clientOptions) { */ @Generated @Override - public ChildClientBuilder retryOptions(RetryOptions retryOptions) { + public QueryParamClientBuilder retryOptions(RetryOptions retryOptions) { this.retryOptions = retryOptions; return this; } @@ -152,7 +152,7 @@ public ChildClientBuilder retryOptions(RetryOptions retryOptions) { */ @Generated @Override - public ChildClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + public QueryParamClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); pipelinePolicies.add(customPolicy); return this; @@ -169,7 +169,7 @@ public ChildClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { */ @Generated @Override - public ChildClientBuilder configuration(Configuration configuration) { + public QueryParamClientBuilder configuration(Configuration configuration) { this.configuration = configuration; return this; } @@ -185,7 +185,7 @@ public ChildClientBuilder configuration(Configuration configuration) { */ @Generated @Override - public ChildClientBuilder endpoint(String endpoint) { + public QueryParamClientBuilder endpoint(String endpoint) { this.endpoint = endpoint; return this; } @@ -200,10 +200,10 @@ public ChildClientBuilder endpoint(String endpoint) { * Sets. * * @param blobName the blobName value. - * @return the ChildClientBuilder. + * @return the QueryParamClientBuilder. */ @Generated - public ChildClientBuilder blobName(String blobName) { + public QueryParamClientBuilder blobName(String blobName) { this.blobName = blobName; return this; } @@ -218,26 +218,26 @@ public ChildClientBuilder blobName(String blobName) { * Sets The retry policy that will attempt to retry failed requests, if applicable. * * @param retryPolicy the retryPolicy value. - * @return the ChildClientBuilder. + * @return the QueryParamClientBuilder. */ @Generated - public ChildClientBuilder retryPolicy(RetryPolicy retryPolicy) { + public QueryParamClientBuilder retryPolicy(RetryPolicy retryPolicy) { this.retryPolicy = retryPolicy; return this; } /** - * Builds an instance of ChildClientImpl with the provided parameters. + * Builds an instance of QueryParamClientImpl with the provided parameters. * - * @return an instance of ChildClientImpl. + * @return an instance of QueryParamClientImpl. */ @Generated - private ChildClientImpl buildInnerClient() { + private QueryParamClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; - ChildClientImpl client = new ChildClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), - localEndpoint, this.blobName); + QueryParamClientImpl client = new QueryParamClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.blobName); return client; } @@ -284,24 +284,24 @@ private HttpPipeline createHttpPipeline() { } /** - * Builds an instance of ChildAsyncClient class. + * Builds an instance of QueryParamAsyncClient class. * - * @return an instance of ChildAsyncClient. + * @return an instance of QueryParamAsyncClient. */ @Generated - public ChildAsyncClient buildAsyncClient() { - return new ChildAsyncClient(buildInnerClient()); + public QueryParamAsyncClient buildAsyncClient() { + return new QueryParamAsyncClient(buildInnerClient()); } /** - * Builds an instance of ChildClient class. + * Builds an instance of QueryParamClient class. * - * @return an instance of ChildClient. + * @return an instance of QueryParamClient. */ @Generated - public ChildClient buildClient() { - return new ChildClient(buildInnerClient()); + public QueryParamClient buildClient() { + return new QueryParamClient(buildInnerClient()); } - private static final ClientLogger LOGGER = new ClientLogger(ChildClientBuilder.class); + private static final ClientLogger LOGGER = new ClientLogger(QueryParamClientBuilder.class); } diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/HeaderParamClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/HeaderParamClientImpl.java similarity index 98% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/HeaderParamClientImpl.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/HeaderParamClientImpl.java index 6f6d472bfb..77e8bce8fa 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/HeaderParamClientImpl.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/HeaderParamClientImpl.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.implementation; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation; import com.azure.core.annotation.BodyParam; import com.azure.core.annotation.ExpectedResponses; @@ -144,7 +144,7 @@ public HeaderParamClientImpl(HttpPipeline httpPipeline, SerializerAdapter serial @Host("{endpoint}") @ServiceInterface(name = "HeaderParamClient") public interface HeaderParamClientService { - @Get("/azure/client-generator-core/client-initialization/header-param/with-query") + @Get("/azure/client-generator-core/client-initialization/default/header-param/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -153,7 +153,7 @@ public interface HeaderParamClientService { Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, @QueryParam("id") String id, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/header-param/with-query") + @Get("/azure/client-generator-core/client-initialization/default/header-param/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -162,7 +162,7 @@ Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderPa Response withQuerySync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, @QueryParam("id") String id, RequestOptions requestOptions, Context context); - @Post("/azure/client-generator-core/client-initialization/header-param/with-body") + @Post("/azure/client-generator-core/client-initialization/default/header-param/with-body") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -172,7 +172,7 @@ Mono> withBody(@HostParam("endpoint") String endpoint, @HeaderPar @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); - @Post("/azure/client-generator-core/client-initialization/header-param/with-body") + @Post("/azure/client-generator-core/client-initialization/default/header-param/with-body") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/MixedParamsClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/MixedParamsClientImpl.java similarity index 98% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/MixedParamsClientImpl.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/MixedParamsClientImpl.java index 0c38becf5c..271682bc70 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/MixedParamsClientImpl.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/MixedParamsClientImpl.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.implementation; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation; import com.azure.core.annotation.BodyParam; import com.azure.core.annotation.ExpectedResponses; @@ -144,7 +144,7 @@ public MixedParamsClientImpl(HttpPipeline httpPipeline, SerializerAdapter serial @Host("{endpoint}") @ServiceInterface(name = "MixedParamsClient") public interface MixedParamsClientService { - @Get("/azure/client-generator-core/client-initialization/mixed-params/with-query") + @Get("/azure/client-generator-core/client-initialization/default/mixed-params/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -154,7 +154,7 @@ Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderPa @QueryParam("region") String region, @QueryParam("id") String id, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/mixed-params/with-query") + @Get("/azure/client-generator-core/client-initialization/default/mixed-params/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -164,7 +164,7 @@ Response withQuerySync(@HostParam("endpoint") String endpoint, @HeaderPara @QueryParam("region") String region, @QueryParam("id") String id, RequestOptions requestOptions, Context context); - @Post("/azure/client-generator-core/client-initialization/mixed-params/with-body") + @Post("/azure/client-generator-core/client-initialization/default/mixed-params/with-body") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -174,7 +174,7 @@ Mono> withBody(@HostParam("endpoint") String endpoint, @HeaderPar @QueryParam("region") String region, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); - @Post("/azure/client-generator-core/client-initialization/mixed-params/with-body") + @Post("/azure/client-generator-core/client-initialization/default/mixed-params/with-body") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/MultipleParamsClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/MultipleParamsClientImpl.java similarity index 98% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/MultipleParamsClientImpl.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/MultipleParamsClientImpl.java index f3f2e5d8a2..5481937e75 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/MultipleParamsClientImpl.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/MultipleParamsClientImpl.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.implementation; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation; import com.azure.core.annotation.BodyParam; import com.azure.core.annotation.ExpectedResponses; @@ -162,7 +162,7 @@ public MultipleParamsClientImpl(HttpPipeline httpPipeline, SerializerAdapter ser @Host("{endpoint}") @ServiceInterface(name = "MultipleParamsClient") public interface MultipleParamsClientService { - @Get("/azure/client-generator-core/client-initialization/multiple-params/with-query") + @Get("/azure/client-generator-core/client-initialization/default/multiple-params/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -172,7 +172,7 @@ Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderPa @QueryParam("region") String region, @QueryParam("id") String id, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/multiple-params/with-query") + @Get("/azure/client-generator-core/client-initialization/default/multiple-params/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -182,7 +182,7 @@ Response withQuerySync(@HostParam("endpoint") String endpoint, @HeaderPara @QueryParam("region") String region, @QueryParam("id") String id, RequestOptions requestOptions, Context context); - @Post("/azure/client-generator-core/client-initialization/multiple-params/with-body") + @Post("/azure/client-generator-core/client-initialization/default/multiple-params/with-body") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -192,7 +192,7 @@ Mono> withBody(@HostParam("endpoint") String endpoint, @HeaderPar @QueryParam("region") String region, @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); - @Post("/azure/client-generator-core/client-initialization/multiple-params/with-body") + @Post("/azure/client-generator-core/client-initialization/default/multiple-params/with-body") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/ParamAliasClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/ParamAliasClientImpl.java similarity index 97% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/ParamAliasClientImpl.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/ParamAliasClientImpl.java index 0c1d58cfbc..4ac7c32b57 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/ParamAliasClientImpl.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/ParamAliasClientImpl.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.implementation; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation; import com.azure.core.annotation.ExpectedResponses; import com.azure.core.annotation.Get; @@ -140,7 +140,7 @@ public ParamAliasClientImpl(HttpPipeline httpPipeline, SerializerAdapter seriali @Host("{endpoint}") @ServiceInterface(name = "ParamAliasClient") public interface ParamAliasClientService { - @Get("/azure/client-generator-core/client-initialization/param-alias/{blob}/with-aliased-name") + @Get("/azure/client-generator-core/client-initialization/default/param-alias/{blob}/with-aliased-name") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -149,7 +149,7 @@ public interface ParamAliasClientService { Mono> withAliasedName(@HostParam("endpoint") String endpoint, @PathParam("blob") String blobName, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/param-alias/{blob}/with-aliased-name") + @Get("/azure/client-generator-core/client-initialization/default/param-alias/{blob}/with-aliased-name") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -158,7 +158,7 @@ Mono> withAliasedName(@HostParam("endpoint") String endpoint, @Pa Response withAliasedNameSync(@HostParam("endpoint") String endpoint, @PathParam("blob") String blobName, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/param-alias/{blobName}/with-original-name") + @Get("/azure/client-generator-core/client-initialization/default/param-alias/{blobName}/with-original-name") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -167,7 +167,7 @@ Response withAliasedNameSync(@HostParam("endpoint") String endpoint, @Path Mono> withOriginalName(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/param-alias/{blobName}/with-original-name") + @Get("/azure/client-generator-core/client-initialization/default/param-alias/{blobName}/with-original-name") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/PathParamClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/PathParamClientImpl.java similarity index 98% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/PathParamClientImpl.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/PathParamClientImpl.java index 7fd730e570..3da147ba50 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/PathParamClientImpl.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/PathParamClientImpl.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.implementation; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation; import com.azure.core.annotation.Delete; import com.azure.core.annotation.ExpectedResponses; @@ -143,7 +143,7 @@ public PathParamClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializ @Host("{endpoint}") @ServiceInterface(name = "PathParamClient") public interface PathParamClientService { - @Get("/azure/client-generator-core/client-initialization/path/{blobName}/with-query") + @Get("/azure/client-generator-core/client-initialization/default/path/{blobName}/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -152,7 +152,7 @@ public interface PathParamClientService { Mono> withQuery(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/path/{blobName}/with-query") + @Get("/azure/client-generator-core/client-initialization/default/path/{blobName}/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -161,7 +161,7 @@ Mono> withQuery(@HostParam("endpoint") String endpoint, @PathPara Response withQuerySync(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/path/{blobName}/get-standalone") + @Get("/azure/client-generator-core/client-initialization/default/path/{blobName}/get-standalone") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -171,7 +171,7 @@ Mono> getStandalone(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/path/{blobName}/get-standalone") + @Get("/azure/client-generator-core/client-initialization/default/path/{blobName}/get-standalone") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -181,7 +181,7 @@ Response getStandaloneSync(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Delete("/azure/client-generator-core/client-initialization/path/{blobName}") + @Delete("/azure/client-generator-core/client-initialization/default/path/{blobName}") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -190,7 +190,7 @@ Response getStandaloneSync(@HostParam("endpoint") String endpoint, Mono> deleteStandalone(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); - @Delete("/azure/client-generator-core/client-initialization/path/{blobName}") + @Delete("/azure/client-generator-core/client-initialization/default/path/{blobName}") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/QueryParamClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/QueryParamClientImpl.java new file mode 100644 index 0000000000..98e28569e3 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/QueryParamClientImpl.java @@ -0,0 +1,335 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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; + +/** + * Initializes a new instance of the QueryParamClient type. + */ +public final class QueryParamClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueryParamClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String blobName; + + /** + * Gets. + * + * @return the blobName value. + */ + public String getBlobName() { + return this.blobName; + } + + /** + * 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 QueryParamClient client. + * + * @param endpoint Service host. + * @param blobName + */ + public QueryParamClientImpl(String endpoint, String blobName) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of QueryParamClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param blobName + */ + public QueryParamClientImpl(HttpPipeline httpPipeline, String endpoint, String blobName) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of QueryParamClient 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 blobName + */ + public QueryParamClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, + String blobName) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.blobName = blobName; + this.service = RestProxy.create(QueryParamClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for QueryParamClient to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "QueryParamClient") + public interface QueryParamClientService { + @Get("/azure/client-generator-core/client-initialization/default/query/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @QueryParam("blobName") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/default/query/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @QueryParam("blobName") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/default/query/get-standalone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/default/query/get-standalone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/default/query/delete-resource") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/default/query/delete-resource") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withQuery(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStandaloneWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getStandalone(this.getEndpoint(), this.getBlobName(), accept, requestOptions, context)); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStandaloneWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getStandaloneSync(this.getEndpoint(), this.getBlobName(), accept, requestOptions, Context.NONE); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.deleteStandalone(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/package-info.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/package-info.java new file mode 100644 index 0000000000..95c5a22793 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/implementation/package-info.java @@ -0,0 +1,11 @@ +// 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 DefaultClient. + * Test for client initialization decorator - moving parameters from method to client level. + * + */ +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.implementation; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/BlobProperties.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/BlobProperties.java similarity index 98% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/BlobProperties.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/BlobProperties.java index 06b73553c8..d89c3c1bb2 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/BlobProperties.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/BlobProperties.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.models; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/Input.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/Input.java similarity index 96% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/Input.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/Input.java index 3b0429b115..850a0a709a 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/Input.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/Input.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.models; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/WithBodyRequest.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/WithBodyRequest.java similarity index 96% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/WithBodyRequest.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/WithBodyRequest.java index f8ff087072..f90a86e77a 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/WithBodyRequest.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/WithBodyRequest.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.models; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/package-info.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/package-info.java similarity index 69% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/package-info.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/package-info.java index b43dea52e0..029a6aa22c 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/package-info.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/models/package-info.java @@ -4,8 +4,8 @@ /** * - * Package containing the implementations for Service. + * Package containing the data models for DefaultClient. * Test for client initialization decorator - moving parameters from method to client level. * */ -package azure.clientgenerator.core.clientinitialization.implementation; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.models; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/package-info.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/package-info.java similarity index 70% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/package-info.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/package-info.java index c2c747b3cf..59ca2121be 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/models/package-info.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/package-info.java @@ -4,8 +4,8 @@ /** * - * Package containing the data models for Service. + * Package containing the classes for DefaultClient. * Test for client initialization decorator - moving parameters from method to client level. * */ -package azure.clientgenerator.core.clientinitialization.models; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient; diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithHeaderAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithHeaderAsyncClient.java new file mode 100644 index 0000000000..db261f11fb --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithHeaderAsyncClient.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithHeaderClientImpl; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyNestedWithHeaderClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithHeaderClientBuilder.class, isAsync = true) +public final class IndividuallyNestedWithHeaderAsyncClient { + @Generated + private final IndividuallyNestedWithHeaderClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithHeaderAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithHeaderAsyncClient(IndividuallyNestedWithHeaderClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(requestOptions); + } + + /** + * The getStandalone 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> getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(requestOptions); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone 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 getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithHeaderClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithHeaderClient.java new file mode 100644 index 0000000000..1c3b865584 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithHeaderClient.java @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithHeaderClientImpl; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyNestedWithHeaderClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithHeaderClientBuilder.class) +public final class IndividuallyNestedWithHeaderClient { + @Generated + private final IndividuallyNestedWithHeaderClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithHeaderClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithHeaderClient(IndividuallyNestedWithHeaderClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(requestOptions); + } + + /** + * The getStandalone 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 getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(requestOptions); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The getStandalone 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 getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + getStandaloneWithResponse(requestOptions).getValue(); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithHeaderClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithHeaderClientBuilder.java new file mode 100644 index 0000000000..409a296c73 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithHeaderClientBuilder.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithHeaderClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyNestedWithHeaderClient type. + */ +@ServiceClientBuilder( + serviceClients = { IndividuallyNestedWithHeaderClient.class, IndividuallyNestedWithHeaderAsyncClient.class }) +public final class IndividuallyNestedWithHeaderClientBuilder 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyNestedWithHeaderClientBuilder. + */ + @Generated + public IndividuallyNestedWithHeaderClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithHeaderClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithHeaderClientBuilder 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 IndividuallyNestedWithHeaderClientBuilder 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 IndividuallyNestedWithHeaderClientBuilder 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 IndividuallyNestedWithHeaderClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithHeaderClientBuilder 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 IndividuallyNestedWithHeaderClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithHeaderClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String name; + + /** + * Sets. + * + * @param name the name value. + * @return the IndividuallyNestedWithHeaderClientBuilder. + */ + @Generated + public IndividuallyNestedWithHeaderClientBuilder name(String name) { + this.name = name; + 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 IndividuallyNestedWithHeaderClientBuilder. + */ + @Generated + public IndividuallyNestedWithHeaderClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyNestedWithHeaderClientImpl with the provided parameters. + * + * @return an instance of IndividuallyNestedWithHeaderClientImpl. + */ + @Generated + private IndividuallyNestedWithHeaderClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyNestedWithHeaderClientImpl client = new IndividuallyNestedWithHeaderClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.name); + 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(name, "'name' 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 IndividuallyNestedWithHeaderAsyncClient class. + * + * @return an instance of IndividuallyNestedWithHeaderAsyncClient. + */ + @Generated + public IndividuallyNestedWithHeaderAsyncClient buildAsyncClient() { + return new IndividuallyNestedWithHeaderAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyNestedWithHeaderClient class. + * + * @return an instance of IndividuallyNestedWithHeaderClient. + */ + @Generated + public IndividuallyNestedWithHeaderClient buildClient() { + return new IndividuallyNestedWithHeaderClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyNestedWithHeaderClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMixedAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMixedAsyncClient.java new file mode 100644 index 0000000000..53c3cee677 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMixedAsyncClient.java @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithMixedClientImpl; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyNestedWithMixedClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithMixedClientBuilder.class, isAsync = true) +public final class IndividuallyNestedWithMixedAsyncClient { + @Generated + private final IndividuallyNestedWithMixedClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithMixedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithMixedAsyncClient(IndividuallyNestedWithMixedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param region The region 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> withQueryWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(region, requestOptions); + } + + /** + * The getStandalone operation. + * + * @param region The region 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> getStandaloneWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(region, requestOptions); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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> deleteStandaloneWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(region, requestOptions); + } + + /** + * The withQuery operation. + * + * @param region The region parameter. + * @param format The format 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 withQuery(String region, String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery operation. + * + * @param region The region 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 withQuery(String region) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone operation. + * + * @param region The region 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 getStandalone(String region) { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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 deleteStandalone(String region) { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMixedClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMixedClient.java new file mode 100644 index 0000000000..ef09cdbfc1 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMixedClient.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithMixedClientImpl; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyNestedWithMixedClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithMixedClientBuilder.class) +public final class IndividuallyNestedWithMixedClient { + @Generated + private final IndividuallyNestedWithMixedClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithMixedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithMixedClient(IndividuallyNestedWithMixedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param region The region 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 withQueryWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(region, requestOptions); + } + + /** + * The getStandalone operation. + * + * @param region The region 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 getStandaloneWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(region, requestOptions); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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 deleteStandaloneWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(region, requestOptions); + } + + /** + * The withQuery operation. + * + * @param region The region parameter. + * @param format The format 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 withQuery(String region, String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(region, requestOptions).getValue(); + } + + /** + * The withQuery operation. + * + * @param region The region 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 withQuery(String region) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(region, requestOptions).getValue(); + } + + /** + * The getStandalone operation. + * + * @param region The region 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 getStandalone(String region) { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + getStandaloneWithResponse(region, requestOptions).getValue(); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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 deleteStandalone(String region) { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(region, requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMixedClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMixedClientBuilder.java new file mode 100644 index 0000000000..33cef9e20a --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMixedClientBuilder.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithMixedClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyNestedWithMixedClient type. + */ +@ServiceClientBuilder( + serviceClients = { IndividuallyNestedWithMixedClient.class, IndividuallyNestedWithMixedAsyncClient.class }) +public final class IndividuallyNestedWithMixedClientBuilder 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyNestedWithMixedClientBuilder. + */ + @Generated + public IndividuallyNestedWithMixedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithMixedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithMixedClientBuilder 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 IndividuallyNestedWithMixedClientBuilder 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 IndividuallyNestedWithMixedClientBuilder 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 IndividuallyNestedWithMixedClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithMixedClientBuilder 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 IndividuallyNestedWithMixedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithMixedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String name; + + /** + * Sets. + * + * @param name the name value. + * @return the IndividuallyNestedWithMixedClientBuilder. + */ + @Generated + public IndividuallyNestedWithMixedClientBuilder name(String name) { + this.name = name; + 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 IndividuallyNestedWithMixedClientBuilder. + */ + @Generated + public IndividuallyNestedWithMixedClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyNestedWithMixedClientImpl with the provided parameters. + * + * @return an instance of IndividuallyNestedWithMixedClientImpl. + */ + @Generated + private IndividuallyNestedWithMixedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyNestedWithMixedClientImpl client = new IndividuallyNestedWithMixedClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.name); + 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(name, "'name' 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 IndividuallyNestedWithMixedAsyncClient class. + * + * @return an instance of IndividuallyNestedWithMixedAsyncClient. + */ + @Generated + public IndividuallyNestedWithMixedAsyncClient buildAsyncClient() { + return new IndividuallyNestedWithMixedAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyNestedWithMixedClient class. + * + * @return an instance of IndividuallyNestedWithMixedClient. + */ + @Generated + public IndividuallyNestedWithMixedClient buildClient() { + return new IndividuallyNestedWithMixedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyNestedWithMixedClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMultipleAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMultipleAsyncClient.java new file mode 100644 index 0000000000..2a6bc41f29 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMultipleAsyncClient.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithMultipleClientImpl; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyNestedWithMultipleClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithMultipleClientBuilder.class, isAsync = true) +public final class IndividuallyNestedWithMultipleAsyncClient { + @Generated + private final IndividuallyNestedWithMultipleClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithMultipleAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithMultipleAsyncClient(IndividuallyNestedWithMultipleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(requestOptions); + } + + /** + * The getStandalone 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> getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(requestOptions); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone 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 getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMultipleClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMultipleClient.java new file mode 100644 index 0000000000..87001b2643 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMultipleClient.java @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithMultipleClientImpl; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyNestedWithMultipleClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithMultipleClientBuilder.class) +public final class IndividuallyNestedWithMultipleClient { + @Generated + private final IndividuallyNestedWithMultipleClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithMultipleClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithMultipleClient(IndividuallyNestedWithMultipleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(requestOptions); + } + + /** + * The getStandalone 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 getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(requestOptions); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The getStandalone 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 getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + getStandaloneWithResponse(requestOptions).getValue(); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMultipleClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMultipleClientBuilder.java new file mode 100644 index 0000000000..903427389f --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithMultipleClientBuilder.java @@ -0,0 +1,329 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithMultipleClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyNestedWithMultipleClient type. + */ +@ServiceClientBuilder( + serviceClients = { IndividuallyNestedWithMultipleClient.class, IndividuallyNestedWithMultipleAsyncClient.class }) +public final class IndividuallyNestedWithMultipleClientBuilder + 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyNestedWithMultipleClientBuilder. + */ + @Generated + public IndividuallyNestedWithMultipleClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithMultipleClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithMultipleClientBuilder 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 IndividuallyNestedWithMultipleClientBuilder 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 IndividuallyNestedWithMultipleClientBuilder 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 IndividuallyNestedWithMultipleClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithMultipleClientBuilder 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 IndividuallyNestedWithMultipleClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithMultipleClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String name; + + /** + * Sets. + * + * @param name the name value. + * @return the IndividuallyNestedWithMultipleClientBuilder. + */ + @Generated + public IndividuallyNestedWithMultipleClientBuilder name(String name) { + this.name = name; + return this; + } + + /* + * + */ + @Generated + private String region; + + /** + * Sets. + * + * @param region the region value. + * @return the IndividuallyNestedWithMultipleClientBuilder. + */ + @Generated + public IndividuallyNestedWithMultipleClientBuilder region(String region) { + this.region = region; + 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 IndividuallyNestedWithMultipleClientBuilder. + */ + @Generated + public IndividuallyNestedWithMultipleClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyNestedWithMultipleClientImpl with the provided parameters. + * + * @return an instance of IndividuallyNestedWithMultipleClientImpl. + */ + @Generated + private IndividuallyNestedWithMultipleClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyNestedWithMultipleClientImpl client = new IndividuallyNestedWithMultipleClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.name, this.region); + 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(name, "'name' cannot be null."); + Objects.requireNonNull(region, "'region' 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 IndividuallyNestedWithMultipleAsyncClient class. + * + * @return an instance of IndividuallyNestedWithMultipleAsyncClient. + */ + @Generated + public IndividuallyNestedWithMultipleAsyncClient buildAsyncClient() { + return new IndividuallyNestedWithMultipleAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyNestedWithMultipleClient class. + * + * @return an instance of IndividuallyNestedWithMultipleClient. + */ + @Generated + public IndividuallyNestedWithMultipleClient buildClient() { + return new IndividuallyNestedWithMultipleClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyNestedWithMultipleClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithParamAliasAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithParamAliasAsyncClient.java new file mode 100644 index 0000000000..3af980f242 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithParamAliasAsyncClient.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithParamAliasClientImpl; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyNestedWithParamAliasClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithParamAliasClientBuilder.class, isAsync = true) +public final class IndividuallyNestedWithParamAliasAsyncClient { + @Generated + private final IndividuallyNestedWithParamAliasClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithParamAliasAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithParamAliasAsyncClient(IndividuallyNestedWithParamAliasClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAliasedName 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> withAliasedNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withAliasedNameWithResponseAsync(requestOptions); + } + + /** + * The withOriginalName 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> withOriginalNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withOriginalNameWithResponseAsync(requestOptions); + } + + /** + * The withAliasedName 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 withAliasedName() { + // Generated convenience method for withAliasedNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAliasedNameWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withOriginalName 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 withOriginalName() { + // Generated convenience method for withOriginalNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withOriginalNameWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithParamAliasClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithParamAliasClient.java new file mode 100644 index 0000000000..2ca0e3612a --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithParamAliasClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithParamAliasClientImpl; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyNestedWithParamAliasClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithParamAliasClientBuilder.class) +public final class IndividuallyNestedWithParamAliasClient { + @Generated + private final IndividuallyNestedWithParamAliasClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithParamAliasClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithParamAliasClient(IndividuallyNestedWithParamAliasClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAliasedName 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 withAliasedNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withAliasedNameWithResponse(requestOptions); + } + + /** + * The withOriginalName 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 withOriginalNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withOriginalNameWithResponse(requestOptions); + } + + /** + * The withAliasedName 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 withAliasedName() { + // Generated convenience method for withAliasedNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAliasedNameWithResponse(requestOptions).getValue(); + } + + /** + * The withOriginalName 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 withOriginalName() { + // Generated convenience method for withOriginalNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + withOriginalNameWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithParamAliasClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithParamAliasClientBuilder.java new file mode 100644 index 0000000000..f79386da36 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithParamAliasClientBuilder.java @@ -0,0 +1,312 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithParamAliasClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyNestedWithParamAliasClient type. + */ +@ServiceClientBuilder( + serviceClients = { + IndividuallyNestedWithParamAliasClient.class, + IndividuallyNestedWithParamAliasAsyncClient.class }) +public final class IndividuallyNestedWithParamAliasClientBuilder + 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyNestedWithParamAliasClientBuilder. + */ + @Generated + public IndividuallyNestedWithParamAliasClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithParamAliasClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithParamAliasClientBuilder 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 IndividuallyNestedWithParamAliasClientBuilder 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 IndividuallyNestedWithParamAliasClientBuilder 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 IndividuallyNestedWithParamAliasClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithParamAliasClientBuilder 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 IndividuallyNestedWithParamAliasClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithParamAliasClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String blobName; + + /** + * Sets. + * + * @param blobName the blobName value. + * @return the IndividuallyNestedWithParamAliasClientBuilder. + */ + @Generated + public IndividuallyNestedWithParamAliasClientBuilder blobName(String blobName) { + this.blobName = blobName; + 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 IndividuallyNestedWithParamAliasClientBuilder. + */ + @Generated + public IndividuallyNestedWithParamAliasClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyNestedWithParamAliasClientImpl with the provided parameters. + * + * @return an instance of IndividuallyNestedWithParamAliasClientImpl. + */ + @Generated + private IndividuallyNestedWithParamAliasClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyNestedWithParamAliasClientImpl client = new IndividuallyNestedWithParamAliasClientImpl( + localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.blobName); + 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(blobName, "'blobName' 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 IndividuallyNestedWithParamAliasAsyncClient class. + * + * @return an instance of IndividuallyNestedWithParamAliasAsyncClient. + */ + @Generated + public IndividuallyNestedWithParamAliasAsyncClient buildAsyncClient() { + return new IndividuallyNestedWithParamAliasAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyNestedWithParamAliasClient class. + * + * @return an instance of IndividuallyNestedWithParamAliasClient. + */ + @Generated + public IndividuallyNestedWithParamAliasClient buildClient() { + return new IndividuallyNestedWithParamAliasClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyNestedWithParamAliasClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithPathAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithPathAsyncClient.java new file mode 100644 index 0000000000..de5fabcb75 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithPathAsyncClient.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithPathClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.models.BlobProperties; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyNestedWithPathClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithPathClientBuilder.class, isAsync = true) +public final class IndividuallyNestedWithPathAsyncClient { + @Generated + private final IndividuallyNestedWithPathClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithPathAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithPathAsyncClient(IndividuallyNestedWithPathClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(requestOptions); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(requestOptions); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone 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 properties of a blob on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BlobProperties.class)); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithPathClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithPathClient.java new file mode 100644 index 0000000000..164c42056a --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithPathClient.java @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithPathClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.models.BlobProperties; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyNestedWithPathClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithPathClientBuilder.class) +public final class IndividuallyNestedWithPathClient { + @Generated + private final IndividuallyNestedWithPathClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithPathClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithPathClient(IndividuallyNestedWithPathClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(requestOptions); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(requestOptions); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The getStandalone 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 properties of a blob. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BlobProperties getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).getValue().toObject(BlobProperties.class); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithPathClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithPathClientBuilder.java new file mode 100644 index 0000000000..717cfd3c82 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithPathClientBuilder.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithPathClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyNestedWithPathClient type. + */ +@ServiceClientBuilder( + serviceClients = { IndividuallyNestedWithPathClient.class, IndividuallyNestedWithPathAsyncClient.class }) +public final class IndividuallyNestedWithPathClientBuilder 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyNestedWithPathClientBuilder. + */ + @Generated + public IndividuallyNestedWithPathClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithPathClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithPathClientBuilder 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 IndividuallyNestedWithPathClientBuilder 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 IndividuallyNestedWithPathClientBuilder 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 IndividuallyNestedWithPathClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithPathClientBuilder 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 IndividuallyNestedWithPathClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithPathClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String blobName; + + /** + * Sets. + * + * @param blobName the blobName value. + * @return the IndividuallyNestedWithPathClientBuilder. + */ + @Generated + public IndividuallyNestedWithPathClientBuilder blobName(String blobName) { + this.blobName = blobName; + 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 IndividuallyNestedWithPathClientBuilder. + */ + @Generated + public IndividuallyNestedWithPathClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyNestedWithPathClientImpl with the provided parameters. + * + * @return an instance of IndividuallyNestedWithPathClientImpl. + */ + @Generated + private IndividuallyNestedWithPathClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyNestedWithPathClientImpl client = new IndividuallyNestedWithPathClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.blobName); + 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(blobName, "'blobName' 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 IndividuallyNestedWithPathAsyncClient class. + * + * @return an instance of IndividuallyNestedWithPathAsyncClient. + */ + @Generated + public IndividuallyNestedWithPathAsyncClient buildAsyncClient() { + return new IndividuallyNestedWithPathAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyNestedWithPathClient class. + * + * @return an instance of IndividuallyNestedWithPathClient. + */ + @Generated + public IndividuallyNestedWithPathClient buildClient() { + return new IndividuallyNestedWithPathClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyNestedWithPathClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithQueryAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithQueryAsyncClient.java new file mode 100644 index 0000000000..411ab4f040 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithQueryAsyncClient.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithQueryClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.models.BlobProperties; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyNestedWithQueryClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithQueryClientBuilder.class, isAsync = true) +public final class IndividuallyNestedWithQueryAsyncClient { + @Generated + private final IndividuallyNestedWithQueryClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithQueryAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithQueryAsyncClient(IndividuallyNestedWithQueryClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(requestOptions); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(requestOptions); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone 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 properties of a blob on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BlobProperties.class)); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithQueryClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithQueryClient.java new file mode 100644 index 0000000000..f70932d97c --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithQueryClient.java @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithQueryClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.models.BlobProperties; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyNestedWithQueryClient type. + */ +@ServiceClient(builder = IndividuallyNestedWithQueryClientBuilder.class) +public final class IndividuallyNestedWithQueryClient { + @Generated + private final IndividuallyNestedWithQueryClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyNestedWithQueryClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyNestedWithQueryClient(IndividuallyNestedWithQueryClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(requestOptions); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(requestOptions); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The getStandalone 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 properties of a blob. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BlobProperties getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).getValue().toObject(BlobProperties.class); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithQueryClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithQueryClientBuilder.java new file mode 100644 index 0000000000..d6fb4e21a3 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/IndividuallyNestedWithQueryClientBuilder.java @@ -0,0 +1,309 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation.IndividuallyNestedWithQueryClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyNestedWithQueryClient type. + */ +@ServiceClientBuilder( + serviceClients = { IndividuallyNestedWithQueryClient.class, IndividuallyNestedWithQueryAsyncClient.class }) +public final class IndividuallyNestedWithQueryClientBuilder 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyNestedWithQueryClientBuilder. + */ + @Generated + public IndividuallyNestedWithQueryClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithQueryClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithQueryClientBuilder 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 IndividuallyNestedWithQueryClientBuilder 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 IndividuallyNestedWithQueryClientBuilder 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 IndividuallyNestedWithQueryClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithQueryClientBuilder 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 IndividuallyNestedWithQueryClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyNestedWithQueryClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String blobName; + + /** + * Sets. + * + * @param blobName the blobName value. + * @return the IndividuallyNestedWithQueryClientBuilder. + */ + @Generated + public IndividuallyNestedWithQueryClientBuilder blobName(String blobName) { + this.blobName = blobName; + 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 IndividuallyNestedWithQueryClientBuilder. + */ + @Generated + public IndividuallyNestedWithQueryClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyNestedWithQueryClientImpl with the provided parameters. + * + * @return an instance of IndividuallyNestedWithQueryClientImpl. + */ + @Generated + private IndividuallyNestedWithQueryClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyNestedWithQueryClientImpl client = new IndividuallyNestedWithQueryClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.blobName); + 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(blobName, "'blobName' 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 IndividuallyNestedWithQueryAsyncClient class. + * + * @return an instance of IndividuallyNestedWithQueryAsyncClient. + */ + @Generated + public IndividuallyNestedWithQueryAsyncClient buildAsyncClient() { + return new IndividuallyNestedWithQueryAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyNestedWithQueryClient class. + * + * @return an instance of IndividuallyNestedWithQueryClient. + */ + @Generated + public IndividuallyNestedWithQueryClient buildClient() { + return new IndividuallyNestedWithQueryClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyNestedWithQueryClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithHeaderClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithHeaderClientImpl.java new file mode 100644 index 0000000000..5e3f94b1cf --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithHeaderClientImpl.java @@ -0,0 +1,306 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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 IndividuallyNestedWithHeaderClient type. + */ +public final class IndividuallyNestedWithHeaderClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyNestedWithHeaderClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String name; + + /** + * Gets. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + * 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 IndividuallyNestedWithHeaderClient client. + * + * @param endpoint Service host. + * @param name + */ + public IndividuallyNestedWithHeaderClientImpl(String endpoint, String name) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name); + } + + /** + * Initializes an instance of IndividuallyNestedWithHeaderClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param name + */ + public IndividuallyNestedWithHeaderClientImpl(HttpPipeline httpPipeline, String endpoint, String name) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name); + } + + /** + * Initializes an instance of IndividuallyNestedWithHeaderClient 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 name + */ + public IndividuallyNestedWithHeaderClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String name) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.name = name; + this.service = RestProxy.create(IndividuallyNestedWithHeaderClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyNestedWithHeaderClient to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyNestedWithHeaderClient") + public interface IndividuallyNestedWithHeaderClientService { + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-header/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-header/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-header/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-header/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually-header/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually-header/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withQuery(this.getEndpoint(), this.getName(), requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getName(), requestOptions, Context.NONE); + } + + /** + * The getStandalone 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> getStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.getStandalone(this.getEndpoint(), this.getName(), requestOptions, context)); + } + + /** + * The getStandalone 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 getStandaloneWithResponse(RequestOptions requestOptions) { + return service.getStandaloneSync(this.getEndpoint(), this.getName(), requestOptions, Context.NONE); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.deleteStandalone(this.getEndpoint(), this.getName(), requestOptions, context)); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getName(), requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithMixedClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithMixedClientImpl.java new file mode 100644 index 0000000000..dfba5ce457 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithMixedClientImpl.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.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 IndividuallyNestedWithMixedClient type. + */ +public final class IndividuallyNestedWithMixedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyNestedWithMixedClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String name; + + /** + * Gets. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + * 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 IndividuallyNestedWithMixedClient client. + * + * @param endpoint Service host. + * @param name + */ + public IndividuallyNestedWithMixedClientImpl(String endpoint, String name) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name); + } + + /** + * Initializes an instance of IndividuallyNestedWithMixedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param name + */ + public IndividuallyNestedWithMixedClientImpl(HttpPipeline httpPipeline, String endpoint, String name) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name); + } + + /** + * Initializes an instance of IndividuallyNestedWithMixedClient 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 name + */ + public IndividuallyNestedWithMixedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String name) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.name = name; + this.service = RestProxy.create(IndividuallyNestedWithMixedClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyNestedWithMixedClient to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyNestedWithMixedClient") + public interface IndividuallyNestedWithMixedClientService { + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-mixed/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-mixed/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-mixed/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-mixed/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually-mixed/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually-mixed/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param region The region 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> withQueryWithResponseAsync(String region, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withQuery(this.getEndpoint(), this.getName(), region, requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param region The region 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 withQueryWithResponse(String region, RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getName(), region, requestOptions, Context.NONE); + } + + /** + * The getStandalone operation. + * + * @param region The region 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> getStandaloneWithResponseAsync(String region, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.getStandalone(this.getEndpoint(), this.getName(), region, requestOptions, context)); + } + + /** + * The getStandalone operation. + * + * @param region The region 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 getStandaloneWithResponse(String region, RequestOptions requestOptions) { + return service.getStandaloneSync(this.getEndpoint(), this.getName(), region, requestOptions, Context.NONE); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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> deleteStandaloneWithResponseAsync(String region, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.deleteStandalone(this.getEndpoint(), this.getName(), region, requestOptions, context)); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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 deleteStandaloneWithResponse(String region, RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getName(), region, requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithMultipleClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithMultipleClientImpl.java new file mode 100644 index 0000000000..f310a4e56c --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithMultipleClientImpl.java @@ -0,0 +1,328 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.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 IndividuallyNestedWithMultipleClient type. + */ +public final class IndividuallyNestedWithMultipleClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyNestedWithMultipleClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String name; + + /** + * Gets. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + */ + private final String region; + + /** + * Gets. + * + * @return the region value. + */ + public String getRegion() { + return this.region; + } + + /** + * 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 IndividuallyNestedWithMultipleClient client. + * + * @param endpoint Service host. + * @param name + * @param region + */ + public IndividuallyNestedWithMultipleClientImpl(String endpoint, String name, String region) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name, region); + } + + /** + * Initializes an instance of IndividuallyNestedWithMultipleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param name + * @param region + */ + public IndividuallyNestedWithMultipleClientImpl(HttpPipeline httpPipeline, String endpoint, String name, + String region) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name, region); + } + + /** + * Initializes an instance of IndividuallyNestedWithMultipleClient 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 name + * @param region + */ + public IndividuallyNestedWithMultipleClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String name, String region) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.name = name; + this.region = region; + this.service = RestProxy.create(IndividuallyNestedWithMultipleClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyNestedWithMultipleClient to be used by the proxy service + * to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyNestedWithMultipleClient") + public interface IndividuallyNestedWithMultipleClientService { + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-multiple/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-multiple/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-multiple/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-multiple/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually-multiple/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually-multiple/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withQuery(this.getEndpoint(), this.getName(), this.getRegion(), + requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getName(), this.getRegion(), requestOptions, + Context.NONE); + } + + /** + * The getStandalone 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> getStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.getStandalone(this.getEndpoint(), this.getName(), + this.getRegion(), requestOptions, context)); + } + + /** + * The getStandalone 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 getStandaloneWithResponse(RequestOptions requestOptions) { + return service.getStandaloneSync(this.getEndpoint(), this.getName(), this.getRegion(), requestOptions, + Context.NONE); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.deleteStandalone(this.getEndpoint(), this.getName(), + this.getRegion(), requestOptions, context)); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getName(), this.getRegion(), requestOptions, + Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithParamAliasClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithParamAliasClientImpl.java new file mode 100644 index 0000000000..6d43e49794 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithParamAliasClientImpl.java @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.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 IndividuallyNestedWithParamAliasClient type. + */ +public final class IndividuallyNestedWithParamAliasClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyNestedWithParamAliasClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String blobName; + + /** + * Gets. + * + * @return the blobName value. + */ + public String getBlobName() { + return this.blobName; + } + + /** + * 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 IndividuallyNestedWithParamAliasClient client. + * + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyNestedWithParamAliasClientImpl(String endpoint, String blobName) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyNestedWithParamAliasClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyNestedWithParamAliasClientImpl(HttpPipeline httpPipeline, String endpoint, String blobName) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyNestedWithParamAliasClient 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 blobName + */ + public IndividuallyNestedWithParamAliasClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String blobName) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.blobName = blobName; + this.service = RestProxy.create(IndividuallyNestedWithParamAliasClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyNestedWithParamAliasClient to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyNestedWithParamAliasClient") + public interface IndividuallyNestedWithParamAliasClientService { + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-param-alias/{blob}/with-aliased-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAliasedName(@HostParam("endpoint") String endpoint, @PathParam("blob") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-param-alias/{blob}/with-aliased-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAliasedNameSync(@HostParam("endpoint") String endpoint, @PathParam("blob") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-param-alias/{blobName}/with-original-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withOriginalName(@HostParam("endpoint") String endpoint, + @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-param-alias/{blobName}/with-original-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withOriginalNameSync(@HostParam("endpoint") String endpoint, + @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); + } + + /** + * The withAliasedName 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> withAliasedNameWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withAliasedName(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The withAliasedName 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 withAliasedNameWithResponse(RequestOptions requestOptions) { + return service.withAliasedNameSync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } + + /** + * The withOriginalName 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> withOriginalNameWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withOriginalName(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The withOriginalName 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 withOriginalNameWithResponse(RequestOptions requestOptions) { + return service.withOriginalNameSync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/ChildClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithPathClientImpl.java similarity index 89% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/ChildClientImpl.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithPathClientImpl.java index d7d09acf4c..c82909a98c 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/ChildClientImpl.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithPathClientImpl.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.implementation; +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation; import com.azure.core.annotation.Delete; import com.azure.core.annotation.ExpectedResponses; @@ -34,13 +34,13 @@ import reactor.core.publisher.Mono; /** - * Initializes a new instance of the ChildClient type. + * Initializes a new instance of the IndividuallyNestedWithPathClient type. */ -public final class ChildClientImpl { +public final class IndividuallyNestedWithPathClientImpl { /** * The proxy service used to perform REST calls. */ - private final ChildClientService service; + private final IndividuallyNestedWithPathClientService service; /** * Service host. @@ -98,51 +98,53 @@ public SerializerAdapter getSerializerAdapter() { } /** - * Initializes an instance of ChildClient client. + * Initializes an instance of IndividuallyNestedWithPathClient client. * * @param endpoint Service host. * @param blobName */ - public ChildClientImpl(String endpoint, String blobName) { + public IndividuallyNestedWithPathClientImpl(String endpoint, String blobName) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); } /** - * Initializes an instance of ChildClient client. + * Initializes an instance of IndividuallyNestedWithPathClient client. * * @param httpPipeline The HTTP pipeline to send requests through. * @param endpoint Service host. * @param blobName */ - public ChildClientImpl(HttpPipeline httpPipeline, String endpoint, String blobName) { + public IndividuallyNestedWithPathClientImpl(HttpPipeline httpPipeline, String endpoint, String blobName) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); } /** - * Initializes an instance of ChildClient client. + * Initializes an instance of IndividuallyNestedWithPathClient 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 blobName */ - public ChildClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, - String blobName) { + public IndividuallyNestedWithPathClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String blobName) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; this.blobName = blobName; - this.service = RestProxy.create(ChildClientService.class, this.httpPipeline, this.getSerializerAdapter()); + this.service = RestProxy.create(IndividuallyNestedWithPathClientService.class, this.httpPipeline, + this.getSerializerAdapter()); } /** - * The interface defining all the services for ChildClient to be used by the proxy service to perform REST calls. + * The interface defining all the services for IndividuallyNestedWithPathClient to be used by the proxy service to + * perform REST calls. */ @Host("{endpoint}") - @ServiceInterface(name = "ChildClient") - public interface ChildClientService { - @Get("/azure/client-generator-core/client-initialization/child-client/{blobName}/with-query") + @ServiceInterface(name = "IndividuallyNestedWithPathClient") + public interface IndividuallyNestedWithPathClientService { + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually/{blobName}/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -151,7 +153,7 @@ public interface ChildClientService { Mono> withQuery(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/child-client/{blobName}/with-query") + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually/{blobName}/with-query") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -160,7 +162,7 @@ Mono> withQuery(@HostParam("endpoint") String endpoint, @PathPara Response withQuerySync(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/child-client/{blobName}/get-standalone") + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually/{blobName}/get-standalone") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -170,7 +172,7 @@ Mono> getStandalone(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Get("/azure/client-generator-core/client-initialization/child-client/{blobName}/get-standalone") + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually/{blobName}/get-standalone") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -180,7 +182,7 @@ Response getStandaloneSync(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Delete("/azure/client-generator-core/client-initialization/child-client/{blobName}") + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually/{blobName}") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @@ -189,7 +191,7 @@ Response getStandaloneSync(@HostParam("endpoint") String endpoint, Mono> deleteStandalone(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); - @Delete("/azure/client-generator-core/client-initialization/child-client/{blobName}") + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually/{blobName}") @ExpectedResponses({ 204 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithQueryClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithQueryClientImpl.java new file mode 100644 index 0000000000..5704371b6f --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/IndividuallyNestedWithQueryClientImpl.java @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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; + +/** + * Initializes a new instance of the IndividuallyNestedWithQueryClient type. + */ +public final class IndividuallyNestedWithQueryClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyNestedWithQueryClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String blobName; + + /** + * Gets. + * + * @return the blobName value. + */ + public String getBlobName() { + return this.blobName; + } + + /** + * 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 IndividuallyNestedWithQueryClient client. + * + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyNestedWithQueryClientImpl(String endpoint, String blobName) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyNestedWithQueryClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyNestedWithQueryClientImpl(HttpPipeline httpPipeline, String endpoint, String blobName) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyNestedWithQueryClient 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 blobName + */ + public IndividuallyNestedWithQueryClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String blobName) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.blobName = blobName; + this.service = RestProxy.create(IndividuallyNestedWithQueryClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyNestedWithQueryClient to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyNestedWithQueryClient") + public interface IndividuallyNestedWithQueryClientService { + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-query/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @QueryParam("blobName") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-query/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @QueryParam("blobName") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-query/get-standalone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually/nested-default-individually-query/get-standalone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually-query/delete-resource") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually/nested-default-individually-query/delete-resource") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withQuery(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStandaloneWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getStandalone(this.getEndpoint(), this.getBlobName(), accept, requestOptions, context)); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStandaloneWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getStandaloneSync(this.getEndpoint(), this.getBlobName(), accept, requestOptions, Context.NONE); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.deleteStandalone(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/package-info.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/package-info.java new file mode 100644 index 0000000000..5e9e3e0121 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/implementation/package-info.java @@ -0,0 +1,11 @@ +// 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 IndividuallyClient. + * Test for client initialization decorator - moving parameters from method to client level. + * + */ +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.implementation; diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/models/BlobProperties.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/models/BlobProperties.java new file mode 100644 index 0000000000..74ff6516b8 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/models/BlobProperties.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Properties of a blob. + */ +@Immutable +public final class BlobProperties implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The size property. + */ + @Generated + private final long size; + + /* + * The contentType property. + */ + @Generated + private final String contentType; + + /* + * The createdOn property. + */ + @Generated + private final OffsetDateTime createdOn; + + /** + * Creates an instance of BlobProperties class. + * + * @param name the name value to set. + * @param size the size value to set. + * @param contentType the contentType value to set. + * @param createdOn the createdOn value to set. + */ + @Generated + private BlobProperties(String name, long size, String contentType, OffsetDateTime createdOn) { + this.name = name; + this.size = size; + this.contentType = contentType; + this.createdOn = createdOn; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the size property: The size property. + * + * @return the size value. + */ + @Generated + public long getSize() { + return this.size; + } + + /** + * Get the contentType property: The contentType property. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Get the createdOn property: The createdOn property. + * + * @return the createdOn value. + */ + @Generated + public OffsetDateTime getCreatedOn() { + return this.createdOn; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeLongField("size", this.size); + jsonWriter.writeStringField("contentType", this.contentType); + jsonWriter.writeStringField("createdOn", + this.createdOn == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdOn)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobProperties 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 BlobProperties. + */ + @Generated + public static BlobProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + long size = 0L; + String contentType = null; + OffsetDateTime createdOn = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("size".equals(fieldName)) { + size = reader.getLong(); + } else if ("contentType".equals(fieldName)) { + contentType = reader.getString(); + } else if ("createdOn".equals(fieldName)) { + createdOn = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new BlobProperties(name, size, contentType, createdOn); + }); + } +} diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/package-info.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/models/package-info.java similarity index 67% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/package-info.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/models/package-info.java index 2eb62c2e3d..34507e7f5a 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/package-info.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/models/package-info.java @@ -4,8 +4,8 @@ /** * - * Package containing the classes for ChildClient. + * Package containing the data models for IndividuallyClient. * Test for client initialization decorator - moving parameters from method to client level. * */ -package azure.clientgenerator.core.clientinitialization.parentclient; +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.models; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/package-info.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/package-info.java similarity index 69% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/package-info.java rename to typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/package-info.java index daa49ebd2d..59b682bced 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/package-info.java +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/package-info.java @@ -4,8 +4,8 @@ /** * - * Package containing the classes for Service. + * Package containing the classes for IndividuallyClient. * Test for client initialization decorator - moving parameters from method to client level. * */ -package azure.clientgenerator.core.clientinitialization; +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient; diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentAsyncClient.java new file mode 100644 index 0000000000..2d98f37074 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentAsyncClient.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClient; + +/** + * Initializes a new instance of the asynchronous IndividuallyParentClient type. + */ +@ServiceClient(builder = IndividuallyParentClientBuilder.class, isAsync = true) +public final class IndividuallyParentAsyncClient { + @Generated + private final IndividuallyParentClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentAsyncClient(IndividuallyParentClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Gets an instance of IndividuallyParentNestedWithPathAsyncClient class. + * + * @param blobName The blobName parameter. + * @return an instance of IndividuallyParentNestedWithPathAsyncClient class. + */ + public IndividuallyParentNestedWithPathAsyncClient getIndividuallyParentNestedWithPathAsyncClient(String blobName) { + return new IndividuallyParentNestedWithPathAsyncClient( + serviceClient.getIndividuallyParentNestedWithPathClient(blobName)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithQueryAsyncClient class. + * + * @param blobName The blobName parameter. + * @return an instance of IndividuallyParentNestedWithQueryAsyncClient class. + */ + public IndividuallyParentNestedWithQueryAsyncClient + getIndividuallyParentNestedWithQueryAsyncClient(String blobName) { + return new IndividuallyParentNestedWithQueryAsyncClient( + serviceClient.getIndividuallyParentNestedWithQueryClient(blobName)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithHeaderAsyncClient class. + * + * @param name The name parameter. + * @return an instance of IndividuallyParentNestedWithHeaderAsyncClient class. + */ + public IndividuallyParentNestedWithHeaderAsyncClient getIndividuallyParentNestedWithHeaderAsyncClient(String name) { + return new IndividuallyParentNestedWithHeaderAsyncClient( + serviceClient.getIndividuallyParentNestedWithHeaderClient(name)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithMultipleAsyncClient class. + * + * @param name The name parameter. + * @param region The region parameter. + * @return an instance of IndividuallyParentNestedWithMultipleAsyncClient class. + */ + public IndividuallyParentNestedWithMultipleAsyncClient + getIndividuallyParentNestedWithMultipleAsyncClient(String name, String region) { + return new IndividuallyParentNestedWithMultipleAsyncClient( + serviceClient.getIndividuallyParentNestedWithMultipleClient(name, region)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithMixedAsyncClient class. + * + * @param name The name parameter. + * @return an instance of IndividuallyParentNestedWithMixedAsyncClient class. + */ + public IndividuallyParentNestedWithMixedAsyncClient getIndividuallyParentNestedWithMixedAsyncClient(String name) { + return new IndividuallyParentNestedWithMixedAsyncClient( + serviceClient.getIndividuallyParentNestedWithMixedClient(name)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithParamAliasAsyncClient class. + * + * @param blobName The blobName parameter. + * @return an instance of IndividuallyParentNestedWithParamAliasAsyncClient class. + */ + public IndividuallyParentNestedWithParamAliasAsyncClient + getIndividuallyParentNestedWithParamAliasAsyncClient(String blobName) { + return new IndividuallyParentNestedWithParamAliasAsyncClient( + serviceClient.getIndividuallyParentNestedWithParamAliasClient(blobName)); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentClient.java new file mode 100644 index 0000000000..d9cc367647 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentClient.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClient; + +/** + * Initializes a new instance of the synchronous IndividuallyParentClient type. + */ +@ServiceClient(builder = IndividuallyParentClientBuilder.class) +public final class IndividuallyParentClient { + @Generated + private final IndividuallyParentClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentClient(IndividuallyParentClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Gets an instance of IndividuallyParentNestedWithPathClient class. + * + * @param blobName The blobName parameter. + * @return an instance of IndividuallyParentNestedWithPathClient class. + */ + public IndividuallyParentNestedWithPathClient getIndividuallyParentNestedWithPathClient(String blobName) { + return new IndividuallyParentNestedWithPathClient( + serviceClient.getIndividuallyParentNestedWithPathClient(blobName)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithQueryClient class. + * + * @param blobName The blobName parameter. + * @return an instance of IndividuallyParentNestedWithQueryClient class. + */ + public IndividuallyParentNestedWithQueryClient getIndividuallyParentNestedWithQueryClient(String blobName) { + return new IndividuallyParentNestedWithQueryClient( + serviceClient.getIndividuallyParentNestedWithQueryClient(blobName)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithHeaderClient class. + * + * @param name The name parameter. + * @return an instance of IndividuallyParentNestedWithHeaderClient class. + */ + public IndividuallyParentNestedWithHeaderClient getIndividuallyParentNestedWithHeaderClient(String name) { + return new IndividuallyParentNestedWithHeaderClient( + serviceClient.getIndividuallyParentNestedWithHeaderClient(name)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithMultipleClient class. + * + * @param name The name parameter. + * @param region The region parameter. + * @return an instance of IndividuallyParentNestedWithMultipleClient class. + */ + public IndividuallyParentNestedWithMultipleClient getIndividuallyParentNestedWithMultipleClient(String name, + String region) { + return new IndividuallyParentNestedWithMultipleClient( + serviceClient.getIndividuallyParentNestedWithMultipleClient(name, region)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithMixedClient class. + * + * @param name The name parameter. + * @return an instance of IndividuallyParentNestedWithMixedClient class. + */ + public IndividuallyParentNestedWithMixedClient getIndividuallyParentNestedWithMixedClient(String name) { + return new IndividuallyParentNestedWithMixedClient( + serviceClient.getIndividuallyParentNestedWithMixedClient(name)); + } + + /** + * Gets an instance of IndividuallyParentNestedWithParamAliasClient class. + * + * @param blobName The blobName parameter. + * @return an instance of IndividuallyParentNestedWithParamAliasClient class. + */ + public IndividuallyParentNestedWithParamAliasClient + getIndividuallyParentNestedWithParamAliasClient(String blobName) { + return new IndividuallyParentNestedWithParamAliasClient( + serviceClient.getIndividuallyParentNestedWithParamAliasClient(blobName)); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentClientBuilder.java new file mode 100644 index 0000000000..05527a9fa9 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentClientBuilder.java @@ -0,0 +1,288 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyParentClient type. + */ +@ServiceClientBuilder(serviceClients = { IndividuallyParentClient.class, IndividuallyParentAsyncClient.class }) +public final class IndividuallyParentClientBuilder 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyParentClientBuilder. + */ + @Generated + public IndividuallyParentClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentClientBuilder 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 IndividuallyParentClientBuilder 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 IndividuallyParentClientBuilder 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 IndividuallyParentClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentClientBuilder 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 IndividuallyParentClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated + private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the IndividuallyParentClientBuilder. + */ + @Generated + public IndividuallyParentClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyParentClientImpl with the provided parameters. + * + * @return an instance of IndividuallyParentClientImpl. + */ + @Generated + private IndividuallyParentClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyParentClientImpl client = new IndividuallyParentClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); + 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. + } + + @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 IndividuallyParentAsyncClient class. + * + * @return an instance of IndividuallyParentAsyncClient. + */ + @Generated + public IndividuallyParentAsyncClient buildAsyncClient() { + return new IndividuallyParentAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyParentClient class. + * + * @return an instance of IndividuallyParentClient. + */ + @Generated + public IndividuallyParentClient buildClient() { + return new IndividuallyParentClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyParentClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithHeaderAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithHeaderAsyncClient.java new file mode 100644 index 0000000000..a40dc2c42e --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithHeaderAsyncClient.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithHeaderClientImpl; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyParentNestedWithHeaderClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithHeaderClientBuilder.class, isAsync = true) +public final class IndividuallyParentNestedWithHeaderAsyncClient { + @Generated + private final IndividuallyParentNestedWithHeaderClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithHeaderAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithHeaderAsyncClient(IndividuallyParentNestedWithHeaderClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(requestOptions); + } + + /** + * The getStandalone 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> getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(requestOptions); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone 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 getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithHeaderClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithHeaderClient.java new file mode 100644 index 0000000000..9d4b1b5726 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithHeaderClient.java @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithHeaderClientImpl; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyParentNestedWithHeaderClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithHeaderClientBuilder.class) +public final class IndividuallyParentNestedWithHeaderClient { + @Generated + private final IndividuallyParentNestedWithHeaderClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithHeaderClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithHeaderClient(IndividuallyParentNestedWithHeaderClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(requestOptions); + } + + /** + * The getStandalone 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 getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(requestOptions); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The getStandalone 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 getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + getStandaloneWithResponse(requestOptions).getValue(); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithHeaderClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithHeaderClientBuilder.java new file mode 100644 index 0000000000..79ca34e701 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithHeaderClientBuilder.java @@ -0,0 +1,312 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithHeaderClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyParentNestedWithHeaderClient type. + */ +@ServiceClientBuilder( + serviceClients = { + IndividuallyParentNestedWithHeaderClient.class, + IndividuallyParentNestedWithHeaderAsyncClient.class }) +public final class IndividuallyParentNestedWithHeaderClientBuilder + 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyParentNestedWithHeaderClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithHeaderClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithHeaderClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithHeaderClientBuilder 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 IndividuallyParentNestedWithHeaderClientBuilder 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 IndividuallyParentNestedWithHeaderClientBuilder 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 IndividuallyParentNestedWithHeaderClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithHeaderClientBuilder 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 IndividuallyParentNestedWithHeaderClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithHeaderClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String name; + + /** + * Sets. + * + * @param name the name value. + * @return the IndividuallyParentNestedWithHeaderClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithHeaderClientBuilder name(String name) { + this.name = name; + 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 IndividuallyParentNestedWithHeaderClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithHeaderClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyParentNestedWithHeaderClientImpl with the provided parameters. + * + * @return an instance of IndividuallyParentNestedWithHeaderClientImpl. + */ + @Generated + private IndividuallyParentNestedWithHeaderClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyParentNestedWithHeaderClientImpl client = new IndividuallyParentNestedWithHeaderClientImpl( + localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.name); + 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(name, "'name' 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 IndividuallyParentNestedWithHeaderAsyncClient class. + * + * @return an instance of IndividuallyParentNestedWithHeaderAsyncClient. + */ + @Generated + public IndividuallyParentNestedWithHeaderAsyncClient buildAsyncClient() { + return new IndividuallyParentNestedWithHeaderAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyParentNestedWithHeaderClient class. + * + * @return an instance of IndividuallyParentNestedWithHeaderClient. + */ + @Generated + public IndividuallyParentNestedWithHeaderClient buildClient() { + return new IndividuallyParentNestedWithHeaderClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyParentNestedWithHeaderClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMixedAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMixedAsyncClient.java new file mode 100644 index 0000000000..4a58ed6c18 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMixedAsyncClient.java @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithMixedClientImpl; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyParentNestedWithMixedClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithMixedClientBuilder.class, isAsync = true) +public final class IndividuallyParentNestedWithMixedAsyncClient { + @Generated + private final IndividuallyParentNestedWithMixedClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithMixedAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithMixedAsyncClient(IndividuallyParentNestedWithMixedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param region The region 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> withQueryWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(region, requestOptions); + } + + /** + * The getStandalone operation. + * + * @param region The region 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> getStandaloneWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(region, requestOptions); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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> deleteStandaloneWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(region, requestOptions); + } + + /** + * The withQuery operation. + * + * @param region The region parameter. + * @param format The format 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 withQuery(String region, String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery operation. + * + * @param region The region 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 withQuery(String region) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone operation. + * + * @param region The region 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 getStandalone(String region) { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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 deleteStandalone(String region) { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(region, requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMixedClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMixedClient.java new file mode 100644 index 0000000000..a3937047c2 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMixedClient.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithMixedClientImpl; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyParentNestedWithMixedClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithMixedClientBuilder.class) +public final class IndividuallyParentNestedWithMixedClient { + @Generated + private final IndividuallyParentNestedWithMixedClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithMixedClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithMixedClient(IndividuallyParentNestedWithMixedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param region The region 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 withQueryWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(region, requestOptions); + } + + /** + * The getStandalone operation. + * + * @param region The region 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 getStandaloneWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(region, requestOptions); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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 deleteStandaloneWithResponse(String region, RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(region, requestOptions); + } + + /** + * The withQuery operation. + * + * @param region The region parameter. + * @param format The format 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 withQuery(String region, String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(region, requestOptions).getValue(); + } + + /** + * The withQuery operation. + * + * @param region The region 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 withQuery(String region) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(region, requestOptions).getValue(); + } + + /** + * The getStandalone operation. + * + * @param region The region 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 getStandalone(String region) { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + getStandaloneWithResponse(region, requestOptions).getValue(); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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 deleteStandalone(String region) { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(region, requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMixedClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMixedClientBuilder.java new file mode 100644 index 0000000000..32ea151be2 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMixedClientBuilder.java @@ -0,0 +1,312 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithMixedClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyParentNestedWithMixedClient type. + */ +@ServiceClientBuilder( + serviceClients = { + IndividuallyParentNestedWithMixedClient.class, + IndividuallyParentNestedWithMixedAsyncClient.class }) +public final class IndividuallyParentNestedWithMixedClientBuilder + 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyParentNestedWithMixedClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithMixedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithMixedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithMixedClientBuilder 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 IndividuallyParentNestedWithMixedClientBuilder 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 IndividuallyParentNestedWithMixedClientBuilder 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 IndividuallyParentNestedWithMixedClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithMixedClientBuilder 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 IndividuallyParentNestedWithMixedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithMixedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String name; + + /** + * Sets. + * + * @param name the name value. + * @return the IndividuallyParentNestedWithMixedClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithMixedClientBuilder name(String name) { + this.name = name; + 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 IndividuallyParentNestedWithMixedClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithMixedClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyParentNestedWithMixedClientImpl with the provided parameters. + * + * @return an instance of IndividuallyParentNestedWithMixedClientImpl. + */ + @Generated + private IndividuallyParentNestedWithMixedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyParentNestedWithMixedClientImpl client = new IndividuallyParentNestedWithMixedClientImpl( + localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.name); + 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(name, "'name' 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 IndividuallyParentNestedWithMixedAsyncClient class. + * + * @return an instance of IndividuallyParentNestedWithMixedAsyncClient. + */ + @Generated + public IndividuallyParentNestedWithMixedAsyncClient buildAsyncClient() { + return new IndividuallyParentNestedWithMixedAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyParentNestedWithMixedClient class. + * + * @return an instance of IndividuallyParentNestedWithMixedClient. + */ + @Generated + public IndividuallyParentNestedWithMixedClient buildClient() { + return new IndividuallyParentNestedWithMixedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyParentNestedWithMixedClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMultipleAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMultipleAsyncClient.java new file mode 100644 index 0000000000..56f0f11ec2 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMultipleAsyncClient.java @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithMultipleClientImpl; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyParentNestedWithMultipleClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithMultipleClientBuilder.class, isAsync = true) +public final class IndividuallyParentNestedWithMultipleAsyncClient { + @Generated + private final IndividuallyParentNestedWithMultipleClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithMultipleAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithMultipleAsyncClient(IndividuallyParentNestedWithMultipleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(requestOptions); + } + + /** + * The getStandalone 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> getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(requestOptions); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone 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 getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMultipleClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMultipleClient.java new file mode 100644 index 0000000000..0d5ea371b8 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMultipleClient.java @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithMultipleClientImpl; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyParentNestedWithMultipleClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithMultipleClientBuilder.class) +public final class IndividuallyParentNestedWithMultipleClient { + @Generated + private final IndividuallyParentNestedWithMultipleClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithMultipleClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithMultipleClient(IndividuallyParentNestedWithMultipleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(requestOptions); + } + + /** + * The getStandalone 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 getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(requestOptions); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The getStandalone 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 getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + getStandaloneWithResponse(requestOptions).getValue(); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMultipleClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMultipleClientBuilder.java new file mode 100644 index 0000000000..d20811188c --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithMultipleClientBuilder.java @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithMultipleClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyParentNestedWithMultipleClient type. + */ +@ServiceClientBuilder( + serviceClients = { + IndividuallyParentNestedWithMultipleClient.class, + IndividuallyParentNestedWithMultipleAsyncClient.class }) +public final class IndividuallyParentNestedWithMultipleClientBuilder + 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyParentNestedWithMultipleClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithMultipleClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithMultipleClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithMultipleClientBuilder 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 IndividuallyParentNestedWithMultipleClientBuilder 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 IndividuallyParentNestedWithMultipleClientBuilder 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 IndividuallyParentNestedWithMultipleClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithMultipleClientBuilder 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 IndividuallyParentNestedWithMultipleClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithMultipleClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String name; + + /** + * Sets. + * + * @param name the name value. + * @return the IndividuallyParentNestedWithMultipleClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithMultipleClientBuilder name(String name) { + this.name = name; + return this; + } + + /* + * + */ + @Generated + private String region; + + /** + * Sets. + * + * @param region the region value. + * @return the IndividuallyParentNestedWithMultipleClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithMultipleClientBuilder region(String region) { + this.region = region; + 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 IndividuallyParentNestedWithMultipleClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithMultipleClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyParentNestedWithMultipleClientImpl with the provided parameters. + * + * @return an instance of IndividuallyParentNestedWithMultipleClientImpl. + */ + @Generated + private IndividuallyParentNestedWithMultipleClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyParentNestedWithMultipleClientImpl client = new IndividuallyParentNestedWithMultipleClientImpl( + localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.name, this.region); + 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(name, "'name' cannot be null."); + Objects.requireNonNull(region, "'region' 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 IndividuallyParentNestedWithMultipleAsyncClient class. + * + * @return an instance of IndividuallyParentNestedWithMultipleAsyncClient. + */ + @Generated + public IndividuallyParentNestedWithMultipleAsyncClient buildAsyncClient() { + return new IndividuallyParentNestedWithMultipleAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyParentNestedWithMultipleClient class. + * + * @return an instance of IndividuallyParentNestedWithMultipleClient. + */ + @Generated + public IndividuallyParentNestedWithMultipleClient buildClient() { + return new IndividuallyParentNestedWithMultipleClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER + = new ClientLogger(IndividuallyParentNestedWithMultipleClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithParamAliasAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithParamAliasAsyncClient.java new file mode 100644 index 0000000000..94679aa600 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithParamAliasAsyncClient.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithParamAliasClientImpl; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyParentNestedWithParamAliasClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithParamAliasClientBuilder.class, isAsync = true) +public final class IndividuallyParentNestedWithParamAliasAsyncClient { + @Generated + private final IndividuallyParentNestedWithParamAliasClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithParamAliasAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithParamAliasAsyncClient(IndividuallyParentNestedWithParamAliasClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAliasedName 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> withAliasedNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withAliasedNameWithResponseAsync(requestOptions); + } + + /** + * The withOriginalName 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> withOriginalNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withOriginalNameWithResponseAsync(requestOptions); + } + + /** + * The withAliasedName 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 withAliasedName() { + // Generated convenience method for withAliasedNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withAliasedNameWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withOriginalName 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 withOriginalName() { + // Generated convenience method for withOriginalNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withOriginalNameWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithParamAliasClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithParamAliasClient.java new file mode 100644 index 0000000000..d4e8214339 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithParamAliasClient.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithParamAliasClientImpl; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyParentNestedWithParamAliasClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithParamAliasClientBuilder.class) +public final class IndividuallyParentNestedWithParamAliasClient { + @Generated + private final IndividuallyParentNestedWithParamAliasClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithParamAliasClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithParamAliasClient(IndividuallyParentNestedWithParamAliasClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAliasedName 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 withAliasedNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withAliasedNameWithResponse(requestOptions); + } + + /** + * The withOriginalName 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 withOriginalNameWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withOriginalNameWithResponse(requestOptions); + } + + /** + * The withAliasedName 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 withAliasedName() { + // Generated convenience method for withAliasedNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAliasedNameWithResponse(requestOptions).getValue(); + } + + /** + * The withOriginalName 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 withOriginalName() { + // Generated convenience method for withOriginalNameWithResponse + RequestOptions requestOptions = new RequestOptions(); + withOriginalNameWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithParamAliasClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithParamAliasClientBuilder.java new file mode 100644 index 0000000000..4a6bd194a0 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithParamAliasClientBuilder.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithParamAliasClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyParentNestedWithParamAliasClient type. + */ +@ServiceClientBuilder( + serviceClients = { + IndividuallyParentNestedWithParamAliasClient.class, + IndividuallyParentNestedWithParamAliasAsyncClient.class }) +public final class IndividuallyParentNestedWithParamAliasClientBuilder + 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyParentNestedWithParamAliasClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithParamAliasClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithParamAliasClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithParamAliasClientBuilder 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 IndividuallyParentNestedWithParamAliasClientBuilder 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 IndividuallyParentNestedWithParamAliasClientBuilder 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 IndividuallyParentNestedWithParamAliasClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithParamAliasClientBuilder 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 IndividuallyParentNestedWithParamAliasClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithParamAliasClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String blobName; + + /** + * Sets. + * + * @param blobName the blobName value. + * @return the IndividuallyParentNestedWithParamAliasClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithParamAliasClientBuilder blobName(String blobName) { + this.blobName = blobName; + 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 IndividuallyParentNestedWithParamAliasClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithParamAliasClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyParentNestedWithParamAliasClientImpl with the provided parameters. + * + * @return an instance of IndividuallyParentNestedWithParamAliasClientImpl. + */ + @Generated + private IndividuallyParentNestedWithParamAliasClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyParentNestedWithParamAliasClientImpl client = new IndividuallyParentNestedWithParamAliasClientImpl( + localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.blobName); + 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(blobName, "'blobName' 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 IndividuallyParentNestedWithParamAliasAsyncClient class. + * + * @return an instance of IndividuallyParentNestedWithParamAliasAsyncClient. + */ + @Generated + public IndividuallyParentNestedWithParamAliasAsyncClient buildAsyncClient() { + return new IndividuallyParentNestedWithParamAliasAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyParentNestedWithParamAliasClient class. + * + * @return an instance of IndividuallyParentNestedWithParamAliasClient. + */ + @Generated + public IndividuallyParentNestedWithParamAliasClient buildClient() { + return new IndividuallyParentNestedWithParamAliasClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER + = new ClientLogger(IndividuallyParentNestedWithParamAliasClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithPathAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithPathAsyncClient.java new file mode 100644 index 0000000000..fcdab9bed8 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithPathAsyncClient.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithPathClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.models.BlobProperties; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyParentNestedWithPathClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithPathClientBuilder.class, isAsync = true) +public final class IndividuallyParentNestedWithPathAsyncClient { + @Generated + private final IndividuallyParentNestedWithPathClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithPathAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithPathAsyncClient(IndividuallyParentNestedWithPathClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(requestOptions); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(requestOptions); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone 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 properties of a blob on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BlobProperties.class)); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithPathClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithPathClient.java new file mode 100644 index 0000000000..3d91bcd3a7 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithPathClient.java @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithPathClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.models.BlobProperties; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyParentNestedWithPathClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithPathClientBuilder.class) +public final class IndividuallyParentNestedWithPathClient { + @Generated + private final IndividuallyParentNestedWithPathClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithPathClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithPathClient(IndividuallyParentNestedWithPathClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(requestOptions); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(requestOptions); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The getStandalone 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 properties of a blob. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BlobProperties getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).getValue().toObject(BlobProperties.class); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithPathClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithPathClientBuilder.java new file mode 100644 index 0000000000..0619b12c4e --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithPathClientBuilder.java @@ -0,0 +1,312 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithPathClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyParentNestedWithPathClient type. + */ +@ServiceClientBuilder( + serviceClients = { + IndividuallyParentNestedWithPathClient.class, + IndividuallyParentNestedWithPathAsyncClient.class }) +public final class IndividuallyParentNestedWithPathClientBuilder + 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyParentNestedWithPathClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithPathClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithPathClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithPathClientBuilder 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 IndividuallyParentNestedWithPathClientBuilder 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 IndividuallyParentNestedWithPathClientBuilder 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 IndividuallyParentNestedWithPathClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithPathClientBuilder 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 IndividuallyParentNestedWithPathClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithPathClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String blobName; + + /** + * Sets. + * + * @param blobName the blobName value. + * @return the IndividuallyParentNestedWithPathClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithPathClientBuilder blobName(String blobName) { + this.blobName = blobName; + 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 IndividuallyParentNestedWithPathClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithPathClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyParentNestedWithPathClientImpl with the provided parameters. + * + * @return an instance of IndividuallyParentNestedWithPathClientImpl. + */ + @Generated + private IndividuallyParentNestedWithPathClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyParentNestedWithPathClientImpl client = new IndividuallyParentNestedWithPathClientImpl( + localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.blobName); + 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(blobName, "'blobName' 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 IndividuallyParentNestedWithPathAsyncClient class. + * + * @return an instance of IndividuallyParentNestedWithPathAsyncClient. + */ + @Generated + public IndividuallyParentNestedWithPathAsyncClient buildAsyncClient() { + return new IndividuallyParentNestedWithPathAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyParentNestedWithPathClient class. + * + * @return an instance of IndividuallyParentNestedWithPathClient. + */ + @Generated + public IndividuallyParentNestedWithPathClient buildClient() { + return new IndividuallyParentNestedWithPathClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyParentNestedWithPathClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithQueryAsyncClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithQueryAsyncClient.java new file mode 100644 index 0000000000..e3cae797d8 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithQueryAsyncClient.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithQueryClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.models.BlobProperties; +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; + +/** + * Initializes a new instance of the asynchronous IndividuallyParentNestedWithQueryClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithQueryClientBuilder.class, isAsync = true) +public final class IndividuallyParentNestedWithQueryAsyncClient { + @Generated + private final IndividuallyParentNestedWithQueryClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithQueryAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithQueryAsyncClient(IndividuallyParentNestedWithQueryClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponseAsync(requestOptions); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponseAsync(requestOptions); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponseAsync(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return withQueryWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The getStandalone 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 properties of a blob on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(BlobProperties.class)); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteStandaloneWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithQueryClient.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithQueryClient.java new file mode 100644 index 0000000000..5069a7cd00 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithQueryClient.java @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithQueryClientImpl; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.models.BlobProperties; +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; + +/** + * Initializes a new instance of the synchronous IndividuallyParentNestedWithQueryClient type. + */ +@ServiceClient(builder = IndividuallyParentNestedWithQueryClientBuilder.class) +public final class IndividuallyParentNestedWithQueryClient { + @Generated + private final IndividuallyParentNestedWithQueryClientImpl serviceClient; + + /** + * Initializes an instance of IndividuallyParentNestedWithQueryClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + IndividuallyParentNestedWithQueryClient(IndividuallyParentNestedWithQueryClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryWithResponse(requestOptions); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getStandaloneWithResponse(requestOptions); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return this.serviceClient.deleteStandaloneWithResponse(requestOptions); + } + + /** + * The withQuery operation. + * + * @param format The format 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 withQuery(String format) { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (format != null) { + requestOptions.addQueryParam("format", format, false); + } + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The withQuery 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 withQuery() { + // Generated convenience method for withQueryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryWithResponse(requestOptions).getValue(); + } + + /** + * The getStandalone 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 properties of a blob. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BlobProperties getStandalone() { + // Generated convenience method for getStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getStandaloneWithResponse(requestOptions).getValue().toObject(BlobProperties.class); + } + + /** + * The deleteStandalone 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 deleteStandalone() { + // Generated convenience method for deleteStandaloneWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteStandaloneWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithQueryClientBuilder.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithQueryClientBuilder.java new file mode 100644 index 0000000000..2534362896 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/IndividuallyParentNestedWithQueryClientBuilder.java @@ -0,0 +1,312 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; + +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation.IndividuallyParentNestedWithQueryClientImpl; +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; + +/** + * A builder for creating a new instance of the IndividuallyParentNestedWithQueryClient type. + */ +@ServiceClientBuilder( + serviceClients = { + IndividuallyParentNestedWithQueryClient.class, + IndividuallyParentNestedWithQueryAsyncClient.class }) +public final class IndividuallyParentNestedWithQueryClientBuilder + 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("_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the IndividuallyParentNestedWithQueryClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithQueryClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithQueryClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithQueryClientBuilder 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 IndividuallyParentNestedWithQueryClientBuilder 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 IndividuallyParentNestedWithQueryClientBuilder 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 IndividuallyParentNestedWithQueryClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithQueryClientBuilder 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 IndividuallyParentNestedWithQueryClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public IndividuallyParentNestedWithQueryClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String blobName; + + /** + * Sets. + * + * @param blobName the blobName value. + * @return the IndividuallyParentNestedWithQueryClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithQueryClientBuilder blobName(String blobName) { + this.blobName = blobName; + 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 IndividuallyParentNestedWithQueryClientBuilder. + */ + @Generated + public IndividuallyParentNestedWithQueryClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of IndividuallyParentNestedWithQueryClientImpl with the provided parameters. + * + * @return an instance of IndividuallyParentNestedWithQueryClientImpl. + */ + @Generated + private IndividuallyParentNestedWithQueryClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + IndividuallyParentNestedWithQueryClientImpl client = new IndividuallyParentNestedWithQueryClientImpl( + localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint, this.blobName); + 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(blobName, "'blobName' 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 IndividuallyParentNestedWithQueryAsyncClient class. + * + * @return an instance of IndividuallyParentNestedWithQueryAsyncClient. + */ + @Generated + public IndividuallyParentNestedWithQueryAsyncClient buildAsyncClient() { + return new IndividuallyParentNestedWithQueryAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of IndividuallyParentNestedWithQueryClient class. + * + * @return an instance of IndividuallyParentNestedWithQueryClient. + */ + @Generated + public IndividuallyParentNestedWithQueryClient buildClient() { + return new IndividuallyParentNestedWithQueryClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(IndividuallyParentNestedWithQueryClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentClientImpl.java new file mode 100644 index 0000000000..e5ac51fd7f --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentClientImpl.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation; + +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import java.util.Objects; + +/** + * Initializes a new instance of the IndividuallyParentClient type. + */ +public final class IndividuallyParentClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of IndividuallyParentClient client. + * + * @param endpoint Service host. + */ + public IndividuallyParentClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of IndividuallyParentClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public IndividuallyParentClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of IndividuallyParentClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Service host. + */ + public IndividuallyParentClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + } + + /** + * Gets an instance of IndividuallyParentNestedWithPathClientImpl class. + * + * @param blobName The blobName parameter. + * @return an instance of IndividuallyParentNestedWithPathClientImpl class. + */ + public IndividuallyParentNestedWithPathClientImpl getIndividuallyParentNestedWithPathClient(String blobName) { + Objects.requireNonNull(blobName, "'blobName' cannot be null."); + return new IndividuallyParentNestedWithPathClientImpl(httpPipeline, serializerAdapter, endpoint, blobName); + } + + /** + * Gets an instance of IndividuallyParentNestedWithQueryClientImpl class. + * + * @param blobName The blobName parameter. + * @return an instance of IndividuallyParentNestedWithQueryClientImpl class. + */ + public IndividuallyParentNestedWithQueryClientImpl getIndividuallyParentNestedWithQueryClient(String blobName) { + Objects.requireNonNull(blobName, "'blobName' cannot be null."); + return new IndividuallyParentNestedWithQueryClientImpl(httpPipeline, serializerAdapter, endpoint, blobName); + } + + /** + * Gets an instance of IndividuallyParentNestedWithHeaderClientImpl class. + * + * @param name The name parameter. + * @return an instance of IndividuallyParentNestedWithHeaderClientImpl class. + */ + public IndividuallyParentNestedWithHeaderClientImpl getIndividuallyParentNestedWithHeaderClient(String name) { + Objects.requireNonNull(name, "'name' cannot be null."); + return new IndividuallyParentNestedWithHeaderClientImpl(httpPipeline, serializerAdapter, endpoint, name); + } + + /** + * Gets an instance of IndividuallyParentNestedWithMultipleClientImpl class. + * + * @param name The name parameter. + * @param region The region parameter. + * @return an instance of IndividuallyParentNestedWithMultipleClientImpl class. + */ + public IndividuallyParentNestedWithMultipleClientImpl getIndividuallyParentNestedWithMultipleClient(String name, + String region) { + Objects.requireNonNull(name, "'name' cannot be null."); + Objects.requireNonNull(region, "'region' cannot be null."); + return new IndividuallyParentNestedWithMultipleClientImpl(httpPipeline, serializerAdapter, endpoint, name, + region); + } + + /** + * Gets an instance of IndividuallyParentNestedWithMixedClientImpl class. + * + * @param name The name parameter. + * @return an instance of IndividuallyParentNestedWithMixedClientImpl class. + */ + public IndividuallyParentNestedWithMixedClientImpl getIndividuallyParentNestedWithMixedClient(String name) { + Objects.requireNonNull(name, "'name' cannot be null."); + return new IndividuallyParentNestedWithMixedClientImpl(httpPipeline, serializerAdapter, endpoint, name); + } + + /** + * Gets an instance of IndividuallyParentNestedWithParamAliasClientImpl class. + * + * @param blobName The blobName parameter. + * @return an instance of IndividuallyParentNestedWithParamAliasClientImpl class. + */ + public IndividuallyParentNestedWithParamAliasClientImpl + getIndividuallyParentNestedWithParamAliasClient(String blobName) { + Objects.requireNonNull(blobName, "'blobName' cannot be null."); + return new IndividuallyParentNestedWithParamAliasClientImpl(httpPipeline, serializerAdapter, endpoint, + blobName); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithHeaderClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithHeaderClientImpl.java new file mode 100644 index 0000000000..c974907925 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithHeaderClientImpl.java @@ -0,0 +1,306 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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 IndividuallyParentNestedWithHeaderClient type. + */ +public final class IndividuallyParentNestedWithHeaderClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyParentNestedWithHeaderClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String name; + + /** + * Gets. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + * 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 IndividuallyParentNestedWithHeaderClient client. + * + * @param endpoint Service host. + * @param name + */ + public IndividuallyParentNestedWithHeaderClientImpl(String endpoint, String name) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithHeaderClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param name + */ + public IndividuallyParentNestedWithHeaderClientImpl(HttpPipeline httpPipeline, String endpoint, String name) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithHeaderClient 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 name + */ + public IndividuallyParentNestedWithHeaderClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String name) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.name = name; + this.service = RestProxy.create(IndividuallyParentNestedWithHeaderClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyParentNestedWithHeaderClient to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyParentNestedWithHeaderClient") + public interface IndividuallyParentNestedWithHeaderClientService { + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-header/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-header/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-header/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-header/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-header/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-header/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withQuery(this.getEndpoint(), this.getName(), requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getName(), requestOptions, Context.NONE); + } + + /** + * The getStandalone 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> getStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.getStandalone(this.getEndpoint(), this.getName(), requestOptions, context)); + } + + /** + * The getStandalone 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 getStandaloneWithResponse(RequestOptions requestOptions) { + return service.getStandaloneSync(this.getEndpoint(), this.getName(), requestOptions, Context.NONE); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.deleteStandalone(this.getEndpoint(), this.getName(), requestOptions, context)); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getName(), requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithMixedClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithMixedClientImpl.java new file mode 100644 index 0000000000..efb36a71a1 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithMixedClientImpl.java @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.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 IndividuallyParentNestedWithMixedClient type. + */ +public final class IndividuallyParentNestedWithMixedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyParentNestedWithMixedClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String name; + + /** + * Gets. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + * 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 IndividuallyParentNestedWithMixedClient client. + * + * @param endpoint Service host. + * @param name + */ + public IndividuallyParentNestedWithMixedClientImpl(String endpoint, String name) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithMixedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param name + */ + public IndividuallyParentNestedWithMixedClientImpl(HttpPipeline httpPipeline, String endpoint, String name) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithMixedClient 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 name + */ + public IndividuallyParentNestedWithMixedClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String name) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.name = name; + this.service = RestProxy.create(IndividuallyParentNestedWithMixedClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyParentNestedWithMixedClient to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyParentNestedWithMixedClient") + public interface IndividuallyParentNestedWithMixedClientService { + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-mixed/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-mixed/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-mixed/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-mixed/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-mixed/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-mixed/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param region The region 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> withQueryWithResponseAsync(String region, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withQuery(this.getEndpoint(), this.getName(), region, requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @param region The region 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 withQueryWithResponse(String region, RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getName(), region, requestOptions, Context.NONE); + } + + /** + * The getStandalone operation. + * + * @param region The region 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> getStandaloneWithResponseAsync(String region, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.getStandalone(this.getEndpoint(), this.getName(), region, requestOptions, context)); + } + + /** + * The getStandalone operation. + * + * @param region The region 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 getStandaloneWithResponse(String region, RequestOptions requestOptions) { + return service.getStandaloneSync(this.getEndpoint(), this.getName(), region, requestOptions, Context.NONE); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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> deleteStandaloneWithResponseAsync(String region, RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.deleteStandalone(this.getEndpoint(), this.getName(), region, requestOptions, context)); + } + + /** + * The deleteStandalone operation. + * + * @param region The region 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 deleteStandaloneWithResponse(String region, RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getName(), region, requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithMultipleClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithMultipleClientImpl.java new file mode 100644 index 0000000000..3127e122df --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithMultipleClientImpl.java @@ -0,0 +1,328 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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.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 IndividuallyParentNestedWithMultipleClient type. + */ +public final class IndividuallyParentNestedWithMultipleClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyParentNestedWithMultipleClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String name; + + /** + * Gets. + * + * @return the name value. + */ + public String getName() { + return this.name; + } + + /** + */ + private final String region; + + /** + * Gets. + * + * @return the region value. + */ + public String getRegion() { + return this.region; + } + + /** + * 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 IndividuallyParentNestedWithMultipleClient client. + * + * @param endpoint Service host. + * @param name + * @param region + */ + public IndividuallyParentNestedWithMultipleClientImpl(String endpoint, String name, String region) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name, region); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithMultipleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param name + * @param region + */ + public IndividuallyParentNestedWithMultipleClientImpl(HttpPipeline httpPipeline, String endpoint, String name, + String region) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, name, region); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithMultipleClient 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 name + * @param region + */ + public IndividuallyParentNestedWithMultipleClientImpl(HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, String endpoint, String name, String region) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.name = name; + this.region = region; + this.service = RestProxy.create(IndividuallyParentNestedWithMultipleClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyParentNestedWithMultipleClient to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyParentNestedWithMultipleClient") + public interface IndividuallyParentNestedWithMultipleClientService { + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-multiple/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-multiple/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-multiple/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-multiple/get-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-multiple/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-multiple/delete-standalone") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, @HeaderParam("name") String name, + @QueryParam("region") String region, RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.withQuery(this.getEndpoint(), this.getName(), this.getRegion(), + requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getName(), this.getRegion(), requestOptions, + Context.NONE); + } + + /** + * The getStandalone 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> getStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.getStandalone(this.getEndpoint(), this.getName(), + this.getRegion(), requestOptions, context)); + } + + /** + * The getStandalone 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 getStandaloneWithResponse(RequestOptions requestOptions) { + return service.getStandaloneSync(this.getEndpoint(), this.getName(), this.getRegion(), requestOptions, + Context.NONE); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.deleteStandalone(this.getEndpoint(), this.getName(), + this.getRegion(), requestOptions, context)); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getName(), this.getRegion(), requestOptions, + Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithParamAliasClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithParamAliasClientImpl.java new file mode 100644 index 0000000000..c45bcc7fe6 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithParamAliasClientImpl.java @@ -0,0 +1,243 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.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 IndividuallyParentNestedWithParamAliasClient type. + */ +public final class IndividuallyParentNestedWithParamAliasClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyParentNestedWithParamAliasClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String blobName; + + /** + * Gets. + * + * @return the blobName value. + */ + public String getBlobName() { + return this.blobName; + } + + /** + * 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 IndividuallyParentNestedWithParamAliasClient client. + * + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyParentNestedWithParamAliasClientImpl(String endpoint, String blobName) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithParamAliasClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyParentNestedWithParamAliasClientImpl(HttpPipeline httpPipeline, String endpoint, + String blobName) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithParamAliasClient 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 blobName + */ + public IndividuallyParentNestedWithParamAliasClientImpl(HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, String endpoint, String blobName) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.blobName = blobName; + this.service = RestProxy.create(IndividuallyParentNestedWithParamAliasClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyParentNestedWithParamAliasClient to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyParentNestedWithParamAliasClient") + public interface IndividuallyParentNestedWithParamAliasClientService { + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/{blob}/with-aliased-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withAliasedName(@HostParam("endpoint") String endpoint, @PathParam("blob") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/{blob}/with-aliased-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withAliasedNameSync(@HostParam("endpoint") String endpoint, @PathParam("blob") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/{blobName}/with-original-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withOriginalName(@HostParam("endpoint") String endpoint, + @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-param-alias/{blobName}/with-original-name") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withOriginalNameSync(@HostParam("endpoint") String endpoint, + @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); + } + + /** + * The withAliasedName 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> withAliasedNameWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withAliasedName(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The withAliasedName 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 withAliasedNameWithResponse(RequestOptions requestOptions) { + return service.withAliasedNameSync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } + + /** + * The withOriginalName 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> withOriginalNameWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.withOriginalName(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The withOriginalName 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 withOriginalNameWithResponse(RequestOptions requestOptions) { + return service.withOriginalNameSync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithPathClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithPathClientImpl.java new file mode 100644 index 0000000000..bcf99fe609 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithPathClientImpl.java @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.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.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; + +/** + * Initializes a new instance of the IndividuallyParentNestedWithPathClient type. + */ +public final class IndividuallyParentNestedWithPathClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyParentNestedWithPathClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String blobName; + + /** + * Gets. + * + * @return the blobName value. + */ + public String getBlobName() { + return this.blobName; + } + + /** + * 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 IndividuallyParentNestedWithPathClient client. + * + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyParentNestedWithPathClientImpl(String endpoint, String blobName) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithPathClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyParentNestedWithPathClientImpl(HttpPipeline httpPipeline, String endpoint, String blobName) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithPathClient 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 blobName + */ + public IndividuallyParentNestedWithPathClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String blobName) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.blobName = blobName; + this.service = RestProxy.create(IndividuallyParentNestedWithPathClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyParentNestedWithPathClient to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyParentNestedWithPathClient") + public interface IndividuallyParentNestedWithPathClientService { + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent/{blobName}/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent/{blobName}/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @PathParam("blobName") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent/{blobName}/get-standalone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, + @PathParam("blobName") String blobName, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent/{blobName}/get-standalone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, + @PathParam("blobName") String blobName, @HeaderParam("Accept") String accept, RequestOptions requestOptions, + Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent/{blobName}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, + @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent/{blobName}") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, + @PathParam("blobName") String blobName, RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withQuery(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStandaloneWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getStandalone(this.getEndpoint(), this.getBlobName(), accept, requestOptions, context)); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStandaloneWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getStandaloneSync(this.getEndpoint(), this.getBlobName(), accept, requestOptions, Context.NONE); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.deleteStandalone(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithQueryClientImpl.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithQueryClientImpl.java new file mode 100644 index 0000000000..c66818ef39 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/IndividuallyParentNestedWithQueryClientImpl.java @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +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; + +/** + * Initializes a new instance of the IndividuallyParentNestedWithQueryClient type. + */ +public final class IndividuallyParentNestedWithQueryClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IndividuallyParentNestedWithQueryClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + */ + private final String blobName; + + /** + * Gets. + * + * @return the blobName value. + */ + public String getBlobName() { + return this.blobName; + } + + /** + * 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 IndividuallyParentNestedWithQueryClient client. + * + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyParentNestedWithQueryClientImpl(String endpoint, String blobName) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithQueryClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + * @param blobName + */ + public IndividuallyParentNestedWithQueryClientImpl(HttpPipeline httpPipeline, String endpoint, String blobName) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, blobName); + } + + /** + * Initializes an instance of IndividuallyParentNestedWithQueryClient 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 blobName + */ + public IndividuallyParentNestedWithQueryClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint, String blobName) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.blobName = blobName; + this.service = RestProxy.create(IndividuallyParentNestedWithQueryClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for IndividuallyParentNestedWithQueryClient to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "IndividuallyParentNestedWithQueryClient") + public interface IndividuallyParentNestedWithQueryClientService { + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-query/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> withQuery(@HostParam("endpoint") String endpoint, @QueryParam("blobName") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-query/with-query") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response withQuerySync(@HostParam("endpoint") String endpoint, @QueryParam("blobName") String blobName, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-query/get-standalone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getStandalone(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Get("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-query/get-standalone") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getStandaloneSync(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, @HeaderParam("Accept") String accept, + RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-query/delete-resource") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> deleteStandalone(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, RequestOptions requestOptions, Context context); + + @Delete("/azure/client-generator-core/client-initialization/individually-parent/nested-default-individually-parent-query/delete-resource") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response deleteStandaloneSync(@HostParam("endpoint") String endpoint, + @QueryParam("blobName") String blobName, RequestOptions requestOptions, Context context); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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> withQueryWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil + .withContext(context -> service.withQuery(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The withQuery operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
formatStringNoThe format parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + * + * @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 withQueryWithResponse(RequestOptions requestOptions) { + return service.withQuerySync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getStandaloneWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.getStandalone(this.getEndpoint(), this.getBlobName(), accept, requestOptions, context)); + } + + /** + * The getStandalone operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     size: long (Required)
+     *     contentType: String (Required)
+     *     createdOn: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @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 properties of a blob along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getStandaloneWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getStandaloneSync(this.getEndpoint(), this.getBlobName(), accept, requestOptions, Context.NONE); + } + + /** + * The deleteStandalone 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> deleteStandaloneWithResponseAsync(RequestOptions requestOptions) { + return FluxUtil.withContext( + context -> service.deleteStandalone(this.getEndpoint(), this.getBlobName(), requestOptions, context)); + } + + /** + * The deleteStandalone 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 deleteStandaloneWithResponse(RequestOptions requestOptions) { + return service.deleteStandaloneSync(this.getEndpoint(), this.getBlobName(), requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/package-info.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/package-info.java new file mode 100644 index 0000000000..38e4e189db --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/implementation/package-info.java @@ -0,0 +1,11 @@ +// 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 IndividuallyParentClient. + * Test for client initialization decorator - moving parameters from method to client level. + * + */ +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.implementation; diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/models/BlobProperties.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/models/BlobProperties.java new file mode 100644 index 0000000000..9896d015b2 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/models/BlobProperties.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Properties of a blob. + */ +@Immutable +public final class BlobProperties implements JsonSerializable { + /* + * The name property. + */ + @Generated + private final String name; + + /* + * The size property. + */ + @Generated + private final long size; + + /* + * The contentType property. + */ + @Generated + private final String contentType; + + /* + * The createdOn property. + */ + @Generated + private final OffsetDateTime createdOn; + + /** + * Creates an instance of BlobProperties class. + * + * @param name the name value to set. + * @param size the size value to set. + * @param contentType the contentType value to set. + * @param createdOn the createdOn value to set. + */ + @Generated + private BlobProperties(String name, long size, String contentType, OffsetDateTime createdOn) { + this.name = name; + this.size = size; + this.contentType = contentType; + this.createdOn = createdOn; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Get the size property: The size property. + * + * @return the size value. + */ + @Generated + public long getSize() { + return this.size; + } + + /** + * Get the contentType property: The contentType property. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Get the createdOn property: The createdOn property. + * + * @return the createdOn value. + */ + @Generated + public OffsetDateTime getCreatedOn() { + return this.createdOn; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeLongField("size", this.size); + jsonWriter.writeStringField("contentType", this.contentType); + jsonWriter.writeStringField("createdOn", + this.createdOn == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.createdOn)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobProperties 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 BlobProperties. + */ + @Generated + public static BlobProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + long size = 0L; + String contentType = null; + OffsetDateTime createdOn = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("size".equals(fieldName)) { + size = reader.getLong(); + } else if ("contentType".equals(fieldName)) { + contentType = reader.getString(); + } else if ("createdOn".equals(fieldName)) { + createdOn = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new BlobProperties(name, size, contentType, createdOn); + }); + } +} diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/models/package-info.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/models/package-info.java new file mode 100644 index 0000000000..0cfc765fd3 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/models/package-info.java @@ -0,0 +1,11 @@ +// 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 IndividuallyParentClient. + * Test for client initialization decorator - moving parameters from method to client level. + * + */ +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.models; diff --git a/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/package-info.java b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/package-info.java new file mode 100644 index 0000000000..d7088f0d78 --- /dev/null +++ b/typespec-tests/src/main/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/package-info.java @@ -0,0 +1,11 @@ +// 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 IndividuallyParentClient. + * Test for client initialization decorator - moving parameters from method to client level. + * + */ +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient; diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ParentAsyncClient.java b/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ParentAsyncClient.java deleted file mode 100644 index 773affee93..0000000000 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ParentAsyncClient.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package azure.clientgenerator.core.clientinitialization.parentclient; - -import azure.clientgenerator.core.clientinitialization.implementation.ParentClientImpl; -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClient; - -/** - * Initializes a new instance of the asynchronous ParentClient type. - */ -@ServiceClient(builder = ParentClientBuilder.class, isAsync = true) -public final class ParentAsyncClient { - @Generated - private final ParentClientImpl serviceClient; - - /** - * Initializes an instance of ParentAsyncClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - ParentAsyncClient(ParentClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * Gets an instance of ChildAsyncClient class. - * - * @param blobName The blobName parameter. - * @return an instance of ChildAsyncClient class. - */ - public ChildAsyncClient getChildAsyncClient(String blobName) { - return new ChildAsyncClient(serviceClient.getChildClient(blobName)); - } -} diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ParentClient.java b/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ParentClient.java deleted file mode 100644 index a0f775904c..0000000000 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ParentClient.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) TypeSpec Code Generator. - -package azure.clientgenerator.core.clientinitialization.parentclient; - -import azure.clientgenerator.core.clientinitialization.implementation.ParentClientImpl; -import com.azure.core.annotation.Generated; -import com.azure.core.annotation.ServiceClient; - -/** - * Initializes a new instance of the synchronous ParentClient type. - */ -@ServiceClient(builder = ParentClientBuilder.class) -public final class ParentClient { - @Generated - private final ParentClientImpl serviceClient; - - /** - * Initializes an instance of ParentClient class. - * - * @param serviceClient the service client implementation. - */ - @Generated - ParentClient(ParentClientImpl serviceClient) { - this.serviceClient = serviceClient; - } - - /** - * Gets an instance of ChildClient class. - * - * @param blobName The blobName parameter. - * @return an instance of ChildClient class. - */ - public ChildClient getChildClient(String blobName) { - return new ChildClient(serviceClient.getChildClient(blobName)); - } -} diff --git a/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/fluent/LroesClient.java b/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/fluent/LroesClient.java index a3b6d81429..25550dca7a 100644 --- a/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/fluent/LroesClient.java +++ b/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/fluent/LroesClient.java @@ -12,6 +12,7 @@ import com.azure.core.management.polling.PollResult; import com.azure.core.util.Context; import com.azure.core.util.polling.SyncPoller; +import java.util.List; /** * An instance of this class provides access to all the operations defined in LroesClient. @@ -190,4 +191,55 @@ SyncPoller, ExportResultInner> beginExport(String */ @ServiceMethod(returns = ReturnType.SINGLE) void delete(String resourceGroupName, String orderName, Context context); + + /** + * The exportArray operation. + * + * @param body The request body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller>, List> beginExportArray(ExportRequest body); + + /** + * The exportArray operation. + * + * @param body The request body. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller>, List> beginExportArray(ExportRequest body, + Context context); + + /** + * The exportArray operation. + * + * @param body The request body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + List exportArray(ExportRequest body); + + /** + * The exportArray operation. + * + * @param body The request body. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + List exportArray(ExportRequest body, Context context); } diff --git a/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/implementation/LroesClientImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/implementation/LroesClientImpl.java index e713f22453..c9de25e34a 100644 --- a/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/implementation/LroesClientImpl.java +++ b/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/implementation/LroesClientImpl.java @@ -32,7 +32,9 @@ import com.azure.core.util.FluxUtil; import com.azure.core.util.polling.PollerFlux; import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.TypeReference; import java.nio.ByteBuffer; +import java.util.List; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -120,6 +122,22 @@ Response deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, @PathParam("resourceGroupName") String resourceGroupName, @PathParam("orderName") String orderName, Context context); + + @Post("/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/exportArray") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> exportArray(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ExportRequest body, Context context); + + @Post("/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/exportArray") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response exportArraySync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ExportRequest body, Context context); } /** @@ -615,4 +633,163 @@ public void delete(String resourceGroupName, String orderName) { public void delete(String resourceGroupName, String orderName, Context context) { beginDelete(resourceGroupName, orderName, context).getFinalResult(); } + + /** + * The exportArray operation. + * + * @param body The request body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> exportArrayWithResponseAsync(ExportRequest body) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.exportArray(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), contentType, accept, body, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * The exportArray operation. + * + * @param body The request body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response exportArrayWithResponse(ExportRequest body) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.exportArraySync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), contentType, accept, body, Context.NONE); + } + + /** + * The exportArray operation. + * + * @param body The request body. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response exportArrayWithResponse(ExportRequest body, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.exportArraySync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), contentType, accept, body, context); + } + + /** + * The exportArray operation. + * + * @param body The request body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux>, List> + beginExportArrayAsync(ExportRequest body) { + Mono>> mono = exportArrayWithResponseAsync(body); + return this.client., List>getLroResult(mono, + this.client.getHttpPipeline(), new TypeReference>() { + }.getJavaType(), new TypeReference>() { + }.getJavaType(), this.client.getContext()); + } + + /** + * The exportArray operation. + * + * @param body The request body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller>, List> + beginExportArray(ExportRequest body) { + Response response = exportArrayWithResponse(body); + return this.client., List>getLroResult(response, + new TypeReference>() { + }.getJavaType(), new TypeReference>() { + }.getJavaType(), Context.NONE); + } + + /** + * The exportArray operation. + * + * @param body The request body. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller>, List> beginExportArray(ExportRequest body, + Context context) { + Response response = exportArrayWithResponse(body, context); + return this.client., List>getLroResult(response, + new TypeReference>() { + }.getJavaType(), new TypeReference>() { + }.getJavaType(), context); + } + + /** + * The exportArray operation. + * + * @param body The request body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> exportArrayAsync(ExportRequest body) { + return beginExportArrayAsync(body).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * The exportArray operation. + * + * @param body The request body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public List exportArray(ExportRequest body) { + return beginExportArray(body).getFinalResult(); + } + + /** + * The exportArray operation. + * + * @param body The request body. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public List exportArray(ExportRequest body, Context context) { + return beginExportArray(body, context).getFinalResult(); + } + + private static final TypeReference> TYPE_REFERENCE_LIST_EXPORT_RESULT_INNER + = new TypeReference>() { + }; } diff --git a/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/implementation/LroesImpl.java b/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/implementation/LroesImpl.java index b528a78346..a4a016ccae 100644 --- a/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/implementation/LroesImpl.java +++ b/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/implementation/LroesImpl.java @@ -11,6 +11,9 @@ import azure.resourcemanager.operationtemplates.models.Lroes; import com.azure.core.util.Context; import com.azure.core.util.logging.ClientLogger; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; public final class LroesImpl implements Lroes { private static final ClientLogger LOGGER = new ClientLogger(LroesImpl.class); @@ -51,6 +54,28 @@ public void delete(String resourceGroupName, String orderName, Context context) this.serviceClient().delete(resourceGroupName, orderName, context); } + public List exportArray(ExportRequest body) { + List inner = this.serviceClient().exportArray(body); + if (inner != null) { + return Collections.unmodifiableList(inner.stream() + .map(inner1 -> new ExportResultImpl(inner1, this.manager())) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public List exportArray(ExportRequest body, Context context) { + List inner = this.serviceClient().exportArray(body, context); + if (inner != null) { + return Collections.unmodifiableList(inner.stream() + .map(inner1 -> new ExportResultImpl(inner1, this.manager())) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + public void deleteById(String id) { String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); if (resourceGroupName == null) { diff --git a/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/models/Lroes.java b/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/models/Lroes.java index 92398ca748..6ec7337eed 100644 --- a/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/models/Lroes.java +++ b/typespec-tests/src/main/java/azure/resourcemanager/operationtemplates/models/Lroes.java @@ -5,6 +5,7 @@ package azure.resourcemanager.operationtemplates.models; import com.azure.core.util.Context; +import java.util.List; /** * Resource collection API of Lroes. @@ -60,6 +61,29 @@ public interface Lroes { */ void delete(String resourceGroupName, String orderName, Context context); + /** + * The exportArray operation. + * + * @param body The request body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + List exportArray(ExportRequest body); + + /** + * The exportArray operation. + * + * @param body The request body. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + List exportArray(ExportRequest body, Context context); + /** * Delete a Order. * diff --git a/typespec-tests/src/main/java/encode/array/ArrayAsyncClient.java b/typespec-tests/src/main/java/encode/array/ArrayAsyncClient.java index c1f6104946..7667b905ee 100644 --- a/typespec-tests/src/main/java/encode/array/ArrayAsyncClient.java +++ b/typespec-tests/src/main/java/encode/array/ArrayAsyncClient.java @@ -18,9 +18,17 @@ import com.azure.core.util.FluxUtil; import encode.array.implementation.PropertiesImpl; import encode.array.models.CommaDelimitedArrayProperty; +import encode.array.models.CommaDelimitedEnumArrayProperty; +import encode.array.models.CommaDelimitedExtensibleEnumArrayProperty; import encode.array.models.NewlineDelimitedArrayProperty; +import encode.array.models.NewlineDelimitedEnumArrayProperty; +import encode.array.models.NewlineDelimitedExtensibleEnumArrayProperty; import encode.array.models.PipeDelimitedArrayProperty; +import encode.array.models.PipeDelimitedEnumArrayProperty; +import encode.array.models.PipeDelimitedExtensibleEnumArrayProperty; import encode.array.models.SpaceDelimitedArrayProperty; +import encode.array.models.SpaceDelimitedEnumArrayProperty; +import encode.array.models.SpaceDelimitedExtensibleEnumArrayProperty; import reactor.core.publisher.Mono; /** @@ -201,6 +209,330 @@ public Mono> newlineDelimitedWithResponse(BinaryData body, return this.serviceClient.newlineDelimitedWithResponseAsync(body, requestOptions); } + /** + * The enumCommaDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> enumCommaDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.enumCommaDelimitedWithResponseAsync(body, requestOptions); + } + + /** + * The enumSpaceDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> enumSpaceDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.enumSpaceDelimitedWithResponseAsync(body, requestOptions); + } + + /** + * The enumPipeDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> enumPipeDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.enumPipeDelimitedWithResponseAsync(body, requestOptions); + } + + /** + * The enumNewlineDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> enumNewlineDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.enumNewlineDelimitedWithResponseAsync(body, requestOptions); + } + + /** + * The extensibleEnumCommaDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> extensibleEnumCommaDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.extensibleEnumCommaDelimitedWithResponseAsync(body, requestOptions); + } + + /** + * The extensibleEnumSpaceDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> extensibleEnumSpaceDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.extensibleEnumSpaceDelimitedWithResponseAsync(body, requestOptions); + } + + /** + * The extensibleEnumPipeDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> extensibleEnumPipeDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.extensibleEnumPipeDelimitedWithResponseAsync(body, requestOptions); + } + + /** + * The extensibleEnumNewlineDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> extensibleEnumNewlineDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.extensibleEnumNewlineDelimitedWithResponseAsync(body, requestOptions); + } + /** * The commaDelimited operation. * @@ -284,4 +616,180 @@ public Mono newlineDelimited(NewlineDelimitedArra return newlineDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(NewlineDelimitedArrayProperty.class)); } + + /** + * The enumCommaDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono enumCommaDelimited(CommaDelimitedEnumArrayProperty body) { + // Generated convenience method for enumCommaDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return enumCommaDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CommaDelimitedEnumArrayProperty.class)); + } + + /** + * The enumSpaceDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono enumSpaceDelimited(SpaceDelimitedEnumArrayProperty body) { + // Generated convenience method for enumSpaceDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return enumSpaceDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpaceDelimitedEnumArrayProperty.class)); + } + + /** + * The enumPipeDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono enumPipeDelimited(PipeDelimitedEnumArrayProperty body) { + // Generated convenience method for enumPipeDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return enumPipeDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PipeDelimitedEnumArrayProperty.class)); + } + + /** + * The enumNewlineDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono enumNewlineDelimited(NewlineDelimitedEnumArrayProperty body) { + // Generated convenience method for enumNewlineDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return enumNewlineDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(NewlineDelimitedEnumArrayProperty.class)); + } + + /** + * The extensibleEnumCommaDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono + extensibleEnumCommaDelimited(CommaDelimitedExtensibleEnumArrayProperty body) { + // Generated convenience method for extensibleEnumCommaDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return extensibleEnumCommaDelimitedWithResponse(BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CommaDelimitedExtensibleEnumArrayProperty.class)); + } + + /** + * The extensibleEnumSpaceDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono + extensibleEnumSpaceDelimited(SpaceDelimitedExtensibleEnumArrayProperty body) { + // Generated convenience method for extensibleEnumSpaceDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return extensibleEnumSpaceDelimitedWithResponse(BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(SpaceDelimitedExtensibleEnumArrayProperty.class)); + } + + /** + * The extensibleEnumPipeDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono + extensibleEnumPipeDelimited(PipeDelimitedExtensibleEnumArrayProperty body) { + // Generated convenience method for extensibleEnumPipeDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return extensibleEnumPipeDelimitedWithResponse(BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(PipeDelimitedExtensibleEnumArrayProperty.class)); + } + + /** + * The extensibleEnumNewlineDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono + extensibleEnumNewlineDelimited(NewlineDelimitedExtensibleEnumArrayProperty body) { + // Generated convenience method for extensibleEnumNewlineDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return extensibleEnumNewlineDelimitedWithResponse(BinaryData.fromObject(body), requestOptions) + .flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(NewlineDelimitedExtensibleEnumArrayProperty.class)); + } } diff --git a/typespec-tests/src/main/java/encode/array/ArrayClient.java b/typespec-tests/src/main/java/encode/array/ArrayClient.java index eba503c660..6b45a6a9fc 100644 --- a/typespec-tests/src/main/java/encode/array/ArrayClient.java +++ b/typespec-tests/src/main/java/encode/array/ArrayClient.java @@ -17,9 +17,17 @@ import com.azure.core.util.BinaryData; import encode.array.implementation.PropertiesImpl; import encode.array.models.CommaDelimitedArrayProperty; +import encode.array.models.CommaDelimitedEnumArrayProperty; +import encode.array.models.CommaDelimitedExtensibleEnumArrayProperty; import encode.array.models.NewlineDelimitedArrayProperty; +import encode.array.models.NewlineDelimitedEnumArrayProperty; +import encode.array.models.NewlineDelimitedExtensibleEnumArrayProperty; import encode.array.models.PipeDelimitedArrayProperty; +import encode.array.models.PipeDelimitedEnumArrayProperty; +import encode.array.models.PipeDelimitedExtensibleEnumArrayProperty; import encode.array.models.SpaceDelimitedArrayProperty; +import encode.array.models.SpaceDelimitedEnumArrayProperty; +import encode.array.models.SpaceDelimitedExtensibleEnumArrayProperty; /** * Initializes a new instance of the synchronous ArrayClient type. @@ -199,6 +207,330 @@ public Response newlineDelimitedWithResponse(BinaryData body, Reques return this.serviceClient.newlineDelimitedWithResponse(body, requestOptions); } + /** + * The enumCommaDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response enumCommaDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.enumCommaDelimitedWithResponse(body, requestOptions); + } + + /** + * The enumSpaceDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response enumSpaceDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.enumSpaceDelimitedWithResponse(body, requestOptions); + } + + /** + * The enumPipeDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response enumPipeDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.enumPipeDelimitedWithResponse(body, requestOptions); + } + + /** + * The enumNewlineDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response enumNewlineDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.enumNewlineDelimitedWithResponse(body, requestOptions); + } + + /** + * The extensibleEnumCommaDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response extensibleEnumCommaDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.extensibleEnumCommaDelimitedWithResponse(body, requestOptions); + } + + /** + * The extensibleEnumSpaceDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response extensibleEnumSpaceDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.extensibleEnumSpaceDelimitedWithResponse(body, requestOptions); + } + + /** + * The extensibleEnumPipeDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response extensibleEnumPipeDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.extensibleEnumPipeDelimitedWithResponse(body, requestOptions); + } + + /** + * The extensibleEnumNewlineDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response extensibleEnumNewlineDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.extensibleEnumNewlineDelimitedWithResponse(body, requestOptions); + } + /** * The commaDelimited operation. * @@ -282,4 +614,176 @@ public NewlineDelimitedArrayProperty newlineDelimited(NewlineDelimitedArrayPrope return newlineDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() .toObject(NewlineDelimitedArrayProperty.class); } + + /** + * The enumCommaDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CommaDelimitedEnumArrayProperty enumCommaDelimited(CommaDelimitedEnumArrayProperty body) { + // Generated convenience method for enumCommaDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return enumCommaDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(CommaDelimitedEnumArrayProperty.class); + } + + /** + * The enumSpaceDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpaceDelimitedEnumArrayProperty enumSpaceDelimited(SpaceDelimitedEnumArrayProperty body) { + // Generated convenience method for enumSpaceDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return enumSpaceDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(SpaceDelimitedEnumArrayProperty.class); + } + + /** + * The enumPipeDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PipeDelimitedEnumArrayProperty enumPipeDelimited(PipeDelimitedEnumArrayProperty body) { + // Generated convenience method for enumPipeDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return enumPipeDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(PipeDelimitedEnumArrayProperty.class); + } + + /** + * The enumNewlineDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public NewlineDelimitedEnumArrayProperty enumNewlineDelimited(NewlineDelimitedEnumArrayProperty body) { + // Generated convenience method for enumNewlineDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return enumNewlineDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(NewlineDelimitedEnumArrayProperty.class); + } + + /** + * The extensibleEnumCommaDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CommaDelimitedExtensibleEnumArrayProperty + extensibleEnumCommaDelimited(CommaDelimitedExtensibleEnumArrayProperty body) { + // Generated convenience method for extensibleEnumCommaDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return extensibleEnumCommaDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(CommaDelimitedExtensibleEnumArrayProperty.class); + } + + /** + * The extensibleEnumSpaceDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public SpaceDelimitedExtensibleEnumArrayProperty + extensibleEnumSpaceDelimited(SpaceDelimitedExtensibleEnumArrayProperty body) { + // Generated convenience method for extensibleEnumSpaceDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return extensibleEnumSpaceDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(SpaceDelimitedExtensibleEnumArrayProperty.class); + } + + /** + * The extensibleEnumPipeDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public PipeDelimitedExtensibleEnumArrayProperty + extensibleEnumPipeDelimited(PipeDelimitedExtensibleEnumArrayProperty body) { + // Generated convenience method for extensibleEnumPipeDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return extensibleEnumPipeDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(PipeDelimitedExtensibleEnumArrayProperty.class); + } + + /** + * The extensibleEnumNewlineDelimited operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public NewlineDelimitedExtensibleEnumArrayProperty + extensibleEnumNewlineDelimited(NewlineDelimitedExtensibleEnumArrayProperty body) { + // Generated convenience method for extensibleEnumNewlineDelimitedWithResponse + RequestOptions requestOptions = new RequestOptions(); + return extensibleEnumNewlineDelimitedWithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(NewlineDelimitedExtensibleEnumArrayProperty.class); + } } diff --git a/typespec-tests/src/main/java/encode/array/implementation/PropertiesImpl.java b/typespec-tests/src/main/java/encode/array/implementation/PropertiesImpl.java index ee142d6851..fc32d96316 100644 --- a/typespec-tests/src/main/java/encode/array/implementation/PropertiesImpl.java +++ b/typespec-tests/src/main/java/encode/array/implementation/PropertiesImpl.java @@ -137,6 +137,166 @@ Mono> newlineDelimited(@HostParam("endpoint") String endpoi Response newlineDelimitedSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/enum/comma-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> enumCommaDelimited(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/enum/comma-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response enumCommaDelimitedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/enum/space-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> enumSpaceDelimited(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/enum/space-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response enumSpaceDelimitedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/enum/pipe-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> enumPipeDelimited(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/enum/pipe-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response enumPipeDelimitedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/enum/newline-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> enumNewlineDelimited(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/enum/newline-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response enumNewlineDelimitedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/extensible-enum/comma-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> extensibleEnumCommaDelimited(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/extensible-enum/comma-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response extensibleEnumCommaDelimitedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/extensible-enum/space-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> extensibleEnumSpaceDelimited(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/extensible-enum/space-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response extensibleEnumSpaceDelimitedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/extensible-enum/pipe-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> extensibleEnumPipeDelimited(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/extensible-enum/pipe-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response extensibleEnumPipeDelimitedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/extensible-enum/newline-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> extensibleEnumNewlineDelimited(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); + + @Post("/encode/array/property/extensible-enum/newline-delimited") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response extensibleEnumNewlineDelimitedSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); } /** @@ -475,4 +635,688 @@ public Response newlineDelimitedWithResponse(BinaryData body, Reques return service.newlineDelimitedSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, Context.NONE); } + + /** + * The enumCommaDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> enumCommaDelimitedWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.enumCommaDelimited(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); + } + + /** + * The enumCommaDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response enumCommaDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.enumCommaDelimitedSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The enumSpaceDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> enumSpaceDelimitedWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.enumSpaceDelimited(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); + } + + /** + * The enumSpaceDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response enumSpaceDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.enumSpaceDelimitedSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The enumPipeDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> enumPipeDelimitedWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.enumPipeDelimited(this.client.getEndpoint(), contentType, accept, + body, requestOptions, context)); + } + + /** + * The enumPipeDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response enumPipeDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.enumPipeDelimitedSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The enumNewlineDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> enumNewlineDelimitedWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.enumNewlineDelimited(this.client.getEndpoint(), contentType, + accept, body, requestOptions, context)); + } + + /** + * The enumNewlineDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response enumNewlineDelimitedWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.enumNewlineDelimitedSync(this.client.getEndpoint(), contentType, accept, body, requestOptions, + Context.NONE); + } + + /** + * The extensibleEnumCommaDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> extensibleEnumCommaDelimitedWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.extensibleEnumCommaDelimited(this.client.getEndpoint(), + contentType, accept, body, requestOptions, context)); + } + + /** + * The extensibleEnumCommaDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response extensibleEnumCommaDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.extensibleEnumCommaDelimitedSync(this.client.getEndpoint(), contentType, accept, body, + requestOptions, Context.NONE); + } + + /** + * The extensibleEnumSpaceDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> extensibleEnumSpaceDelimitedWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.extensibleEnumSpaceDelimited(this.client.getEndpoint(), + contentType, accept, body, requestOptions, context)); + } + + /** + * The extensibleEnumSpaceDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response extensibleEnumSpaceDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.extensibleEnumSpaceDelimitedSync(this.client.getEndpoint(), contentType, accept, body, + requestOptions, Context.NONE); + } + + /** + * The extensibleEnumPipeDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> extensibleEnumPipeDelimitedWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.extensibleEnumPipeDelimited(this.client.getEndpoint(), + contentType, accept, body, requestOptions, context)); + } + + /** + * The extensibleEnumPipeDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response extensibleEnumPipeDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.extensibleEnumPipeDelimitedSync(this.client.getEndpoint(), contentType, accept, body, + requestOptions, Context.NONE); + } + + /** + * The extensibleEnumNewlineDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> extensibleEnumNewlineDelimitedWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.extensibleEnumNewlineDelimited(this.client.getEndpoint(), + contentType, accept, body, requestOptions, context)); + } + + /** + * The extensibleEnumNewlineDelimited operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value (Required): [
+     *         String(blue/red/green) (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response extensibleEnumNewlineDelimitedWithResponse(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.extensibleEnumNewlineDelimitedSync(this.client.getEndpoint(), contentType, accept, body, + requestOptions, Context.NONE); + } } diff --git a/typespec-tests/src/main/java/encode/array/models/Colors.java b/typespec-tests/src/main/java/encode/array/models/Colors.java new file mode 100644 index 0000000000..b06e7be454 --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/Colors.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.models; + +/** + * Defines values for Colors. + */ +public enum Colors { + /** + * Enum value blue. + */ + BLUE("blue"), + + /** + * Enum value red. + */ + RED("red"), + + /** + * Enum value green. + */ + GREEN("green"); + + /** + * The actual serialized value for a Colors instance. + */ + private final String value; + + Colors(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Colors instance. + * + * @param value the serialized value to parse. + * @return the parsed Colors object, or null if unable to parse. + */ + public static Colors fromString(String value) { + if (value == null) { + return null; + } + Colors[] items = Colors.values(); + for (Colors item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/typespec-tests/src/main/java/encode/array/models/ColorsExtensibleEnum.java b/typespec-tests/src/main/java/encode/array/models/ColorsExtensibleEnum.java new file mode 100644 index 0000000000..bad0c8525e --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/ColorsExtensibleEnum.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Defines values for ColorsExtensibleEnum. + */ +public final class ColorsExtensibleEnum extends ExpandableStringEnum { + /** + * Static value blue for ColorsExtensibleEnum. + */ + @Generated + public static final ColorsExtensibleEnum BLUE = fromString("blue"); + + /** + * Static value red for ColorsExtensibleEnum. + */ + @Generated + public static final ColorsExtensibleEnum RED = fromString("red"); + + /** + * Static value green for ColorsExtensibleEnum. + */ + @Generated + public static final ColorsExtensibleEnum GREEN = fromString("green"); + + /** + * Creates a new instance of ColorsExtensibleEnum value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ColorsExtensibleEnum() { + } + + /** + * Creates or finds a ColorsExtensibleEnum from its string representation. + * + * @param name a name to look for. + * @return the corresponding ColorsExtensibleEnum. + */ + @Generated + public static ColorsExtensibleEnum fromString(String name) { + return fromString(name, ColorsExtensibleEnum.class); + } + + /** + * Gets known ColorsExtensibleEnum values. + * + * @return known ColorsExtensibleEnum values. + */ + @Generated + public static Collection values() { + return values(ColorsExtensibleEnum.class); + } +} diff --git a/typespec-tests/src/main/java/encode/array/models/CommaDelimitedEnumArrayProperty.java b/typespec-tests/src/main/java/encode/array/models/CommaDelimitedEnumArrayProperty.java new file mode 100644 index 0000000000..c6309be814 --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/CommaDelimitedEnumArrayProperty.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.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; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The CommaDelimitedEnumArrayProperty model. + */ +@Immutable +public final class CommaDelimitedEnumArrayProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of CommaDelimitedEnumArrayProperty class. + * + * @param value the value value to set. + */ + @Generated + public CommaDelimitedEnumArrayProperty(List value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (this.value != null) { + jsonWriter.writeStringField("value", + this.value.stream() + .map(element -> element == null ? null : element.toString()) + .collect(Collectors.joining(","))); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CommaDelimitedEnumArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CommaDelimitedEnumArrayProperty 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 CommaDelimitedEnumArrayProperty. + */ + @Generated + public static CommaDelimitedEnumArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> { + String valueEncodedAsString = nonNullReader.getString(); + return valueEncodedAsString.isEmpty() + ? new LinkedList<>() + : new LinkedList<>(Arrays.stream(valueEncodedAsString.split(",", -1)) + .map(valueAsString -> valueAsString == null ? null : Colors.fromString(valueAsString)) + .collect(Collectors.toList())); + }); + } else { + reader.skipChildren(); + } + } + return new CommaDelimitedEnumArrayProperty(value); + }); + } +} diff --git a/typespec-tests/src/main/java/encode/array/models/CommaDelimitedExtensibleEnumArrayProperty.java b/typespec-tests/src/main/java/encode/array/models/CommaDelimitedExtensibleEnumArrayProperty.java new file mode 100644 index 0000000000..862f0d90dd --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/CommaDelimitedExtensibleEnumArrayProperty.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.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; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The CommaDelimitedExtensibleEnumArrayProperty model. + */ +@Immutable +public final class CommaDelimitedExtensibleEnumArrayProperty + implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of CommaDelimitedExtensibleEnumArrayProperty class. + * + * @param value the value value to set. + */ + @Generated + public CommaDelimitedExtensibleEnumArrayProperty(List value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (this.value != null) { + jsonWriter.writeStringField("value", + this.value.stream() + .map(element -> element == null ? null : element.toString()) + .collect(Collectors.joining(","))); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CommaDelimitedExtensibleEnumArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CommaDelimitedExtensibleEnumArrayProperty 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 CommaDelimitedExtensibleEnumArrayProperty. + */ + @Generated + public static CommaDelimitedExtensibleEnumArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> { + String valueEncodedAsString = nonNullReader.getString(); + return valueEncodedAsString.isEmpty() + ? new LinkedList<>() + : new LinkedList<>(Arrays.stream(valueEncodedAsString.split(",", -1)) + .map(valueAsString -> valueAsString == null + ? null + : ColorsExtensibleEnum.fromString(valueAsString)) + .collect(Collectors.toList())); + }); + } else { + reader.skipChildren(); + } + } + return new CommaDelimitedExtensibleEnumArrayProperty(value); + }); + } +} diff --git a/typespec-tests/src/main/java/encode/array/models/NewlineDelimitedEnumArrayProperty.java b/typespec-tests/src/main/java/encode/array/models/NewlineDelimitedEnumArrayProperty.java new file mode 100644 index 0000000000..d2ec5f2d1c --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/NewlineDelimitedEnumArrayProperty.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.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; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The NewlineDelimitedEnumArrayProperty model. + */ +@Immutable +public final class NewlineDelimitedEnumArrayProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of NewlineDelimitedEnumArrayProperty class. + * + * @param value the value value to set. + */ + @Generated + public NewlineDelimitedEnumArrayProperty(List value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (this.value != null) { + jsonWriter.writeStringField("value", + this.value.stream() + .map(element -> element == null ? null : element.toString()) + .collect(Collectors.joining("\n"))); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NewlineDelimitedEnumArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NewlineDelimitedEnumArrayProperty 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 NewlineDelimitedEnumArrayProperty. + */ + @Generated + public static NewlineDelimitedEnumArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> { + String valueEncodedAsString = nonNullReader.getString(); + return valueEncodedAsString.isEmpty() + ? new LinkedList<>() + : new LinkedList<>(Arrays.stream(valueEncodedAsString.split("\n", -1)) + .map(valueAsString -> valueAsString == null ? null : Colors.fromString(valueAsString)) + .collect(Collectors.toList())); + }); + } else { + reader.skipChildren(); + } + } + return new NewlineDelimitedEnumArrayProperty(value); + }); + } +} diff --git a/typespec-tests/src/main/java/encode/array/models/NewlineDelimitedExtensibleEnumArrayProperty.java b/typespec-tests/src/main/java/encode/array/models/NewlineDelimitedExtensibleEnumArrayProperty.java new file mode 100644 index 0000000000..10275b48c1 --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/NewlineDelimitedExtensibleEnumArrayProperty.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.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; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The NewlineDelimitedExtensibleEnumArrayProperty model. + */ +@Immutable +public final class NewlineDelimitedExtensibleEnumArrayProperty + implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of NewlineDelimitedExtensibleEnumArrayProperty class. + * + * @param value the value value to set. + */ + @Generated + public NewlineDelimitedExtensibleEnumArrayProperty(List value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (this.value != null) { + jsonWriter.writeStringField("value", + this.value.stream() + .map(element -> element == null ? null : element.toString()) + .collect(Collectors.joining("\n"))); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NewlineDelimitedExtensibleEnumArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NewlineDelimitedExtensibleEnumArrayProperty 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 NewlineDelimitedExtensibleEnumArrayProperty. + */ + @Generated + public static NewlineDelimitedExtensibleEnumArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> { + String valueEncodedAsString = nonNullReader.getString(); + return valueEncodedAsString.isEmpty() + ? new LinkedList<>() + : new LinkedList<>(Arrays.stream(valueEncodedAsString.split("\n", -1)) + .map(valueAsString -> valueAsString == null + ? null + : ColorsExtensibleEnum.fromString(valueAsString)) + .collect(Collectors.toList())); + }); + } else { + reader.skipChildren(); + } + } + return new NewlineDelimitedExtensibleEnumArrayProperty(value); + }); + } +} diff --git a/typespec-tests/src/main/java/encode/array/models/PipeDelimitedEnumArrayProperty.java b/typespec-tests/src/main/java/encode/array/models/PipeDelimitedEnumArrayProperty.java new file mode 100644 index 0000000000..7e599f8552 --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/PipeDelimitedEnumArrayProperty.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.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; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The PipeDelimitedEnumArrayProperty model. + */ +@Immutable +public final class PipeDelimitedEnumArrayProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of PipeDelimitedEnumArrayProperty class. + * + * @param value the value value to set. + */ + @Generated + public PipeDelimitedEnumArrayProperty(List value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (this.value != null) { + jsonWriter.writeStringField("value", + this.value.stream() + .map(element -> element == null ? null : element.toString()) + .collect(Collectors.joining("|"))); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PipeDelimitedEnumArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PipeDelimitedEnumArrayProperty 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 PipeDelimitedEnumArrayProperty. + */ + @Generated + public static PipeDelimitedEnumArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> { + String valueEncodedAsString = nonNullReader.getString(); + return valueEncodedAsString.isEmpty() + ? new LinkedList<>() + : new LinkedList<>(Arrays.stream(valueEncodedAsString.split("\\|", -1)) + .map(valueAsString -> valueAsString == null ? null : Colors.fromString(valueAsString)) + .collect(Collectors.toList())); + }); + } else { + reader.skipChildren(); + } + } + return new PipeDelimitedEnumArrayProperty(value); + }); + } +} diff --git a/typespec-tests/src/main/java/encode/array/models/PipeDelimitedExtensibleEnumArrayProperty.java b/typespec-tests/src/main/java/encode/array/models/PipeDelimitedExtensibleEnumArrayProperty.java new file mode 100644 index 0000000000..c68113ab3c --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/PipeDelimitedExtensibleEnumArrayProperty.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.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; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The PipeDelimitedExtensibleEnumArrayProperty model. + */ +@Immutable +public final class PipeDelimitedExtensibleEnumArrayProperty + implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of PipeDelimitedExtensibleEnumArrayProperty class. + * + * @param value the value value to set. + */ + @Generated + public PipeDelimitedExtensibleEnumArrayProperty(List value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (this.value != null) { + jsonWriter.writeStringField("value", + this.value.stream() + .map(element -> element == null ? null : element.toString()) + .collect(Collectors.joining("|"))); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PipeDelimitedExtensibleEnumArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PipeDelimitedExtensibleEnumArrayProperty 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 PipeDelimitedExtensibleEnumArrayProperty. + */ + @Generated + public static PipeDelimitedExtensibleEnumArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> { + String valueEncodedAsString = nonNullReader.getString(); + return valueEncodedAsString.isEmpty() + ? new LinkedList<>() + : new LinkedList<>(Arrays.stream(valueEncodedAsString.split("\\|", -1)) + .map(valueAsString -> valueAsString == null + ? null + : ColorsExtensibleEnum.fromString(valueAsString)) + .collect(Collectors.toList())); + }); + } else { + reader.skipChildren(); + } + } + return new PipeDelimitedExtensibleEnumArrayProperty(value); + }); + } +} diff --git a/typespec-tests/src/main/java/encode/array/models/SpaceDelimitedEnumArrayProperty.java b/typespec-tests/src/main/java/encode/array/models/SpaceDelimitedEnumArrayProperty.java new file mode 100644 index 0000000000..c83e8e769d --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/SpaceDelimitedEnumArrayProperty.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.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; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The SpaceDelimitedEnumArrayProperty model. + */ +@Immutable +public final class SpaceDelimitedEnumArrayProperty implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of SpaceDelimitedEnumArrayProperty class. + * + * @param value the value value to set. + */ + @Generated + public SpaceDelimitedEnumArrayProperty(List value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (this.value != null) { + jsonWriter.writeStringField("value", + this.value.stream() + .map(element -> element == null ? null : element.toString()) + .collect(Collectors.joining(" "))); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpaceDelimitedEnumArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpaceDelimitedEnumArrayProperty 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 SpaceDelimitedEnumArrayProperty. + */ + @Generated + public static SpaceDelimitedEnumArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> { + String valueEncodedAsString = nonNullReader.getString(); + return valueEncodedAsString.isEmpty() + ? new LinkedList<>() + : new LinkedList<>(Arrays.stream(valueEncodedAsString.split(" ", -1)) + .map(valueAsString -> valueAsString == null ? null : Colors.fromString(valueAsString)) + .collect(Collectors.toList())); + }); + } else { + reader.skipChildren(); + } + } + return new SpaceDelimitedEnumArrayProperty(value); + }); + } +} diff --git a/typespec-tests/src/main/java/encode/array/models/SpaceDelimitedExtensibleEnumArrayProperty.java b/typespec-tests/src/main/java/encode/array/models/SpaceDelimitedExtensibleEnumArrayProperty.java new file mode 100644 index 0000000000..af64331abc --- /dev/null +++ b/typespec-tests/src/main/java/encode/array/models/SpaceDelimitedExtensibleEnumArrayProperty.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.array.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; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The SpaceDelimitedExtensibleEnumArrayProperty model. + */ +@Immutable +public final class SpaceDelimitedExtensibleEnumArrayProperty + implements JsonSerializable { + /* + * The value property. + */ + @Generated + private final List value; + + /** + * Creates an instance of SpaceDelimitedExtensibleEnumArrayProperty class. + * + * @param value the value value to set. + */ + @Generated + public SpaceDelimitedExtensibleEnumArrayProperty(List value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Generated + public List getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (this.value != null) { + jsonWriter.writeStringField("value", + this.value.stream() + .map(element -> element == null ? null : element.toString()) + .collect(Collectors.joining(" "))); + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpaceDelimitedExtensibleEnumArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpaceDelimitedExtensibleEnumArrayProperty 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 SpaceDelimitedExtensibleEnumArrayProperty. + */ + @Generated + public static SpaceDelimitedExtensibleEnumArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List value = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> { + String valueEncodedAsString = nonNullReader.getString(); + return valueEncodedAsString.isEmpty() + ? new LinkedList<>() + : new LinkedList<>(Arrays.stream(valueEncodedAsString.split(" ", -1)) + .map(valueAsString -> valueAsString == null + ? null + : ColorsExtensibleEnum.fromString(valueAsString)) + .collect(Collectors.toList())); + }); + } else { + reader.skipChildren(); + } + } + return new SpaceDelimitedExtensibleEnumArrayProperty(value); + }); + } +} diff --git a/typespec-tests/src/main/java/payload/multipart/FormDataFileAsyncClient.java b/typespec-tests/src/main/java/payload/multipart/FormDataFileAsyncClient.java new file mode 100644 index 0000000000..a0b124f22d --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/FormDataFileAsyncClient.java @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +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 java.util.stream.Collectors; +import payload.multipart.formdata.file.models.UploadFileArrayRequest; +import payload.multipart.formdata.file.models.UploadFileRequiredFilenameRequest; +import payload.multipart.formdata.file.models.UploadFileSpecificContentTypeRequest; +import payload.multipart.implementation.FormDataFilesImpl; +import payload.multipart.implementation.MultipartFormDataHelper; +import payload.multipart.models.FilesFileDetails; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous MultiPartClient type. + */ +@ServiceClient(builder = MultiPartClientBuilder.class, isAsync = true) +public final class FormDataFileAsyncClient { + @Generated + private final FormDataFilesImpl serviceClient; + + /** + * Initializes an instance of FormDataFileAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FormDataFileAsyncClient(FormDataFilesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The uploadFileSpecificContentType operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> uploadFileSpecificContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + // Operation 'uploadFileSpecificContentType' is of content-type 'multipart/form-data'. Protocol API is not + // usable and hence not generated. + return this.serviceClient.uploadFileSpecificContentTypeWithResponseAsync(body, requestOptions); + } + + /** + * The uploadFileRequiredFilename operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> uploadFileRequiredFilenameWithResponse(BinaryData body, RequestOptions requestOptions) { + // Operation 'uploadFileRequiredFilename' is of content-type 'multipart/form-data'. Protocol API is not usable + // and hence not generated. + return this.serviceClient.uploadFileRequiredFilenameWithResponseAsync(body, requestOptions); + } + + /** + * The uploadFileArray operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> uploadFileArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + // Operation 'uploadFileArray' is of content-type 'multipart/form-data'. Protocol API is not usable and hence + // not generated. + return this.serviceClient.uploadFileArrayWithResponseAsync(body, requestOptions); + } + + /** + * The uploadFileSpecificContentType operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono uploadFileSpecificContentType(UploadFileSpecificContentTypeRequest body) { + // Generated convenience method for uploadFileSpecificContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadFileSpecificContentTypeWithResponse( + new MultipartFormDataHelper(requestOptions).serializeFileField("file", body.getFile().getContent(), + body.getFile().getContentType(), body.getFile().getFilename()).end().getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The uploadFileRequiredFilename operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono uploadFileRequiredFilename(UploadFileRequiredFilenameRequest body) { + // Generated convenience method for uploadFileRequiredFilenameWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadFileRequiredFilenameWithResponse( + new MultipartFormDataHelper(requestOptions).serializeFileField("file", body.getFile().getContent(), + body.getFile().getContentType(), body.getFile().getFilename()).end().getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The uploadFileArray operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono uploadFileArray(UploadFileArrayRequest body) { + // Generated convenience method for uploadFileArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadFileArrayWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeFileFields("files", + body.getFiles().stream().map(FilesFileDetails::getContent).collect(Collectors.toList()), + body.getFiles().stream().map(FilesFileDetails::getContentType).collect(Collectors.toList()), + body.getFiles().stream().map(FilesFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/payload/multipart/FormDataFileClient.java b/typespec-tests/src/main/java/payload/multipart/FormDataFileClient.java new file mode 100644 index 0000000000..a9ff016c88 --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/FormDataFileClient.java @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +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 java.util.stream.Collectors; +import payload.multipart.formdata.file.models.UploadFileArrayRequest; +import payload.multipart.formdata.file.models.UploadFileRequiredFilenameRequest; +import payload.multipart.formdata.file.models.UploadFileSpecificContentTypeRequest; +import payload.multipart.implementation.FormDataFilesImpl; +import payload.multipart.implementation.MultipartFormDataHelper; +import payload.multipart.models.FilesFileDetails; + +/** + * Initializes a new instance of the synchronous MultiPartClient type. + */ +@ServiceClient(builder = MultiPartClientBuilder.class) +public final class FormDataFileClient { + @Generated + private final FormDataFilesImpl serviceClient; + + /** + * Initializes an instance of FormDataFileClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FormDataFileClient(FormDataFilesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The uploadFileSpecificContentType operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response uploadFileSpecificContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + // Operation 'uploadFileSpecificContentType' is of content-type 'multipart/form-data'. Protocol API is not + // usable and hence not generated. + return this.serviceClient.uploadFileSpecificContentTypeWithResponse(body, requestOptions); + } + + /** + * The uploadFileRequiredFilename operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response uploadFileRequiredFilenameWithResponse(BinaryData body, RequestOptions requestOptions) { + // Operation 'uploadFileRequiredFilename' is of content-type 'multipart/form-data'. Protocol API is not usable + // and hence not generated. + return this.serviceClient.uploadFileRequiredFilenameWithResponse(body, requestOptions); + } + + /** + * The uploadFileArray operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Response uploadFileArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + // Operation 'uploadFileArray' is of content-type 'multipart/form-data'. Protocol API is not usable and hence + // not generated. + return this.serviceClient.uploadFileArrayWithResponse(body, requestOptions); + } + + /** + * The uploadFileSpecificContentType operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void uploadFileSpecificContentType(UploadFileSpecificContentTypeRequest body) { + // Generated convenience method for uploadFileSpecificContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadFileSpecificContentTypeWithResponse( + new MultipartFormDataHelper(requestOptions).serializeFileField("file", body.getFile().getContent(), + body.getFile().getContentType(), body.getFile().getFilename()).end().getRequestBody(), + requestOptions).getValue(); + } + + /** + * The uploadFileRequiredFilename operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void uploadFileRequiredFilename(UploadFileRequiredFilenameRequest body) { + // Generated convenience method for uploadFileRequiredFilenameWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadFileRequiredFilenameWithResponse( + new MultipartFormDataHelper(requestOptions).serializeFileField("file", body.getFile().getContent(), + body.getFile().getContentType(), body.getFile().getFilename()).end().getRequestBody(), + requestOptions).getValue(); + } + + /** + * The uploadFileArray operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void uploadFileArray(UploadFileArrayRequest body) { + // Generated convenience method for uploadFileArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadFileArrayWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeFileFields("files", + body.getFiles().stream().map(FilesFileDetails::getContent).collect(Collectors.toList()), + body.getFiles().stream().map(FilesFileDetails::getContentType).collect(Collectors.toList()), + body.getFiles().stream().map(FilesFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/payload/multipart/MultiPartClientBuilder.java b/typespec-tests/src/main/java/payload/multipart/MultiPartClientBuilder.java index 73a9480955..9f4c70e860 100644 --- a/typespec-tests/src/main/java/payload/multipart/MultiPartClientBuilder.java +++ b/typespec-tests/src/main/java/payload/multipart/MultiPartClientBuilder.java @@ -46,10 +46,12 @@ FormDataHttpPartsClient.class, FormDataHttpPartsContentTypeClient.class, FormDataHttpPartsNonStringClient.class, + FormDataFileClient.class, FormDataAsyncClient.class, FormDataHttpPartsAsyncClient.class, FormDataHttpPartsContentTypeAsyncClient.class, - FormDataHttpPartsNonStringAsyncClient.class }) + FormDataHttpPartsNonStringAsyncClient.class, + FormDataFileAsyncClient.class }) public final class MultiPartClientBuilder implements HttpTrait, ConfigurationTrait, EndpointTrait { @Generated @@ -312,6 +314,16 @@ public FormDataHttpPartsNonStringAsyncClient buildFormDataHttpPartsNonStringAsyn return new FormDataHttpPartsNonStringAsyncClient(buildInnerClient().getFormDataHttpPartsNonStrings()); } + /** + * Builds an instance of FormDataFileAsyncClient class. + * + * @return an instance of FormDataFileAsyncClient. + */ + @Generated + public FormDataFileAsyncClient buildFormDataFileAsyncClient() { + return new FormDataFileAsyncClient(buildInnerClient().getFormDataFiles()); + } + /** * Builds an instance of FormDataClient class. * @@ -352,5 +364,15 @@ public FormDataHttpPartsNonStringClient buildFormDataHttpPartsNonStringClient() return new FormDataHttpPartsNonStringClient(buildInnerClient().getFormDataHttpPartsNonStrings()); } + /** + * Builds an instance of FormDataFileClient class. + * + * @return an instance of FormDataFileClient. + */ + @Generated + public FormDataFileClient buildFormDataFileClient() { + return new FormDataFileClient(buildInnerClient().getFormDataFiles()); + } + private static final ClientLogger LOGGER = new ClientLogger(MultiPartClientBuilder.class); } diff --git a/typespec-tests/src/main/java/payload/multipart/formdata/file/models/FileWithRequiredFilename.java b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/FileWithRequiredFilename.java new file mode 100644 index 0000000000..dc4d163d73 --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/FileWithRequiredFilename.java @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.formdata.file.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * The file details for the "file" field. + */ +@Fluent +public final class FileWithRequiredFilename { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private final String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "image/png"; + + /** + * Creates an instance of FileWithRequiredFilename class. + * + * @param content the content value to set. + * @param filename the filename value to set. + */ + @Generated + public FileWithRequiredFilename(BinaryData content, String filename) { + this.content = content; + this.filename = filename; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the FileWithRequiredFilename object itself. + */ + @Generated + public FileWithRequiredFilename setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/typespec-tests/src/main/java/payload/multipart/formdata/file/models/UploadFileArrayRequest.java b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/UploadFileArrayRequest.java new file mode 100644 index 0000000000..0efc919645 --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/UploadFileArrayRequest.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.formdata.file.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import java.util.List; +import payload.multipart.models.FilesFileDetails; + +/** + * The UploadFileArrayRequest model. + */ +@Immutable +public final class UploadFileArrayRequest { + /* + * The files property. + */ + @Generated + private final List files; + + /** + * Creates an instance of UploadFileArrayRequest class. + * + * @param files the files value to set. + */ + @Generated + public UploadFileArrayRequest(List files) { + this.files = files; + } + + /** + * Get the files property: The files property. + * + * @return the files value. + */ + @Generated + public List getFiles() { + return this.files; + } +} diff --git a/typespec-tests/src/main/java/payload/multipart/formdata/file/models/UploadFileRequiredFilenameRequest.java b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/UploadFileRequiredFilenameRequest.java new file mode 100644 index 0000000000..97c3c46178 --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/UploadFileRequiredFilenameRequest.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.formdata.file.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; + +/** + * The UploadFileRequiredFilenameRequest model. + */ +@Immutable +public final class UploadFileRequiredFilenameRequest { + /* + * The file property. + */ + @Generated + private final FileWithRequiredFilename file; + + /** + * Creates an instance of UploadFileRequiredFilenameRequest class. + * + * @param file the file value to set. + */ + @Generated + public UploadFileRequiredFilenameRequest(FileWithRequiredFilename file) { + this.file = file; + } + + /** + * Get the file property: The file property. + * + * @return the file value. + */ + @Generated + public FileWithRequiredFilename getFile() { + return this.file; + } +} diff --git a/typespec-tests/src/main/java/payload/multipart/formdata/file/models/UploadFileSpecificContentTypeRequest.java b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/UploadFileSpecificContentTypeRequest.java new file mode 100644 index 0000000000..ea572c110b --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/UploadFileSpecificContentTypeRequest.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.formdata.file.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import payload.multipart.models.FileDetails; + +/** + * The UploadFileSpecificContentTypeRequest model. + */ +@Immutable +public final class UploadFileSpecificContentTypeRequest { + /* + * The file property. + */ + @Generated + private final FileDetails file; + + /** + * Creates an instance of UploadFileSpecificContentTypeRequest class. + * + * @param file the file value to set. + */ + @Generated + public UploadFileSpecificContentTypeRequest(FileDetails file) { + this.file = file; + } + + /** + * Get the file property: The file property. + * + * @return the file value. + */ + @Generated + public FileDetails getFile() { + return this.file; + } +} diff --git a/typespec-tests/src/main/java/payload/multipart/formdata/file/models/package-info.java b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/package-info.java new file mode 100644 index 0000000000..25fb95c27f --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/formdata/file/models/package-info.java @@ -0,0 +1,11 @@ +// 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 MultiPart. + * Test for multipart. + * + */ +package payload.multipart.formdata.file.models; diff --git a/typespec-tests/src/main/java/payload/multipart/implementation/FormDataFilesImpl.java b/typespec-tests/src/main/java/payload/multipart/implementation/FormDataFilesImpl.java new file mode 100644 index 0000000000..193357c68d --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/implementation/FormDataFilesImpl.java @@ -0,0 +1,236 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in FormDataFiles. + */ +public final class FormDataFilesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FormDataFilesService service; + + /** + * The service client containing this operation class. + */ + private final MultiPartClientImpl client; + + /** + * Initializes an instance of FormDataFilesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FormDataFilesImpl(MultiPartClientImpl client) { + this.service + = RestProxy.create(FormDataFilesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MultiPartClientFormDataFiles to be used by the proxy service to + * perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "MultiPartClientFormDataFiles") + public interface FormDataFilesService { + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/file/specific-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadFileSpecificContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/file/specific-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadFileSpecificContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/file/required-filename") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadFileRequiredFilename(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/file/required-filename") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadFileRequiredFilenameSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/file/file-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadFileArray(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + + // @Multipart not supported by RestProxy + @Post("/multipart/form-data/file/file-array") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadFileArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions, Context context); + } + + /** + * The uploadFileSpecificContentType operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> uploadFileSpecificContentTypeWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext(context -> service.uploadFileSpecificContentType(this.client.getEndpoint(), + contentType, body, requestOptions, context)); + } + + /** + * The uploadFileSpecificContentType operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response uploadFileSpecificContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.uploadFileSpecificContentTypeSync(this.client.getEndpoint(), contentType, body, requestOptions, + Context.NONE); + } + + /** + * The uploadFileRequiredFilename operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> uploadFileRequiredFilenameWithResponseAsync(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext(context -> service.uploadFileRequiredFilename(this.client.getEndpoint(), + contentType, body, requestOptions, context)); + } + + /** + * The uploadFileRequiredFilename operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response uploadFileRequiredFilenameWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.uploadFileRequiredFilenameSync(this.client.getEndpoint(), contentType, body, requestOptions, + Context.NONE); + } + + /** + * The uploadFileArray operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> uploadFileArrayWithResponseAsync(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return FluxUtil.withContext( + context -> service.uploadFileArray(this.client.getEndpoint(), contentType, body, requestOptions, context)); + } + + /** + * The uploadFileArray operation. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response uploadFileArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.uploadFileArraySync(this.client.getEndpoint(), contentType, body, requestOptions, Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/payload/multipart/implementation/MultiPartClientImpl.java b/typespec-tests/src/main/java/payload/multipart/implementation/MultiPartClientImpl.java index 084691d24c..420b831cc1 100644 --- a/typespec-tests/src/main/java/payload/multipart/implementation/MultiPartClientImpl.java +++ b/typespec-tests/src/main/java/payload/multipart/implementation/MultiPartClientImpl.java @@ -113,6 +113,20 @@ public FormDataHttpPartsNonStringsImpl getFormDataHttpPartsNonStrings() { return this.formDataHttpPartsNonStrings; } + /** + * The FormDataFilesImpl object to access its operations. + */ + private final FormDataFilesImpl formDataFiles; + + /** + * Gets the FormDataFilesImpl object to access its operations. + * + * @return the FormDataFilesImpl object. + */ + public FormDataFilesImpl getFormDataFiles() { + return this.formDataFiles; + } + /** * Initializes an instance of MultiPartClient client. * @@ -148,5 +162,6 @@ public MultiPartClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializ this.formDataHttpParts = new FormDataHttpPartsImpl(this); this.formDataHttpPartsContentTypes = new FormDataHttpPartsContentTypesImpl(this); this.formDataHttpPartsNonStrings = new FormDataHttpPartsNonStringsImpl(this); + this.formDataFiles = new FormDataFilesImpl(this); } } diff --git a/typespec-tests/src/main/java/payload/multipart/models/FileDetails.java b/typespec-tests/src/main/java/payload/multipart/models/FileDetails.java new file mode 100644 index 0000000000..9552489b92 --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/models/FileDetails.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * A file in an HTTP request, response, or multipart payload. + * + * A file in an HTTP request, response, or multipart payload. + * + * Files have a special meaning that the HTTP library understands. When the body of an HTTP request, response, + * or multipart payload is _effectively_ an instance of `TypeSpec.Http.File` or any type that extends it, the + * operation is treated as a file upload or download. + * + * When using file bodies, the fields of the file model are defined to come from particular locations by default: + * + * - `contentType`: The `Content-Type` header of the request, response, or multipart payload (CANNOT be overridden or + * changed). + * - `contents`: The body of the request, response, or multipart payload (CANNOT be overridden or changed). + * - `filename`: The `filename` parameter value of the `Content-Disposition` header of the response or multipart payload + * (MAY be overridden or changed). + * + * A File may be used as a normal structured JSON object in a request or response, if the request specifies an explicit + * `Content-Type` header. In this case, the entire File model is serialized as if it were any other model. In a JSON + * payload, + * it will have a structure like: + * + * ``` + * { + * "contentType": <string?>, + * "filename": <string?>, + * "contents": <string, base64> + * } + * ``` + * + * The `contentType` _within_ the file defines what media types the data inside the file can be, but if the + * specification + * defines a `Content-Type` for the payload as HTTP metadata, that `Content-Type` metadata defines _how the file is + * serialized_. See the examples below for more information. + * + * NOTE: The `filename` and `contentType` fields are optional. Furthermore, the default location of `filename` + * (`Content-Disposition: <disposition>; filename=<filename>`) is only valid in HTTP responses and multipart + * payloads. If + * you wish to send the `filename` in a request, you must use HTTP metadata decorators to describe the location of the + * `filename` field. You can combine the metadata decorators with `@visibility` to control when the `filename` + * location + * is overridden, as shown in the examples below. + */ +@Fluent +public final class FileDetails { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "image/png"; + + /** + * Creates an instance of FileDetails class. + * + * @param content the content value to set. + */ + @Generated + public FileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the FileDetails object itself. + */ + @Generated + public FileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the FileDetails object itself. + */ + @Generated + public FileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/typespec-tests/src/main/java/payload/multipart/models/FilesFileDetails.java b/typespec-tests/src/main/java/payload/multipart/models/FilesFileDetails.java new file mode 100644 index 0000000000..525983c27b --- /dev/null +++ b/typespec-tests/src/main/java/payload/multipart/models/FilesFileDetails.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.BinaryData; + +/** + * A file in an HTTP request, response, or multipart payload. + * + * A file in an HTTP request, response, or multipart payload. + * + * Files have a special meaning that the HTTP library understands. When the body of an HTTP request, response, + * or multipart payload is _effectively_ an instance of `TypeSpec.Http.File` or any type that extends it, the + * operation is treated as a file upload or download. + * + * When using file bodies, the fields of the file model are defined to come from particular locations by default: + * + * - `contentType`: The `Content-Type` header of the request, response, or multipart payload (CANNOT be overridden or + * changed). + * - `contents`: The body of the request, response, or multipart payload (CANNOT be overridden or changed). + * - `filename`: The `filename` parameter value of the `Content-Disposition` header of the response or multipart payload + * (MAY be overridden or changed). + * + * A File may be used as a normal structured JSON object in a request or response, if the request specifies an explicit + * `Content-Type` header. In this case, the entire File model is serialized as if it were any other model. In a JSON + * payload, + * it will have a structure like: + * + * ``` + * { + * "contentType": <string?>, + * "filename": <string?>, + * "contents": <string, base64> + * } + * ``` + * + * The `contentType` _within_ the file defines what media types the data inside the file can be, but if the + * specification + * defines a `Content-Type` for the payload as HTTP metadata, that `Content-Type` metadata defines _how the file is + * serialized_. See the examples below for more information. + * + * NOTE: The `filename` and `contentType` fields are optional. Furthermore, the default location of `filename` + * (`Content-Disposition: <disposition>; filename=<filename>`) is only valid in HTTP responses and multipart + * payloads. If + * you wish to send the `filename` in a request, you must use HTTP metadata decorators to describe the location of the + * `filename` field. You can combine the metadata decorators with `@visibility` to control when the `filename` + * location + * is overridden, as shown in the examples below. + */ +@Fluent +public final class FilesFileDetails { + /* + * The content of the file. + */ + @Generated + private final BinaryData content; + + /* + * The filename of the file. + */ + @Generated + private String filename; + + /* + * The content-type of the file. + */ + @Generated + private String contentType = "image/png"; + + /** + * Creates an instance of FilesFileDetails class. + * + * @param content the content value to set. + */ + @Generated + public FilesFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Generated + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Generated + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the FilesFileDetails object itself. + */ + @Generated + public FilesFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Generated + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the FilesFileDetails object itself. + */ + @Generated + public FilesFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/typespec-tests/src/main/java/tsptest/clientinitialization/ClientInitializationClientBuilder.java b/typespec-tests/src/main/java/tsptest/clientinitialization/ClientInitializationClientBuilder.java index 94ead6fa1d..e1c7749dc3 100644 --- a/typespec-tests/src/main/java/tsptest/clientinitialization/ClientInitializationClientBuilder.java +++ b/typespec-tests/src/main/java/tsptest/clientinitialization/ClientInitializationClientBuilder.java @@ -40,12 +40,7 @@ /** * A builder for creating a new instance of the ClientInitializationClient type. */ -@ServiceClientBuilder( - serviceClients = { - ClientInitializationClient.class, - ClientInitializationAsyncClient.class, - SubClient.class, - SubAsyncClient.class }) +@ServiceClientBuilder(serviceClients = { ClientInitializationClient.class, ClientInitializationAsyncClient.class }) public final class ClientInitializationClientBuilder implements HttpTrait, ConfigurationTrait, EndpointTrait { @Generated diff --git a/typespec-tests/src/main/java/tsptest/clientinitialization/SubAsyncClient.java b/typespec-tests/src/main/java/tsptest/clientinitialization/SubAsyncClient.java index c45a8623d2..8579cd34f2 100644 --- a/typespec-tests/src/main/java/tsptest/clientinitialization/SubAsyncClient.java +++ b/typespec-tests/src/main/java/tsptest/clientinitialization/SubAsyncClient.java @@ -21,7 +21,7 @@ /** * Initializes a new instance of the asynchronous SubClient type. */ -@ServiceClient(builder = ClientInitializationClientBuilder.class, isAsync = true) +@ServiceClient(builder = SubClientBuilder.class, isAsync = true) public final class SubAsyncClient { @Generated private final SubClientImpl serviceClient; diff --git a/typespec-tests/src/main/java/tsptest/clientinitialization/SubClient.java b/typespec-tests/src/main/java/tsptest/clientinitialization/SubClient.java index 999520fafd..d083f31109 100644 --- a/typespec-tests/src/main/java/tsptest/clientinitialization/SubClient.java +++ b/typespec-tests/src/main/java/tsptest/clientinitialization/SubClient.java @@ -19,7 +19,7 @@ /** * Initializes a new instance of the synchronous SubClient type. */ -@ServiceClient(builder = ClientInitializationClientBuilder.class) +@ServiceClient(builder = SubClientBuilder.class) public final class SubClient { @Generated private final SubClientImpl serviceClient; diff --git a/typespec-tests/src/main/java/tsptest/clientinitialization/SubClientBuilder.java b/typespec-tests/src/main/java/tsptest/clientinitialization/SubClientBuilder.java new file mode 100644 index 0000000000..6d4eb30bed --- /dev/null +++ b/typespec-tests/src/main/java/tsptest/clientinitialization/SubClientBuilder.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.clientinitialization; + +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.clientinitialization.implementation.SubClientImpl; + +/** + * A builder for creating a new instance of the SubClient type. + */ +@ServiceClientBuilder(serviceClients = { SubClient.class, SubAsyncClient.class }) +public final class SubClientBuilder + 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-clientinitialization.properties"); + + @Generated + private final List pipelinePolicies; + + /** + * Create an instance of the SubClientBuilder. + */ + @Generated + public SubClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP client used to send the request. + */ + @Generated + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SubClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SubClientBuilder 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 SubClientBuilder 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 SubClientBuilder 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 SubClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SubClientBuilder 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 SubClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Generated + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Generated + @Override + public SubClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * + */ + @Generated + private String name; + + /** + * Sets. + * + * @param name the name value. + * @return the SubClientBuilder. + */ + @Generated + public SubClientBuilder name(String name) { + this.name = name; + 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 SubClientBuilder. + */ + @Generated + public SubClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SubClientImpl with the provided parameters. + * + * @return an instance of SubClientImpl. + */ + @Generated + private SubClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + SubClientImpl client = new SubClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), + localEndpoint, this.name); + 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(name, "'name' 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 SubAsyncClient class. + * + * @return an instance of SubAsyncClient. + */ + @Generated + public SubAsyncClient buildAsyncClient() { + return new SubAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of SubClient class. + * + * @return an instance of SubClient. + */ + @Generated + public SubClient buildClient() { + return new SubClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SubClientBuilder.class); +} diff --git a/typespec-tests/src/main/java/type/file/FileAsyncClient.java b/typespec-tests/src/main/java/type/file/FileAsyncClient.java new file mode 100644 index 0000000000..4630c036e8 --- /dev/null +++ b/typespec-tests/src/main/java/type/file/FileAsyncClient.java @@ -0,0 +1,392 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.file; + +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 type.file.implementation.BodiesImpl; + +/** + * Initializes a new instance of the asynchronous FileClient type. + */ +@ServiceClient(builder = FileClientBuilder.class, isAsync = true) +public final class FileAsyncClient { + @Generated + private final BodiesImpl serviceClient; + + /** + * Initializes an instance of FileAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FileAsyncClient(BodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The uploadFileSpecificContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are image/png. + * @param file The file 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> uploadFileSpecificContentTypeWithResponse(String contentType, BinaryData file, + RequestOptions requestOptions) { + return this.serviceClient.uploadFileSpecificContentTypeWithResponseAsync(contentType, file, requestOptions); + } + + /** + * The uploadFileJsonContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param file The file 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> uploadFileJsonContentTypeWithResponse(BinaryData file, RequestOptions requestOptions) { + return this.serviceClient.uploadFileJsonContentTypeWithResponseAsync(file, requestOptions); + } + + /** + * The downloadFileJsonContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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> downloadFileJsonContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadFileJsonContentTypeWithResponseAsync(requestOptions); + } + + /** + * The downloadFileSpecificContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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> downloadFileSpecificContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadFileSpecificContentTypeWithResponseAsync(requestOptions); + } + + /** + * The uploadFileMultipleContentTypes operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are image/png,image/jpeg. + * @param file The file 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> uploadFileMultipleContentTypesWithResponse(String contentType, BinaryData file, + RequestOptions requestOptions) { + return this.serviceClient.uploadFileMultipleContentTypesWithResponseAsync(contentType, file, requestOptions); + } + + /** + * The downloadFileMultipleContentTypes operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param accept The accept 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> downloadFileMultipleContentTypesWithResponse(String accept, + RequestOptions requestOptions) { + return this.serviceClient.downloadFileMultipleContentTypesWithResponseAsync(accept, requestOptions); + } + + /** + * The uploadFileDefaultContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are */*. + * @param file The file 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> uploadFileDefaultContentTypeWithResponse(String contentType, BinaryData file, + RequestOptions requestOptions) { + return this.serviceClient.uploadFileDefaultContentTypeWithResponseAsync(contentType, file, requestOptions); + } + + /** + * The downloadFileDefaultContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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> downloadFileDefaultContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadFileDefaultContentTypeWithResponseAsync(requestOptions); + } + + /** + * The uploadFileSpecificContentType operation. + * + * @param contentType Body parameter's content type. Known values are image/png. + * @param file The file 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 uploadFileSpecificContentType(String contentType, BinaryData file) { + // Generated convenience method for uploadFileSpecificContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadFileSpecificContentTypeWithResponse(contentType, file, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The uploadFileJsonContentType operation. + * + * @param file The file 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 uploadFileJsonContentType(BinaryData file) { + // Generated convenience method for uploadFileJsonContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadFileJsonContentTypeWithResponse(file, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The downloadFileJsonContentType 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono downloadFileJsonContentType() { + // Generated convenience method for downloadFileJsonContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadFileJsonContentTypeWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The downloadFileSpecificContentType 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono downloadFileSpecificContentType() { + // Generated convenience method for downloadFileSpecificContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadFileSpecificContentTypeWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The uploadFileMultipleContentTypes operation. + * + * @param contentType Body parameter's content type. Known values are image/png,image/jpeg. + * @param file The file 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 uploadFileMultipleContentTypes(String contentType, BinaryData file) { + // Generated convenience method for uploadFileMultipleContentTypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadFileMultipleContentTypesWithResponse(contentType, file, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The downloadFileMultipleContentTypes operation. + * + * @param accept The accept 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 downloadFileMultipleContentTypes(String accept) { + // Generated convenience method for downloadFileMultipleContentTypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadFileMultipleContentTypesWithResponse(accept, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The uploadFileDefaultContentType operation. + * + * @param contentType Body parameter's content type. Known values are */*. + * @param file The file 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 uploadFileDefaultContentType(String contentType, BinaryData file) { + // Generated convenience method for uploadFileDefaultContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uploadFileDefaultContentTypeWithResponse(contentType, file, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * The downloadFileDefaultContentType 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 the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono downloadFileDefaultContentType() { + // Generated convenience method for downloadFileDefaultContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadFileDefaultContentTypeWithResponse(requestOptions).flatMap(FluxUtil::toMono); + } +} diff --git a/typespec-tests/src/main/java/type/file/FileClient.java b/typespec-tests/src/main/java/type/file/FileClient.java new file mode 100644 index 0000000000..05170b2fdb --- /dev/null +++ b/typespec-tests/src/main/java/type/file/FileClient.java @@ -0,0 +1,386 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.file; + +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 type.file.implementation.BodiesImpl; + +/** + * Initializes a new instance of the synchronous FileClient type. + */ +@ServiceClient(builder = FileClientBuilder.class) +public final class FileClient { + @Generated + private final BodiesImpl serviceClient; + + /** + * Initializes an instance of FileClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + FileClient(BodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The uploadFileSpecificContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are image/png. + * @param file The file 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 uploadFileSpecificContentTypeWithResponse(String contentType, BinaryData file, + RequestOptions requestOptions) { + return this.serviceClient.uploadFileSpecificContentTypeWithResponse(contentType, file, requestOptions); + } + + /** + * The uploadFileJsonContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param file The file 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 uploadFileJsonContentTypeWithResponse(BinaryData file, RequestOptions requestOptions) { + return this.serviceClient.uploadFileJsonContentTypeWithResponse(file, requestOptions); + } + + /** + * The downloadFileJsonContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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 downloadFileJsonContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadFileJsonContentTypeWithResponse(requestOptions); + } + + /** + * The downloadFileSpecificContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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 downloadFileSpecificContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadFileSpecificContentTypeWithResponse(requestOptions); + } + + /** + * The uploadFileMultipleContentTypes operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are image/png,image/jpeg. + * @param file The file 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 uploadFileMultipleContentTypesWithResponse(String contentType, BinaryData file, + RequestOptions requestOptions) { + return this.serviceClient.uploadFileMultipleContentTypesWithResponse(contentType, file, requestOptions); + } + + /** + * The downloadFileMultipleContentTypes operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param accept The accept 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 downloadFileMultipleContentTypesWithResponse(String accept, + RequestOptions requestOptions) { + return this.serviceClient.downloadFileMultipleContentTypesWithResponse(accept, requestOptions); + } + + /** + * The uploadFileDefaultContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are */*. + * @param file The file 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 uploadFileDefaultContentTypeWithResponse(String contentType, BinaryData file, + RequestOptions requestOptions) { + return this.serviceClient.uploadFileDefaultContentTypeWithResponse(contentType, file, requestOptions); + } + + /** + * The downloadFileDefaultContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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 downloadFileDefaultContentTypeWithResponse(RequestOptions requestOptions) { + return this.serviceClient.downloadFileDefaultContentTypeWithResponse(requestOptions); + } + + /** + * The uploadFileSpecificContentType operation. + * + * @param contentType Body parameter's content type. Known values are image/png. + * @param file The file 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 uploadFileSpecificContentType(String contentType, BinaryData file) { + // Generated convenience method for uploadFileSpecificContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadFileSpecificContentTypeWithResponse(contentType, file, requestOptions).getValue(); + } + + /** + * The uploadFileJsonContentType operation. + * + * @param file The file 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 uploadFileJsonContentType(BinaryData file) { + // Generated convenience method for uploadFileJsonContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadFileJsonContentTypeWithResponse(file, requestOptions).getValue(); + } + + /** + * The downloadFileJsonContentType 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData downloadFileJsonContentType() { + // Generated convenience method for downloadFileJsonContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadFileJsonContentTypeWithResponse(requestOptions).getValue(); + } + + /** + * The downloadFileSpecificContentType 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData downloadFileSpecificContentType() { + // Generated convenience method for downloadFileSpecificContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadFileSpecificContentTypeWithResponse(requestOptions).getValue(); + } + + /** + * The uploadFileMultipleContentTypes operation. + * + * @param contentType Body parameter's content type. Known values are image/png,image/jpeg. + * @param file The file 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 uploadFileMultipleContentTypes(String contentType, BinaryData file) { + // Generated convenience method for uploadFileMultipleContentTypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadFileMultipleContentTypesWithResponse(contentType, file, requestOptions).getValue(); + } + + /** + * The downloadFileMultipleContentTypes operation. + * + * @param accept The accept 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 BinaryData downloadFileMultipleContentTypes(String accept) { + // Generated convenience method for downloadFileMultipleContentTypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadFileMultipleContentTypesWithResponse(accept, requestOptions).getValue(); + } + + /** + * The uploadFileDefaultContentType operation. + * + * @param contentType Body parameter's content type. Known values are */*. + * @param file The file 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 uploadFileDefaultContentType(String contentType, BinaryData file) { + // Generated convenience method for uploadFileDefaultContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + uploadFileDefaultContentTypeWithResponse(contentType, file, requestOptions).getValue(); + } + + /** + * The downloadFileDefaultContentType 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 the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData downloadFileDefaultContentType() { + // Generated convenience method for downloadFileDefaultContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadFileDefaultContentTypeWithResponse(requestOptions).getValue(); + } +} diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ParentClientBuilder.java b/typespec-tests/src/main/java/type/file/FileClientBuilder.java similarity index 77% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ParentClientBuilder.java rename to typespec-tests/src/main/java/type/file/FileClientBuilder.java index cba227f9fb..be3cd09892 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/parentclient/ParentClientBuilder.java +++ b/typespec-tests/src/main/java/type/file/FileClientBuilder.java @@ -2,9 +2,8 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.parentclient; +package type.file; -import azure.clientgenerator.core.clientinitialization.implementation.ParentClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.client.traits.ConfigurationTrait; @@ -36,13 +35,14 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import type.file.implementation.FileClientImpl; /** - * A builder for creating a new instance of the ParentClient type. + * A builder for creating a new instance of the FileClient type. */ -@ServiceClientBuilder(serviceClients = { ParentClient.class, ParentAsyncClient.class }) -public final class ParentClientBuilder implements HttpTrait, - ConfigurationTrait, EndpointTrait { +@ServiceClientBuilder(serviceClients = { FileClient.class, FileAsyncClient.class }) +public final class FileClientBuilder + implements HttpTrait, ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -50,17 +50,16 @@ public final class ParentClientBuilder implements HttpTrait private static final String SDK_VERSION = "version"; @Generated - private static final Map PROPERTIES - = CoreUtils.getProperties("azure-clientgenerator-core-clientinitialization.properties"); + private static final Map PROPERTIES = CoreUtils.getProperties("type-file.properties"); @Generated private final List pipelinePolicies; /** - * Create an instance of the ParentClientBuilder. + * Create an instance of the FileClientBuilder. */ @Generated - public ParentClientBuilder() { + public FileClientBuilder() { this.pipelinePolicies = new ArrayList<>(); } @@ -75,7 +74,7 @@ public ParentClientBuilder() { */ @Generated @Override - public ParentClientBuilder httpClient(HttpClient httpClient) { + public FileClientBuilder httpClient(HttpClient httpClient) { this.httpClient = httpClient; return this; } @@ -91,7 +90,7 @@ public ParentClientBuilder httpClient(HttpClient httpClient) { */ @Generated @Override - public ParentClientBuilder pipeline(HttpPipeline pipeline) { + public FileClientBuilder pipeline(HttpPipeline pipeline) { if (this.pipeline != null && pipeline == null) { LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); } @@ -110,7 +109,7 @@ public ParentClientBuilder pipeline(HttpPipeline pipeline) { */ @Generated @Override - public ParentClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + public FileClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { this.httpLogOptions = httpLogOptions; return this; } @@ -126,7 +125,7 @@ public ParentClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { */ @Generated @Override - public ParentClientBuilder clientOptions(ClientOptions clientOptions) { + public FileClientBuilder clientOptions(ClientOptions clientOptions) { this.clientOptions = clientOptions; return this; } @@ -142,7 +141,7 @@ public ParentClientBuilder clientOptions(ClientOptions clientOptions) { */ @Generated @Override - public ParentClientBuilder retryOptions(RetryOptions retryOptions) { + public FileClientBuilder retryOptions(RetryOptions retryOptions) { this.retryOptions = retryOptions; return this; } @@ -152,7 +151,7 @@ public ParentClientBuilder retryOptions(RetryOptions retryOptions) { */ @Generated @Override - public ParentClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + public FileClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); pipelinePolicies.add(customPolicy); return this; @@ -169,7 +168,7 @@ public ParentClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { */ @Generated @Override - public ParentClientBuilder configuration(Configuration configuration) { + public FileClientBuilder configuration(Configuration configuration) { this.configuration = configuration; return this; } @@ -185,7 +184,7 @@ public ParentClientBuilder configuration(Configuration configuration) { */ @Generated @Override - public ParentClientBuilder endpoint(String endpoint) { + public FileClientBuilder endpoint(String endpoint) { this.endpoint = endpoint; return this; } @@ -200,26 +199,26 @@ public ParentClientBuilder endpoint(String endpoint) { * Sets The retry policy that will attempt to retry failed requests, if applicable. * * @param retryPolicy the retryPolicy value. - * @return the ParentClientBuilder. + * @return the FileClientBuilder. */ @Generated - public ParentClientBuilder retryPolicy(RetryPolicy retryPolicy) { + public FileClientBuilder retryPolicy(RetryPolicy retryPolicy) { this.retryPolicy = retryPolicy; return this; } /** - * Builds an instance of ParentClientImpl with the provided parameters. + * Builds an instance of FileClientImpl with the provided parameters. * - * @return an instance of ParentClientImpl. + * @return an instance of FileClientImpl. */ @Generated - private ParentClientImpl buildInnerClient() { + private FileClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; - ParentClientImpl client - = new ParentClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); + FileClientImpl client + = new FileClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), localEndpoint); return client; } @@ -265,24 +264,24 @@ private HttpPipeline createHttpPipeline() { } /** - * Builds an instance of ParentAsyncClient class. + * Builds an instance of FileAsyncClient class. * - * @return an instance of ParentAsyncClient. + * @return an instance of FileAsyncClient. */ @Generated - public ParentAsyncClient buildAsyncClient() { - return new ParentAsyncClient(buildInnerClient()); + public FileAsyncClient buildAsyncClient() { + return new FileAsyncClient(buildInnerClient().getBodies()); } /** - * Builds an instance of ParentClient class. + * Builds an instance of FileClient class. * - * @return an instance of ParentClient. + * @return an instance of FileClient. */ @Generated - public ParentClient buildClient() { - return new ParentClient(buildInnerClient()); + public FileClient buildClient() { + return new FileClient(buildInnerClient().getBodies()); } - private static final ClientLogger LOGGER = new ClientLogger(ParentClientBuilder.class); + private static final ClientLogger LOGGER = new ClientLogger(FileClientBuilder.class); } diff --git a/typespec-tests/src/main/java/type/file/implementation/BodiesImpl.java b/typespec-tests/src/main/java/type/file/implementation/BodiesImpl.java new file mode 100644 index 0000000000..43f5f03c38 --- /dev/null +++ b/typespec-tests/src/main/java/type/file/implementation/BodiesImpl.java @@ -0,0 +1,613 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.file.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in Bodies. + */ +public final class BodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BodiesService service; + + /** + * The service client containing this operation class. + */ + private final FileClientImpl client; + + /** + * Initializes an instance of BodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BodiesImpl(FileClientImpl client) { + this.service = RestProxy.create(BodiesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for FileClientBodies to be used by the proxy service to perform REST + * calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "FileClientBodies") + public interface BodiesService { + @Post("/type/file/body/request/specific-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadFileSpecificContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("image/png") BinaryData file, + RequestOptions requestOptions, Context context); + + @Post("/type/file/body/request/specific-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadFileSpecificContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("image/png") BinaryData file, + RequestOptions requestOptions, Context context); + + @Post("/type/file/body/request/json-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadFileJsonContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData file, + RequestOptions requestOptions, Context context); + + @Post("/type/file/body/request/json-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadFileJsonContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData file, + RequestOptions requestOptions, Context context); + + @Get("/type/file/body/response/json-content-type") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> downloadFileJsonContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/file/body/response/json-content-type") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response downloadFileJsonContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/file/body/response/specific-content-type") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> downloadFileSpecificContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/file/body/response/specific-content-type") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response downloadFileSpecificContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/type/file/body/request/multiple-content-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadFileMultipleContentTypes(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData file, + RequestOptions requestOptions, Context context); + + @Post("/type/file/body/request/multiple-content-types") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadFileMultipleContentTypesSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData file, + RequestOptions requestOptions, Context context); + + @Get("/type/file/body/response/multiple-content-types") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> downloadFileMultipleContentTypes(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/file/body/response/multiple-content-types") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response downloadFileMultipleContentTypesSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Post("/type/file/body/request/default-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> uploadFileDefaultContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("*/*") BinaryData file, + RequestOptions requestOptions, Context context); + + @Post("/type/file/body/request/default-content-type") + @ExpectedResponses({ 204 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response uploadFileDefaultContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("*/*") BinaryData file, + RequestOptions requestOptions, Context context); + + @Get("/type/file/body/response/default-content-type") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> downloadFileDefaultContentType(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/type/file/body/response/default-content-type") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response downloadFileDefaultContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + } + + /** + * The uploadFileSpecificContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are image/png. + * @param file The file 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> uploadFileSpecificContentTypeWithResponseAsync(String contentType, BinaryData file, + RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.uploadFileSpecificContentType(this.client.getEndpoint(), + contentType, file, requestOptions, context)); + } + + /** + * The uploadFileSpecificContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are image/png. + * @param file The file 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 uploadFileSpecificContentTypeWithResponse(String contentType, BinaryData file, + RequestOptions requestOptions) { + return service.uploadFileSpecificContentTypeSync(this.client.getEndpoint(), contentType, file, requestOptions, + Context.NONE); + } + + /** + * The uploadFileJsonContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param file The file 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> uploadFileJsonContentTypeWithResponseAsync(BinaryData file, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return FluxUtil.withContext(context -> service.uploadFileJsonContentType(this.client.getEndpoint(), contentType, + file, requestOptions, context)); + } + + /** + * The uploadFileJsonContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param file The file 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 uploadFileJsonContentTypeWithResponse(BinaryData file, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.uploadFileJsonContentTypeSync(this.client.getEndpoint(), contentType, file, requestOptions, + Context.NONE); + } + + /** + * The downloadFileJsonContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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> downloadFileJsonContentTypeWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> service.downloadFileJsonContentType(this.client.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The downloadFileJsonContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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 downloadFileJsonContentTypeWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.downloadFileJsonContentTypeSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The downloadFileSpecificContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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> downloadFileSpecificContentTypeWithResponseAsync(RequestOptions requestOptions) { + final String accept = "image/png"; + return FluxUtil.withContext(context -> service.downloadFileSpecificContentType(this.client.getEndpoint(), + accept, requestOptions, context)); + } + + /** + * The downloadFileSpecificContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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 downloadFileSpecificContentTypeWithResponse(RequestOptions requestOptions) { + final String accept = "image/png"; + return service.downloadFileSpecificContentTypeSync(this.client.getEndpoint(), accept, requestOptions, + Context.NONE); + } + + /** + * The uploadFileMultipleContentTypes operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are image/png,image/jpeg. + * @param file The file 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> uploadFileMultipleContentTypesWithResponseAsync(String contentType, BinaryData file, + RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.uploadFileMultipleContentTypes(this.client.getEndpoint(), + contentType, file, requestOptions, context)); + } + + /** + * The uploadFileMultipleContentTypes operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are image/png,image/jpeg. + * @param file The file 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 uploadFileMultipleContentTypesWithResponse(String contentType, BinaryData file, + RequestOptions requestOptions) { + return service.uploadFileMultipleContentTypesSync(this.client.getEndpoint(), contentType, file, requestOptions, + Context.NONE); + } + + /** + * The downloadFileMultipleContentTypes operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param accept The accept 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> downloadFileMultipleContentTypesWithResponseAsync(String accept, + RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.downloadFileMultipleContentTypes(this.client.getEndpoint(), + accept, requestOptions, context)); + } + + /** + * The downloadFileMultipleContentTypes operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param accept The accept 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 downloadFileMultipleContentTypesWithResponse(String accept, + RequestOptions requestOptions) { + return service.downloadFileMultipleContentTypesSync(this.client.getEndpoint(), accept, requestOptions, + Context.NONE); + } + + /** + * The uploadFileDefaultContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are */*. + * @param file The file 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> uploadFileDefaultContentTypeWithResponseAsync(String contentType, BinaryData file, + RequestOptions requestOptions) { + return FluxUtil.withContext(context -> service.uploadFileDefaultContentType(this.client.getEndpoint(), + contentType, file, requestOptions, context)); + } + + /** + * The uploadFileDefaultContentType operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param contentType Body parameter's content type. Known values are */*. + * @param file The file 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 uploadFileDefaultContentTypeWithResponse(String contentType, BinaryData file, + RequestOptions requestOptions) { + return service.uploadFileDefaultContentTypeSync(this.client.getEndpoint(), contentType, file, requestOptions, + Context.NONE); + } + + /** + * The downloadFileDefaultContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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> downloadFileDefaultContentTypeWithResponseAsync(RequestOptions requestOptions) { + final String accept = "*/*"; + return FluxUtil.withContext(context -> service.downloadFileDefaultContentType(this.client.getEndpoint(), accept, + requestOptions, context)); + } + + /** + * The downloadFileDefaultContentType operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @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 downloadFileDefaultContentTypeWithResponse(RequestOptions requestOptions) { + final String accept = "*/*"; + return service.downloadFileDefaultContentTypeSync(this.client.getEndpoint(), accept, requestOptions, + Context.NONE); + } +} diff --git a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/ParentClientImpl.java b/typespec-tests/src/main/java/type/file/implementation/FileClientImpl.java similarity index 69% rename from typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/ParentClientImpl.java rename to typespec-tests/src/main/java/type/file/implementation/FileClientImpl.java index fc97d0a752..142d728cab 100644 --- a/typespec-tests/src/main/java/azure/clientgenerator/core/clientinitialization/implementation/ParentClientImpl.java +++ b/typespec-tests/src/main/java/type/file/implementation/FileClientImpl.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.implementation; +package type.file.implementation; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; @@ -10,12 +10,11 @@ import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; -import java.util.Objects; /** - * Initializes a new instance of the ParentClient type. + * Initializes a new instance of the FileClient type. */ -public final class ParentClientImpl { +public final class FileClientImpl { /** * Service host. */ @@ -59,46 +58,50 @@ public SerializerAdapter getSerializerAdapter() { } /** - * Initializes an instance of ParentClient client. + * The BodiesImpl object to access its operations. + */ + private final BodiesImpl bodies; + + /** + * Gets the BodiesImpl object to access its operations. + * + * @return the BodiesImpl object. + */ + public BodiesImpl getBodies() { + return this.bodies; + } + + /** + * Initializes an instance of FileClient client. * * @param endpoint Service host. */ - public ParentClientImpl(String endpoint) { + public FileClientImpl(String endpoint) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** - * Initializes an instance of ParentClient client. + * Initializes an instance of FileClient client. * * @param httpPipeline The HTTP pipeline to send requests through. * @param endpoint Service host. */ - public ParentClientImpl(HttpPipeline httpPipeline, String endpoint) { + public FileClientImpl(HttpPipeline httpPipeline, String endpoint) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); } /** - * Initializes an instance of ParentClient client. + * Initializes an instance of FileClient client. * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. * @param endpoint Service host. */ - public ParentClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { + public FileClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; - } - - /** - * Gets an instance of ChildClientImpl class. - * - * @param blobName The blobName parameter. - * @return an instance of ChildClientImpl class. - */ - public ChildClientImpl getChildClient(String blobName) { - Objects.requireNonNull(blobName, "'blobName' cannot be null."); - return new ChildClientImpl(httpPipeline, serializerAdapter, endpoint, blobName); + this.bodies = new BodiesImpl(this); } } diff --git a/typespec-tests/src/main/java/type/file/implementation/package-info.java b/typespec-tests/src/main/java/type/file/implementation/package-info.java new file mode 100644 index 0000000000..8e8bc81517 --- /dev/null +++ b/typespec-tests/src/main/java/type/file/implementation/package-info.java @@ -0,0 +1,11 @@ +// 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 File. + * Test for File type usage in request and response bodies. + * + */ +package type.file.implementation; diff --git a/typespec-tests/src/main/java/type/file/package-info.java b/typespec-tests/src/main/java/type/file/package-info.java new file mode 100644 index 0000000000..a9ab17929b --- /dev/null +++ b/typespec-tests/src/main/java/type/file/package-info.java @@ -0,0 +1,11 @@ +// 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 File. + * Test for File type usage in request and response bodies. + * + */ +package type.file; diff --git a/typespec-tests/src/main/resources/azure-clientgenerator-core-clientinitialization.properties b/typespec-tests/src/main/resources/_specs_-azure-clientgenerator-core-clientinitialization-defaultclient.properties similarity index 100% rename from typespec-tests/src/main/resources/azure-clientgenerator-core-clientinitialization.properties rename to typespec-tests/src/main/resources/_specs_-azure-clientgenerator-core-clientinitialization-defaultclient.properties diff --git a/typespec-tests/src/main/resources/_specs_-azure-clientgenerator-core-clientinitialization-individuallyclient.properties b/typespec-tests/src/main/resources/_specs_-azure-clientgenerator-core-clientinitialization-individuallyclient.properties new file mode 100644 index 0000000000..ca812989b4 --- /dev/null +++ b/typespec-tests/src/main/resources/_specs_-azure-clientgenerator-core-clientinitialization-individuallyclient.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/typespec-tests/src/main/resources/_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties b/typespec-tests/src/main/resources/_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties new file mode 100644 index 0000000000..ca812989b4 --- /dev/null +++ b/typespec-tests/src/main/resources/_specs_-azure-clientgenerator-core-clientinitialization-individuallyparentclient.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/typespec-tests/src/main/resources/type-file.properties b/typespec-tests/src/main/resources/type-file.properties new file mode 100644 index 0000000000..ca812989b4 --- /dev/null +++ b/typespec-tests/src/main/resources/type-file.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/typespec-tests/src/test/java/azure/clientgenerator/core/clientinitialization/generated/HeaderParamClientTestBase.java b/typespec-tests/src/test/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/generated/HeaderParamClientTestBase.java similarity index 70% rename from typespec-tests/src/test/java/azure/clientgenerator/core/clientinitialization/generated/HeaderParamClientTestBase.java rename to typespec-tests/src/test/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/generated/HeaderParamClientTestBase.java index 16d677e966..4b0f55cce3 100644 --- a/typespec-tests/src/test/java/azure/clientgenerator/core/clientinitialization/generated/HeaderParamClientTestBase.java +++ b/typespec-tests/src/test/java/_specs_/azure/clientgenerator/core/clientinitialization/defaultclient/generated/HeaderParamClientTestBase.java @@ -2,26 +2,24 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package azure.clientgenerator.core.clientinitialization.generated; +package _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.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 azure.clientgenerator.core.clientinitialization.HeaderParamClient; -import azure.clientgenerator.core.clientinitialization.HeaderParamClientBuilder; -import azure.clientgenerator.core.clientinitialization.MixedParamsClient; -import azure.clientgenerator.core.clientinitialization.MixedParamsClientBuilder; -import azure.clientgenerator.core.clientinitialization.MultipleParamsClient; -import azure.clientgenerator.core.clientinitialization.MultipleParamsClientBuilder; -import azure.clientgenerator.core.clientinitialization.ParamAliasClient; -import azure.clientgenerator.core.clientinitialization.ParamAliasClientBuilder; -import azure.clientgenerator.core.clientinitialization.PathParamClient; -import azure.clientgenerator.core.clientinitialization.PathParamClientBuilder; -import azure.clientgenerator.core.clientinitialization.parentclient.ChildClient; -import azure.clientgenerator.core.clientinitialization.parentclient.ChildClientBuilder; -import azure.clientgenerator.core.clientinitialization.parentclient.ParentClient; -import azure.clientgenerator.core.clientinitialization.parentclient.ParentClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.HeaderParamClient; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.HeaderParamClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.MixedParamsClient; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.MixedParamsClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.MultipleParamsClient; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.MultipleParamsClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.ParamAliasClient; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.ParamAliasClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.PathParamClient; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.PathParamClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.QueryParamClient; +import _specs_.azure.clientgenerator.core.clientinitialization.defaultclient.QueryParamClientBuilder; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.test.TestMode; @@ -39,9 +37,7 @@ class HeaderParamClientTestBase extends TestProxyTestBase { protected ParamAliasClient paramAliasClient; - protected ChildClient childClient; - - protected ParentClient parentClient; + protected QueryParamClient queryParamClient; @Override protected void beforeTest() { @@ -96,24 +92,15 @@ protected void beforeTest() { } paramAliasClient = paramAliasClientbuilder.buildClient(); - ChildClientBuilder childClientbuilder = new ChildClientBuilder() + QueryParamClientBuilder queryParamClientbuilder = new QueryParamClientBuilder() .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) .blobName(Configuration.getGlobalConfiguration().get("BLOBNAME", "blobname")) .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); if (getTestMode() == TestMode.RECORD) { - childClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); - } - childClient = childClientbuilder.buildClient(); - - ParentClientBuilder parentClientbuilder = new ParentClientBuilder() - .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) - .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); - if (getTestMode() == TestMode.RECORD) { - parentClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + queryParamClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); } - parentClient = parentClientbuilder.buildClient(); + queryParamClient = queryParamClientbuilder.buildClient(); } } diff --git a/typespec-tests/src/test/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/generated/IndividuallyNestedWithPathClientTestBase.java b/typespec-tests/src/test/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/generated/IndividuallyNestedWithPathClientTestBase.java new file mode 100644 index 0000000000..c5add06432 --- /dev/null +++ b/typespec-tests/src/test/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyclient/generated/IndividuallyNestedWithPathClientTestBase.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.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 _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithHeaderClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithHeaderClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithMixedClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithMixedClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithMultipleClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithMultipleClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithParamAliasClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithParamAliasClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithPathClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithPathClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithQueryClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyclient.IndividuallyNestedWithQueryClientBuilder; +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; + +class IndividuallyNestedWithPathClientTestBase extends TestProxyTestBase { + protected IndividuallyNestedWithPathClient individuallyNestedWithPathClient; + + protected IndividuallyNestedWithQueryClient individuallyNestedWithQueryClient; + + protected IndividuallyNestedWithHeaderClient individuallyNestedWithHeaderClient; + + protected IndividuallyNestedWithMultipleClient individuallyNestedWithMultipleClient; + + protected IndividuallyNestedWithMixedClient individuallyNestedWithMixedClient; + + protected IndividuallyNestedWithParamAliasClient individuallyNestedWithParamAliasClient; + + @Override + protected void beforeTest() { + IndividuallyNestedWithPathClientBuilder individuallyNestedWithPathClientbuilder + = new IndividuallyNestedWithPathClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .blobName(Configuration.getGlobalConfiguration().get("BLOBNAME", "blobname")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyNestedWithPathClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyNestedWithPathClient = individuallyNestedWithPathClientbuilder.buildClient(); + + IndividuallyNestedWithQueryClientBuilder individuallyNestedWithQueryClientbuilder + = new IndividuallyNestedWithQueryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .blobName(Configuration.getGlobalConfiguration().get("BLOBNAME", "blobname")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyNestedWithQueryClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyNestedWithQueryClient = individuallyNestedWithQueryClientbuilder.buildClient(); + + IndividuallyNestedWithHeaderClientBuilder individuallyNestedWithHeaderClientbuilder + = new IndividuallyNestedWithHeaderClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .name(Configuration.getGlobalConfiguration().get("NAME", "name")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyNestedWithHeaderClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyNestedWithHeaderClient = individuallyNestedWithHeaderClientbuilder.buildClient(); + + IndividuallyNestedWithMultipleClientBuilder individuallyNestedWithMultipleClientbuilder + = new IndividuallyNestedWithMultipleClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .name(Configuration.getGlobalConfiguration().get("NAME", "name")) + .region(Configuration.getGlobalConfiguration().get("REGION", "region")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyNestedWithMultipleClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyNestedWithMultipleClient = individuallyNestedWithMultipleClientbuilder.buildClient(); + + IndividuallyNestedWithMixedClientBuilder individuallyNestedWithMixedClientbuilder + = new IndividuallyNestedWithMixedClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .name(Configuration.getGlobalConfiguration().get("NAME", "name")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyNestedWithMixedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyNestedWithMixedClient = individuallyNestedWithMixedClientbuilder.buildClient(); + + IndividuallyNestedWithParamAliasClientBuilder individuallyNestedWithParamAliasClientbuilder + = new IndividuallyNestedWithParamAliasClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .blobName(Configuration.getGlobalConfiguration().get("BLOBNAME", "blobname")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyNestedWithParamAliasClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyNestedWithParamAliasClient = individuallyNestedWithParamAliasClientbuilder.buildClient(); + + } +} diff --git a/typespec-tests/src/test/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/generated/IndividuallyParentNestedWithPathClientTestBase.java b/typespec-tests/src/test/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/generated/IndividuallyParentNestedWithPathClientTestBase.java new file mode 100644 index 0000000000..79eb17cdd8 --- /dev/null +++ b/typespec-tests/src/test/java/_specs_/azure/clientgenerator/core/clientinitialization/individuallyparentclient/generated/IndividuallyParentNestedWithPathClientTestBase.java @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.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 _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithHeaderClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithHeaderClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithMixedClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithMixedClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithMultipleClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithMultipleClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithParamAliasClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithParamAliasClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithPathClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithPathClientBuilder; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithQueryClient; +import _specs_.azure.clientgenerator.core.clientinitialization.individuallyparentclient.IndividuallyParentNestedWithQueryClientBuilder; +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; + +class IndividuallyParentNestedWithPathClientTestBase extends TestProxyTestBase { + protected IndividuallyParentNestedWithPathClient individuallyParentNestedWithPathClient; + + protected IndividuallyParentNestedWithQueryClient individuallyParentNestedWithQueryClient; + + protected IndividuallyParentNestedWithHeaderClient individuallyParentNestedWithHeaderClient; + + protected IndividuallyParentNestedWithMultipleClient individuallyParentNestedWithMultipleClient; + + protected IndividuallyParentNestedWithMixedClient individuallyParentNestedWithMixedClient; + + protected IndividuallyParentNestedWithParamAliasClient individuallyParentNestedWithParamAliasClient; + + protected IndividuallyParentClient individuallyParentClient; + + @Override + protected void beforeTest() { + IndividuallyParentNestedWithPathClientBuilder individuallyParentNestedWithPathClientbuilder + = new IndividuallyParentNestedWithPathClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .blobName(Configuration.getGlobalConfiguration().get("BLOBNAME", "blobname")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyParentNestedWithPathClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyParentNestedWithPathClient = individuallyParentNestedWithPathClientbuilder.buildClient(); + + IndividuallyParentNestedWithQueryClientBuilder individuallyParentNestedWithQueryClientbuilder + = new IndividuallyParentNestedWithQueryClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .blobName(Configuration.getGlobalConfiguration().get("BLOBNAME", "blobname")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyParentNestedWithQueryClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyParentNestedWithQueryClient = individuallyParentNestedWithQueryClientbuilder.buildClient(); + + IndividuallyParentNestedWithHeaderClientBuilder individuallyParentNestedWithHeaderClientbuilder + = new IndividuallyParentNestedWithHeaderClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .name(Configuration.getGlobalConfiguration().get("NAME", "name")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyParentNestedWithHeaderClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyParentNestedWithHeaderClient = individuallyParentNestedWithHeaderClientbuilder.buildClient(); + + IndividuallyParentNestedWithMultipleClientBuilder individuallyParentNestedWithMultipleClientbuilder + = new IndividuallyParentNestedWithMultipleClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .name(Configuration.getGlobalConfiguration().get("NAME", "name")) + .region(Configuration.getGlobalConfiguration().get("REGION", "region")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyParentNestedWithMultipleClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyParentNestedWithMultipleClient = individuallyParentNestedWithMultipleClientbuilder.buildClient(); + + IndividuallyParentNestedWithMixedClientBuilder individuallyParentNestedWithMixedClientbuilder + = new IndividuallyParentNestedWithMixedClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .name(Configuration.getGlobalConfiguration().get("NAME", "name")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyParentNestedWithMixedClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyParentNestedWithMixedClient = individuallyParentNestedWithMixedClientbuilder.buildClient(); + + IndividuallyParentNestedWithParamAliasClientBuilder individuallyParentNestedWithParamAliasClientbuilder + = new IndividuallyParentNestedWithParamAliasClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .blobName(Configuration.getGlobalConfiguration().get("BLOBNAME", "blobname")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyParentNestedWithParamAliasClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyParentNestedWithParamAliasClient + = individuallyParentNestedWithParamAliasClientbuilder.buildClient(); + + IndividuallyParentClientBuilder individuallyParentClientbuilder = new IndividuallyParentClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + individuallyParentClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + individuallyParentClient = individuallyParentClientbuilder.buildClient(); + + } +} diff --git a/typespec-tests/src/test/java/payload/multipart/generated/MultiPartClientTestBase.java b/typespec-tests/src/test/java/payload/multipart/generated/MultiPartClientTestBase.java index 24d5eeb281..d0ebfc8186 100644 --- a/typespec-tests/src/test/java/payload/multipart/generated/MultiPartClientTestBase.java +++ b/typespec-tests/src/test/java/payload/multipart/generated/MultiPartClientTestBase.java @@ -14,6 +14,7 @@ import com.azure.core.test.TestProxyTestBase; import com.azure.core.util.Configuration; import payload.multipart.FormDataClient; +import payload.multipart.FormDataFileClient; import payload.multipart.FormDataHttpPartsClient; import payload.multipart.FormDataHttpPartsContentTypeClient; import payload.multipart.FormDataHttpPartsNonStringClient; @@ -28,6 +29,8 @@ class MultiPartClientTestBase extends TestProxyTestBase { protected FormDataHttpPartsNonStringClient formDataHttpPartsNonStringClient; + protected FormDataFileClient formDataFileClient; + @Override protected void beforeTest() { MultiPartClientBuilder formDataClientbuilder = new MultiPartClientBuilder() @@ -68,5 +71,14 @@ protected void beforeTest() { formDataHttpPartsNonStringClient = formDataHttpPartsNonStringClientbuilder.buildFormDataHttpPartsNonStringClient(); + MultiPartClientBuilder formDataFileClientbuilder = new MultiPartClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + formDataFileClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + formDataFileClient = formDataFileClientbuilder.buildFormDataFileClient(); + } } diff --git a/typespec-tests/src/test/java/payload/pageable/PageableTests.java b/typespec-tests/src/test/java/payload/pageable/PageableTests.java deleted file mode 100644 index dd00187844..0000000000 --- a/typespec-tests/src/test/java/payload/pageable/PageableTests.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package payload.pageable; - -//import com.azure.core.http.rest.PagedIterable; -//import org.junit.jupiter.api.Assertions; -//import org.junit.jupiter.api.Test; -//import payload.pageable.models.Pet; - -public class PageableTests { - -// private final ServerDrivenPaginationClient client = new PageableClientBuilder().buildServerDrivenPaginationClient(); -// -// @Test -// public void testNextLink() { -// PagedIterable pagedIterable = client.link(); -// -// Assertions.assertEquals(4, pagedIterable.stream().count()); -// } -} diff --git a/typespec-tests/src/test/java/tsptest/clientinitialization/generated/ClientInitializationClientTestBase.java b/typespec-tests/src/test/java/tsptest/clientinitialization/generated/SubClientTestBase.java similarity index 66% rename from typespec-tests/src/test/java/tsptest/clientinitialization/generated/ClientInitializationClientTestBase.java rename to typespec-tests/src/test/java/tsptest/clientinitialization/generated/SubClientTestBase.java index 593cce4525..92c1b125ac 100644 --- a/typespec-tests/src/test/java/tsptest/clientinitialization/generated/ClientInitializationClientTestBase.java +++ b/typespec-tests/src/test/java/tsptest/clientinitialization/generated/SubClientTestBase.java @@ -15,12 +15,26 @@ import com.azure.core.util.Configuration; import tsptest.clientinitialization.ClientInitializationClient; import tsptest.clientinitialization.ClientInitializationClientBuilder; +import tsptest.clientinitialization.SubClient; +import tsptest.clientinitialization.SubClientBuilder; + +class SubClientTestBase extends TestProxyTestBase { + protected SubClient subClient; -class ClientInitializationClientTestBase extends TestProxyTestBase { protected ClientInitializationClient clientInitializationClient; @Override protected void beforeTest() { + SubClientBuilder subClientbuilder = new SubClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .name(Configuration.getGlobalConfiguration().get("NAME", "name")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + subClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + subClient = subClientbuilder.buildClient(); + ClientInitializationClientBuilder clientInitializationClientbuilder = new ClientInitializationClientBuilder() .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) diff --git a/typespec-tests/src/test/java/type/file/generated/FileClientTestBase.java b/typespec-tests/src/test/java/type/file/generated/FileClientTestBase.java new file mode 100644 index 0000000000..7d39e1178d --- /dev/null +++ b/typespec-tests/src/test/java/type/file/generated/FileClientTestBase.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.file.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 type.file.FileClient; +import type.file.FileClientBuilder; + +class FileClientTestBase extends TestProxyTestBase { + protected FileClient fileClient; + + @Override + protected void beforeTest() { + FileClientBuilder fileClientbuilder = new FileClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "http://localhost:3000")) + .httpClient(getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(null))) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.RECORD) { + fileClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + fileClient = fileClientbuilder.buildClient(); + + } +}